/* Generated by Cython 0.28.2 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "define_macros": [
            [
                "_GLIBCXX_USE_CXX11_ABI",
                "0"
            ],
            [
                "_FORCE_INLINES",
                "1"
            ],
            [
                "CUPY_NO_CUDA",
                "1"
            ]
        ],
        "depends": [],
        "include_dirs": [
            "/usr/local/cuda/include"
        ],
        "language": "c++",
        "library_dirs": [
            "/usr/local/cuda/lib64"
        ],
        "name": "cupy.core.core",
        "runtime_library_dirs": [
            "/usr/local/cuda/lib64"
        ],
        "sources": [
            "cupy/core/core.pyx"
        ]
    },
    "module_name": "cupy.core.core"
}
END: Cython Metadata */

#define 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_28_2"
#define CYTHON_FUTURE_DIVISION 1
#include <stddef.h>
#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
#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
#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
    #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
  #ifndef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL 1
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
  #undef SHIFT
  #undef BASE
  #undef MASK
#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<class T> 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 <stdint.h>
#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<typename T>
void __Pyx_call_destructor(T& x) {
    x.~T();
}
template<typename T>
class __Pyx_FakeReference {
  public:
    __Pyx_FakeReference() : ptr(NULL) { }
    __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
    T *operator->() { return ptr; }
    T *operator&() { return ptr; }
    operator T&() { return *ptr; }
    template<typename U> bool operator ==(U other) { return *ptr == other; }
    template<typename U> 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_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 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
#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)))))
#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_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; // PyThread_create_key reports success always
}
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 // TSS (Thread Specific Storage) API
#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
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #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)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#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)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? 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
#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 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   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), 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(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#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_ERR(f_index, lineno, Ln_error) \
{ \
  __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; 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__cupy__core__core
#define __PYX_HAVE_API__cupy__core__core
/* Early includes */
#include "ios"
#include "new"
#include "stdexcept"
#include "typeinfo"
#include <vector>
#include <utility>
#include <map>
#include <string.h>
#include <stdio.h>
#include "pythread.h"
#include <stdlib.h>
#include "pystate.h"
#ifdef _OPENMP
#include <omp.h>
#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_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_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)))  )
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #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)
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(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);
#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));
    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;
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;

/* Header.proto */
#if !defined(CYTHON_CCOMPLEX)
  #if defined(__cplusplus)
    #define CYTHON_CCOMPLEX 1
  #elif defined(_Complex_I)
    #define CYTHON_CCOMPLEX 1
  #else
    #define CYTHON_CCOMPLEX 0
  #endif
#endif
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #include <complex>
  #else
    #include <complex.h>
  #endif
#endif
#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  #undef _Complex_I
  #define _Complex_I 1.0fj
#endif


static const char *__pyx_f[] = {
  "cupy/core/core.pyx",
  "cupy/core/elementwise.pxi",
  "cupy/core/carray.pxi",
  "cupy/core/core.pxd",
  "stringsource",
  "cupy/core/reduction.pxi",
  "cupy/cuda/device.pxd",
  "cupy/cuda/memory.pxd",
  "cupy/cuda/function.pxd",
  "type.pxd",
  "bool.pxd",
  "complex.pxd",
  "cupy/cuda/pinned_memory.pxd",
  "cupy/cuda/runtime.pxd",
};
/* 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])

/* Atomics.proto */
#include <pythread.h>
#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 <Windows.h>
    #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

/* 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;

/* Declarations.proto */
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< double > __pyx_t_double_complex;
  #else
    typedef double _Complex __pyx_t_double_complex;
  #endif
#else
    typedef struct { double real, imag; } __pyx_t_double_complex;
#endif
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);

/* Declarations.proto */
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< float > __pyx_t_float_complex;
  #else
    typedef float _Complex __pyx_t_float_complex;
  #endif
#else
    typedef struct { float real, imag; } __pyx_t_float_complex;
#endif
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);


/*--- Type declarations ---*/
struct __pyx_obj_4cupy_4cuda_6device_Device;
struct __pyx_obj_4cupy_4cuda_6memory_Memory;
struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer;
struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool;
struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool;
struct __pyx_obj_4cupy_4cuda_8function_CPointer;
struct __pyx_obj_4cupy_4cuda_8function_Function;
struct __pyx_obj_4cupy_4cuda_8function_Module;
struct __pyx_obj_4cupy_4cuda_8function_LinkState;
struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer;
struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPool;
struct __pyx_obj_4cupy_4cuda_7runtime_PointerAttributes;
struct __pyx_obj_4cupy_4core_4core_ndarray;
struct __pyx_obj_4cupy_4core_4core_Indexer;
struct __pyx_obj_4cupy_4core_4core_CArray;
struct __pyx_obj_4cupy_4core_4core_CIndexer;
struct __pyx_obj_4cupy_4core_4core_ParameterInfo;
struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel;
struct __pyx_obj_4cupy_4core_4core_broadcast;
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel;
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr;
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__;
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr;
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr;
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel;
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr;
struct __pyx_array_obj;
struct __pyx_MemviewEnum_obj;
struct __pyx_memoryview_obj;
struct __pyx_memoryviewslice_obj;
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_device_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_host_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_to_host_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_memset_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_set_allocator;
struct __pyx_opt_args_4cupy_4cuda_6memory_22SingleDeviceMemoryPool_free_all_blocks;
struct __pyx_opt_args_4cupy_4cuda_6memory_10MemoryPool_free_all_blocks;

/* "memory.pxd":23
 * 
 *     cpdef copy_from_device(self, MemoryPointer src, Py_ssize_t size)
 *     cpdef copy_from_device_async(self, MemoryPointer src, size_t size,             # <<<<<<<<<<<<<<
 *                                  stream=?)
 *     cpdef copy_from_host(self, mem, size_t size)
 */
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_device_async {
  int __pyx_n;
  PyObject *stream;
};

/* "memory.pxd":26
 *                                  stream=?)
 *     cpdef copy_from_host(self, mem, size_t size)
 *     cpdef copy_from_host_async(self, mem, size_t size, stream=?)             # <<<<<<<<<<<<<<
 *     cpdef copy_from(self, mem, size_t size)
 *     cpdef copy_from_async(self, mem, size_t size, stream=?)
 */
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_host_async {
  int __pyx_n;
  PyObject *stream;
};

/* "memory.pxd":28
 *     cpdef copy_from_host_async(self, mem, size_t size, stream=?)
 *     cpdef copy_from(self, mem, size_t size)
 *     cpdef copy_from_async(self, mem, size_t size, stream=?)             # <<<<<<<<<<<<<<
 *     cpdef copy_to_host(self, mem, size_t size)
 *     cpdef copy_to_host_async(self, mem, size_t size, stream=?)
 */
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_async {
  int __pyx_n;
  PyObject *stream;
};

/* "memory.pxd":30
 *     cpdef copy_from_async(self, mem, size_t size, stream=?)
 *     cpdef copy_to_host(self, mem, size_t size)
 *     cpdef copy_to_host_async(self, mem, size_t size, stream=?)             # <<<<<<<<<<<<<<
 *     cpdef memset(self, int value, size_t size)
 *     cpdef memset_async(self, int value, size_t size, stream=?)
 */
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_to_host_async {
  int __pyx_n;
  PyObject *stream;
};

/* "memory.pxd":32
 *     cpdef copy_to_host_async(self, mem, size_t size, stream=?)
 *     cpdef memset(self, int value, size_t size)
 *     cpdef memset_async(self, int value, size_t size, stream=?)             # <<<<<<<<<<<<<<
 * 
 * 
 */
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_memset_async {
  int __pyx_n;
  PyObject *stream;
};

/* "memory.pxd":38
 * 
 * 
 * cpdef set_allocator(allocator=*)             # <<<<<<<<<<<<<<
 * 
 * 
 */
struct __pyx_opt_args_4cupy_4cuda_6memory_set_allocator {
  int __pyx_n;
  PyObject *allocator;
};

/* "memory.pxd":71
 *     cpdef MemoryPointer _malloc(self, Py_ssize_t size)
 *     cpdef free(self, size_t ptr, Py_ssize_t size)
 *     cpdef free_all_blocks(self, stream=?)             # <<<<<<<<<<<<<<
 *     cpdef free_all_free(self)
 *     cpdef n_free_blocks(self)
 */
struct __pyx_opt_args_4cupy_4cuda_6memory_22SingleDeviceMemoryPool_free_all_blocks {
  int __pyx_n;
  PyObject *stream;
};

/* "memory.pxd":91
 * 
 *     cpdef MemoryPointer malloc(self, Py_ssize_t size)
 *     cpdef free_all_blocks(self, stream=?)             # <<<<<<<<<<<<<<
 *     cpdef free_all_free(self)
 *     cpdef n_free_blocks(self)
 */
struct __pyx_opt_args_4cupy_4cuda_6memory_10MemoryPool_free_all_blocks {
  int __pyx_n;
  PyObject *stream;
};
struct __pyx_opt_args_4cupy_4cuda_8function_8Function_linear_launch;

/* "cupy/cuda/function.pxd":11
 *         public size_t ptr
 * 
 *     cpdef linear_launch(self, size_t size, args, size_t shared_mem=*,             # <<<<<<<<<<<<<<
 *                         size_t block_max_size=*, stream=*)
 * 
 */
struct __pyx_opt_args_4cupy_4cuda_8function_8Function_linear_launch {
  int __pyx_n;
  size_t shared_mem;
  size_t block_max_size;
  PyObject *stream;
};
struct __pyx_opt_args_4cupy_4core_8internal_prod;
struct __pyx_opt_args_4cupy_4core_8internal_prod_ssize_t;

/* "internal.pxd":3
 * from libcpp cimport vector
 * 
 * cpdef Py_ssize_t prod(args, Py_ssize_t init=*) except *             # <<<<<<<<<<<<<<
 * 
 * cpdef Py_ssize_t prod_ssize_t(
 */
struct __pyx_opt_args_4cupy_4core_8internal_prod {
  int __pyx_n;
  Py_ssize_t init;
};

/* "internal.pxd":5
 * cpdef Py_ssize_t prod(args, Py_ssize_t init=*) except *
 * 
 * cpdef Py_ssize_t prod_ssize_t(             # <<<<<<<<<<<<<<
 *     vector.vector[Py_ssize_t]& arr, Py_ssize_t init=*)
 * 
 */
struct __pyx_opt_args_4cupy_4core_8internal_prod_ssize_t {
  int __pyx_n;
  Py_ssize_t init;
};

/* "cublas.pxd":29
 * ###############################################################################
 * 
 * cpdef enum:             # <<<<<<<<<<<<<<
 *     CUBLAS_OP_N = 0
 *     CUBLAS_OP_T = 1
 */
enum  {
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_OP_N = 0,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_OP_T = 1,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_OP_C = 2,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_POINTER_MODE_HOST = 0,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_POINTER_MODE_DEVICE = 1,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_SIDE_LEFT = 0,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_SIDE_RIGHT = 1,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_FILL_MODE_LOWER = 0,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_FILL_MODE_UPPER = 1,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_DIAG_NON_UNIT = 0,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_DIAG_UNIT = 1,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_GEMM_DFALT = -1L,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_GEMM_DFALT_TENSOR_OP = 99,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_DEFAULT_MATH = 0,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_TENSOR_OP_MATH = 1
};
struct __pyx_opt_args_4cupy_4cuda_13pinned_memory_set_pinned_memory_allocator;

/* "pinned_memory.pxd":19
 * 
 * 
 * cpdef set_pinned_memory_allocator(allocator=*)             # <<<<<<<<<<<<<<
 * 
 * 
 */
struct __pyx_opt_args_4cupy_4cuda_13pinned_memory_set_pinned_memory_allocator {
  int __pyx_n;
  PyObject *allocator;
};
struct __pyx_opt_args_4cupy_4cuda_7runtime_mallocManaged;
struct __pyx_opt_args_4cupy_4cuda_7runtime_streamAddCallback;
struct __pyx_opt_args_4cupy_4cuda_7runtime_streamWaitEvent;

/* "runtime.pxd":23
 * ###############################################################################
 * 
 * cpdef enum:             # <<<<<<<<<<<<<<
 *     memcpyHostToHost = 0
 *     memcpyHostToDevice = 1
 */
enum  {
  __pyx_e_4cupy_4cuda_7runtime_memcpyHostToHost = 0,
  __pyx_e_4cupy_4cuda_7runtime_memcpyHostToDevice = 1,
  __pyx_e_4cupy_4cuda_7runtime_memcpyDeviceToHost = 2,
  __pyx_e_4cupy_4cuda_7runtime_memcpyDeviceToDevice = 3,
  __pyx_e_4cupy_4cuda_7runtime_memcpyDefault = 4,
  __pyx_e_4cupy_4cuda_7runtime_cudaMemoryTypeHost = 1,
  __pyx_e_4cupy_4cuda_7runtime_cudaMemoryTypeDevice = 2,
  __pyx_e_4cupy_4cuda_7runtime_cudaMemAttachGlobal = 1,
  __pyx_e_4cupy_4cuda_7runtime_cudaMemAttachHost = 2,
  __pyx_e_4cupy_4cuda_7runtime_cudaMemAttachSingle = 4,
  __pyx_e_4cupy_4cuda_7runtime_hostAllocDefault = 0,
  __pyx_e_4cupy_4cuda_7runtime_hostAllocPortable = 1,
  __pyx_e_4cupy_4cuda_7runtime_hostAllocMapped = 2,
  __pyx_e_4cupy_4cuda_7runtime_hostAllocWriteCombined = 4,
  __pyx_e_4cupy_4cuda_7runtime_cudaMemAdviseSetReadMostly = 1,
  __pyx_e_4cupy_4cuda_7runtime_cudaMemAdviseUnsetReadMostly = 2,
  __pyx_e_4cupy_4cuda_7runtime_cudaMemAdviseSetPreferredLocation = 3,
  __pyx_e_4cupy_4cuda_7runtime_cudaMemAdviseUnsetPreferredLocation = 4,
  __pyx_e_4cupy_4cuda_7runtime_cudaMemAdviseSetAccessedBy = 5,
  __pyx_e_4cupy_4cuda_7runtime_cudaMemAdviseUnsetAccessedBy = 6,
  __pyx_e_4cupy_4cuda_7runtime_streamDefault = 0,
  __pyx_e_4cupy_4cuda_7runtime_streamNonBlocking = 1,
  __pyx_e_4cupy_4cuda_7runtime_eventDefault = 0,
  __pyx_e_4cupy_4cuda_7runtime_eventBlockingSync = 1,
  __pyx_e_4cupy_4cuda_7runtime_eventDisableTiming = 2,
  __pyx_e_4cupy_4cuda_7runtime_eventInterprocess = 4,
  __pyx_e_4cupy_4cuda_7runtime_CUDA_R_32F = 0,
  __pyx_e_4cupy_4cuda_7runtime_CUDA_R_64F = 1,
  __pyx_e_4cupy_4cuda_7runtime_CUDA_R_16F = 2,
  __pyx_e_4cupy_4cuda_7runtime_CUDA_R_8I = 3,
  __pyx_e_4cupy_4cuda_7runtime_CUDA_C_32F = 4,
  __pyx_e_4cupy_4cuda_7runtime_CUDA_C_64F = 5,
  __pyx_e_4cupy_4cuda_7runtime_CUDA_C_16F = 6,
  __pyx_e_4cupy_4cuda_7runtime_CUDA_C_8I = 7,
  __pyx_e_4cupy_4cuda_7runtime_CUDA_R_8U = 8,
  __pyx_e_4cupy_4cuda_7runtime_CUDA_C_8U = 9,
  __pyx_e_4cupy_4cuda_7runtime_errorMemoryAllocation = 2
};

/* "runtime.pxd":105
 * 
 * cpdef size_t malloc(size_t size) except *
 * cpdef size_t mallocManaged(size_t size, unsigned int flags=*) except *             # <<<<<<<<<<<<<<
 * cpdef size_t hostAlloc(size_t size, unsigned int flags) except *
 * cpdef free(size_t ptr)
 */
struct __pyx_opt_args_4cupy_4cuda_7runtime_mallocManaged {
  int __pyx_n;
  unsigned int flags;
};

/* "runtime.pxd":134
 * cpdef streamDestroy(size_t stream)
 * cpdef streamSynchronize(size_t stream)
 * cpdef streamAddCallback(size_t stream, callback, size_t arg,             # <<<<<<<<<<<<<<
 *                         unsigned int flags=*)
 * cpdef streamQuery(size_t stream)
 */
struct __pyx_opt_args_4cupy_4cuda_7runtime_streamAddCallback {
  int __pyx_n;
  unsigned int flags;
};

/* "runtime.pxd":137
 *                         unsigned int flags=*)
 * cpdef streamQuery(size_t stream)
 * cpdef streamWaitEvent(size_t stream, size_t event, unsigned int flags=*)             # <<<<<<<<<<<<<<
 * cpdef size_t eventCreate() except *
 * cpdef size_t eventCreateWithFlags(unsigned int flags) except *
 */
struct __pyx_opt_args_4cupy_4cuda_7runtime_streamWaitEvent {
  int __pyx_n;
  unsigned int flags;
};
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tofile;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_squeeze;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_take;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_choose;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_diagonal;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_max;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmax;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_min;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmin;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_trace;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_mean;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_var;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_std;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_all;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_get;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_reduced_view;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides;
struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray;
struct __pyx_t_4cupy_4core_4core__CArray;
struct __pyx_t_4cupy_4core_4core__CIndexer;
struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache;
struct __pyx_opt_args_4cupy_4core_4core__get_simple_elementwise_kernel;
struct __pyx_opt_args_4cupy_4core_4core__get_out_args_with_params;
struct __pyx_opt_args_4cupy_4core_4core_create_ufunc;
struct __pyx_opt_args_4cupy_4core_4core_create_reduction_func;
struct __pyx_opt_args_4cupy_4core_4core_array;
struct __pyx_opt_args_4cupy_4core_4core_asfortranarray;
struct __pyx_opt_args_4cupy_4core_4core_rollaxis;
struct __pyx_opt_args_4cupy_4core_4core__repeat;
struct __pyx_opt_args_4cupy_4core_4core_size;
struct __pyx_opt_args_4cupy_4core_4core__create_bit_op;
struct __pyx_opt_args_4cupy_4core_4core__take;
struct __pyx_opt_args_4cupy_4core_4core__scatter_op_single;
struct __pyx_opt_args_4cupy_4core_4core__diagonal;
struct __pyx_opt_args_4cupy_4core_4core_dot;
struct __pyx_opt_args_4cupy_4core_4core_matmul;
struct __pyx_opt_args_4cupy_4core_4core_create_comparison;
struct __pyx_opt_args_4cupy_4core_4core__var;
struct __pyx_opt_args_4cupy_4core_4core__std;
struct __pyx_opt_args_4cupy_4core_4core_scan;

/* "cupy/core/core.pxd":20
 * 
 *     cpdef tolist(self)
 *     cpdef tofile(self, fid, sep=*, format=*)             # <<<<<<<<<<<<<<
 *     cpdef dump(self, file)
 *     cpdef dumps(self)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tofile {
  int __pyx_n;
  PyObject *sep;
  PyObject *format;
};

/* "cupy/core/core.pxd":23
 *     cpdef dump(self, file)
 *     cpdef dumps(self)
 *     cpdef ndarray astype(self, dtype, order=*, casting=*, subok=*, copy=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray copy(self, order=*)
 *     cpdef ndarray view(self, dtype=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype {
  int __pyx_n;
  PyObject *order;
  PyObject *casting;
  PyObject *subok;
  PyObject *copy;
};

/* "cupy/core/core.pxd":24
 *     cpdef dumps(self)
 *     cpdef ndarray astype(self, dtype, order=*, casting=*, subok=*, copy=*)
 *     cpdef ndarray copy(self, order=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray view(self, dtype=*)
 *     cpdef fill(self, value)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy {
  int __pyx_n;
  PyObject *order;
};

/* "cupy/core/core.pxd":25
 *     cpdef ndarray astype(self, dtype, order=*, casting=*, subok=*, copy=*)
 *     cpdef ndarray copy(self, order=*)
 *     cpdef ndarray view(self, dtype=*)             # <<<<<<<<<<<<<<
 *     cpdef fill(self, value)
 *     cpdef ndarray _reshape(self, vector.vector[Py_ssize_t] shape)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view {
  int __pyx_n;
  PyObject *dtype;
};

/* "cupy/core/core.pxd":32
 *     cpdef ndarray flatten(self)
 *     cpdef ndarray ravel(self)
 *     cpdef ndarray squeeze(self, axis=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray take(self, indices, axis=*, out=*)
 *     cpdef repeat(self, repeats, axis=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_squeeze {
  int __pyx_n;
  PyObject *axis;
};

/* "cupy/core/core.pxd":33
 *     cpdef ndarray ravel(self)
 *     cpdef ndarray squeeze(self, axis=*)
 *     cpdef ndarray take(self, indices, axis=*, out=*)             # <<<<<<<<<<<<<<
 *     cpdef repeat(self, repeats, axis=*)
 *     cpdef choose(self, choices, out=*, mode=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_take {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
};

/* "cupy/core/core.pxd":34
 *     cpdef ndarray squeeze(self, axis=*)
 *     cpdef ndarray take(self, indices, axis=*, out=*)
 *     cpdef repeat(self, repeats, axis=*)             # <<<<<<<<<<<<<<
 *     cpdef choose(self, choices, out=*, mode=*)
 *     cpdef ndarray diagonal(self, offset=*, axis1=*, axis2=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat {
  int __pyx_n;
  PyObject *axis;
};

/* "cupy/core/core.pxd":35
 *     cpdef ndarray take(self, indices, axis=*, out=*)
 *     cpdef repeat(self, repeats, axis=*)
 *     cpdef choose(self, choices, out=*, mode=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray diagonal(self, offset=*, axis1=*, axis2=*)
 *     cpdef ndarray max(self, axis=*, out=*, dtype=*, keepdims=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_choose {
  int __pyx_n;
  PyObject *out;
  PyObject *mode;
};

/* "cupy/core/core.pxd":36
 *     cpdef repeat(self, repeats, axis=*)
 *     cpdef choose(self, choices, out=*, mode=*)
 *     cpdef ndarray diagonal(self, offset=*, axis1=*, axis2=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray max(self, axis=*, out=*, dtype=*, keepdims=*)
 *     cpdef ndarray argmax(self, axis=*, out=*, dtype=*,
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_diagonal {
  int __pyx_n;
  PyObject *offset;
  PyObject *axis1;
  PyObject *axis2;
};

/* "cupy/core/core.pxd":37
 *     cpdef choose(self, choices, out=*, mode=*)
 *     cpdef ndarray diagonal(self, offset=*, axis1=*, axis2=*)
 *     cpdef ndarray max(self, axis=*, out=*, dtype=*, keepdims=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray argmax(self, axis=*, out=*, dtype=*,
 *                          keepdims=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_max {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
  PyObject *dtype;
  PyObject *keepdims;
};

/* "cupy/core/core.pxd":38
 *     cpdef ndarray diagonal(self, offset=*, axis1=*, axis2=*)
 *     cpdef ndarray max(self, axis=*, out=*, dtype=*, keepdims=*)
 *     cpdef ndarray argmax(self, axis=*, out=*, dtype=*,             # <<<<<<<<<<<<<<
 *                          keepdims=*)
 *     cpdef ndarray min(self, axis=*, out=*, dtype=*, keepdims=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmax {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
  PyObject *dtype;
  PyObject *keepdims;
};

/* "cupy/core/core.pxd":40
 *     cpdef ndarray argmax(self, axis=*, out=*, dtype=*,
 *                          keepdims=*)
 *     cpdef ndarray min(self, axis=*, out=*, dtype=*, keepdims=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray argmin(self, axis=*, out=*, dtype=*,
 *                          keepdims=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_min {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
  PyObject *dtype;
  PyObject *keepdims;
};

/* "cupy/core/core.pxd":41
 *                          keepdims=*)
 *     cpdef ndarray min(self, axis=*, out=*, dtype=*, keepdims=*)
 *     cpdef ndarray argmin(self, axis=*, out=*, dtype=*,             # <<<<<<<<<<<<<<
 *                          keepdims=*)
 *     cpdef ndarray clip(self, a_min=*, a_max=*, out=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmin {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
  PyObject *dtype;
  PyObject *keepdims;
};

/* "cupy/core/core.pxd":43
 *     cpdef ndarray argmin(self, axis=*, out=*, dtype=*,
 *                          keepdims=*)
 *     cpdef ndarray clip(self, a_min=*, a_max=*, out=*)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray trace(self, offset=*, axis1=*, axis2=*, dtype=*,
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip {
  int __pyx_n;
  PyObject *a_min;
  PyObject *a_max;
  PyObject *out;
};

/* "cupy/core/core.pxd":45
 *     cpdef ndarray clip(self, a_min=*, a_max=*, out=*)
 * 
 *     cpdef ndarray trace(self, offset=*, axis1=*, axis2=*, dtype=*,             # <<<<<<<<<<<<<<
 *                         out=*)
 *     cpdef ndarray sum(self, axis=*, dtype=*, out=*, keepdims=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_trace {
  int __pyx_n;
  PyObject *offset;
  PyObject *axis1;
  PyObject *axis2;
  PyObject *dtype;
  PyObject *out;
};

/* "cupy/core/core.pxd":47
 *     cpdef ndarray trace(self, offset=*, axis1=*, axis2=*, dtype=*,
 *                         out=*)
 *     cpdef ndarray sum(self, axis=*, dtype=*, out=*, keepdims=*)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray mean(self, axis=*, dtype=*, out=*, keepdims=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum {
  int __pyx_n;
  PyObject *axis;
  PyObject *dtype;
  PyObject *out;
  PyObject *keepdims;
};

/* "cupy/core/core.pxd":49
 *     cpdef ndarray sum(self, axis=*, dtype=*, out=*, keepdims=*)
 * 
 *     cpdef ndarray mean(self, axis=*, dtype=*, out=*, keepdims=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray var(self, axis=*, dtype=*, out=*, ddof=*,
 *                       keepdims=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_mean {
  int __pyx_n;
  PyObject *axis;
  PyObject *dtype;
  PyObject *out;
  PyObject *keepdims;
};

/* "cupy/core/core.pxd":50
 * 
 *     cpdef ndarray mean(self, axis=*, dtype=*, out=*, keepdims=*)
 *     cpdef ndarray var(self, axis=*, dtype=*, out=*, ddof=*,             # <<<<<<<<<<<<<<
 *                       keepdims=*)
 *     cpdef ndarray std(self, axis=*, dtype=*, out=*, ddof=*,
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_var {
  int __pyx_n;
  PyObject *axis;
  PyObject *dtype;
  PyObject *out;
  PyObject *ddof;
  PyObject *keepdims;
};

/* "cupy/core/core.pxd":52
 *     cpdef ndarray var(self, axis=*, dtype=*, out=*, ddof=*,
 *                       keepdims=*)
 *     cpdef ndarray std(self, axis=*, dtype=*, out=*, ddof=*,             # <<<<<<<<<<<<<<
 *                       keepdims=*)
 *     cpdef ndarray prod(self, axis=*, dtype=*, out=*, keepdims=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_std {
  int __pyx_n;
  PyObject *axis;
  PyObject *dtype;
  PyObject *out;
  PyObject *ddof;
  PyObject *keepdims;
};

/* "cupy/core/core.pxd":54
 *     cpdef ndarray std(self, axis=*, dtype=*, out=*, ddof=*,
 *                       keepdims=*)
 *     cpdef ndarray prod(self, axis=*, dtype=*, out=*, keepdims=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray all(self, axis=*, out=*, keepdims=*)
 *     cpdef ndarray any(self, axis=*, out=*, keepdims=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod {
  int __pyx_n;
  PyObject *axis;
  PyObject *dtype;
  PyObject *out;
  PyObject *keepdims;
};

/* "cupy/core/core.pxd":55
 *                       keepdims=*)
 *     cpdef ndarray prod(self, axis=*, dtype=*, out=*, keepdims=*)
 *     cpdef ndarray all(self, axis=*, out=*, keepdims=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray any(self, axis=*, out=*, keepdims=*)
 *     cpdef ndarray conj(self)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_all {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
  PyObject *keepdims;
};

/* "cupy/core/core.pxd":56
 *     cpdef ndarray prod(self, axis=*, dtype=*, out=*, keepdims=*)
 *     cpdef ndarray all(self, axis=*, out=*, keepdims=*)
 *     cpdef ndarray any(self, axis=*, out=*, keepdims=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray conj(self)
 *     cpdef get(self, stream=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
  PyObject *keepdims;
};

/* "cupy/core/core.pxd":58
 *     cpdef ndarray any(self, axis=*, out=*, keepdims=*)
 *     cpdef ndarray conj(self)
 *     cpdef get(self, stream=*)             # <<<<<<<<<<<<<<
 *     cpdef set(self, arr, stream=*)
 *     cpdef ndarray reduced_view(self, dtype=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_get {
  int __pyx_n;
  PyObject *stream;
};

/* "cupy/core/core.pxd":59
 *     cpdef ndarray conj(self)
 *     cpdef get(self, stream=*)
 *     cpdef set(self, arr, stream=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray reduced_view(self, dtype=*)
 *     cpdef _update_c_contiguity(self)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set {
  int __pyx_n;
  PyObject *stream;
};

/* "cupy/core/core.pxd":60
 *     cpdef get(self, stream=*)
 *     cpdef set(self, arr, stream=*)
 *     cpdef ndarray reduced_view(self, dtype=*)             # <<<<<<<<<<<<<<
 *     cpdef _update_c_contiguity(self)
 *     cpdef _update_f_contiguity(self)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_reduced_view {
  int __pyx_n;
  PyObject *dtype;
};

/* "cupy/core/core.pxd":64
 *     cpdef _update_f_contiguity(self)
 *     cpdef _update_contiguity(self)
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t]& shape,             # <<<<<<<<<<<<<<
 *                                  vector.vector[Py_ssize_t]& strides,
 *                                  bint update_c_contiguity=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides {
  int __pyx_n;
  int update_c_contiguity;
};

/* "cupy/core/core.pxd":78
 * 
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=*)             # <<<<<<<<<<<<<<
 */
struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray {
  int __pyx_n;
  PyObject *dtype;
};

/* "cupy/core/carray.pxi":11
 * 
 * 
 * cdef struct _CArray:             # <<<<<<<<<<<<<<
 *     void* data
 *     Py_ssize_t size
 */
struct __pyx_t_4cupy_4core_4core__CArray {
  void *data;
  Py_ssize_t size;
  Py_ssize_t shape_and_strides[(25 * 2)];
};

/* "cupy/core/carray.pxi":33
 * 
 * 
 * cdef struct _CIndexer:             # <<<<<<<<<<<<<<
 *     Py_ssize_t size
 *     Py_ssize_t shape_and_index[MAX_NDIM * 2]
 */
struct __pyx_t_4cupy_4core_4core__CIndexer {
  Py_ssize_t size;
  Py_ssize_t shape_and_index[(25 * 2)];
};

/* "cupy/core/carray.pxi":125
 * 
 * 
 * cpdef function.Module compile_with_cache(             # <<<<<<<<<<<<<<
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _cupy_header + source
 */
struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache {
  int __pyx_n;
  PyObject *options;
  PyObject *arch;
  PyObject *cachd_dir;
};

/* "cupy/core/elementwise.pxi":15
 * 
 * cpdef _get_simple_elementwise_kernel(
 *         params, operation, name, preamble,             # <<<<<<<<<<<<<<
 *         loop_prep='', after_loop='', options=()):
 *     module_code = string.Template('''
 */
struct __pyx_opt_args_4cupy_4core_4core__get_simple_elementwise_kernel {
  int __pyx_n;
  PyObject *loop_prep;
  PyObject *after_loop;
  PyObject *options;
};

/* "cupy/core/elementwise.pxi":398
 * 
 * 
 * cdef list _get_out_args_with_params(             # <<<<<<<<<<<<<<
 *         list out_args, tuple out_types, tuple out_shape, tuple out_params,
 *         bint is_size_specified=False):
 */
struct __pyx_opt_args_4cupy_4core_4core__get_out_args_with_params {
  int __pyx_n;
  int is_size_specified;
};

/* "cupy/core/elementwise.pxi":828
 * 
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                    default_casting=None):
 *     _ops = []
 */
struct __pyx_opt_args_4cupy_4core_4core_create_ufunc {
  int __pyx_n;
  PyObject *routine;
  PyObject *preamble;
  PyObject *doc;
  PyObject *default_casting;
};

/* "cupy/core/reduction.pxi":453
 * 
 * 
 * cpdef create_reduction_func(name, ops, routine=None, identity=None,             # <<<<<<<<<<<<<<
 *                             preamble=''):
 *     _ops = []
 */
struct __pyx_opt_args_4cupy_4core_4core_create_reduction_func {
  int __pyx_n;
  PyObject *routine;
  PyObject *identity;
  PyObject *preamble;
};

/* "cupy/core/core.pyx":2050
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, str order='K',             # <<<<<<<<<<<<<<
 *                     bint subok=False, Py_ssize_t ndmin=0):
 *     # TODO(beam2d): Support subok options
 */
struct __pyx_opt_args_4cupy_4core_4core_array {
  int __pyx_n;
  PyObject *dtype;
  int copy;
  PyObject *order;
  int subok;
  Py_ssize_t ndmin;
};

/* "cupy/core/core.pyx":2111
 * 
 * 
 * cpdef ndarray asfortranarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     cdef ndarray newarray
 *     cdef int m, n
 */
struct __pyx_opt_args_4cupy_4core_4core_asfortranarray {
  int __pyx_n;
  PyObject *dtype;
};

/* "cupy/core/core.pyx":2205
 * 
 * 
 * cpdef ndarray rollaxis(ndarray a, Py_ssize_t axis, Py_ssize_t start=0):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, ndim = a.ndim
 *     cdef vector.vector[Py_ssize_t] axes
 */
struct __pyx_opt_args_4cupy_4core_4core_rollaxis {
  int __pyx_n;
  Py_ssize_t start;
};

/* "cupy/core/core.pyx":2392
 * 
 * 
 * cpdef ndarray _repeat(ndarray a, repeats, axis=None):             # <<<<<<<<<<<<<<
 *     """Repeat arrays along an axis.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core__repeat {
  int __pyx_n;
  PyObject *axis;
};

/* "cupy/core/core.pyx":2643
 * 
 * 
 * cpdef Py_ssize_t size(ndarray a, axis=None) except *:             # <<<<<<<<<<<<<<
 *     """Returns the number of elements along a given axis.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_size {
  int __pyx_n;
  PyObject *axis;
};

/* "cupy/core/core.pyx":2671
 * # -----------------------------------------------------------------------------
 * 
 * cpdef _create_bit_op(name, op, no_bool, doc=''):             # <<<<<<<<<<<<<<
 *     types = () if no_bool else ('??->?',)
 *     return create_ufunc(
 */
struct __pyx_opt_args_4cupy_4core_4core__create_bit_op {
  int __pyx_n;
  PyObject *doc;
};

/* "cupy/core/core.pyx":3068
 * 
 * 
 * cpdef ndarray _take(ndarray a, indices, li=None, ri=None, ndarray out=None):             # <<<<<<<<<<<<<<
 *     # When li == ri, this function behaves similarly to np.take
 *     if a.ndim == 0:
 */
struct __pyx_opt_args_4cupy_4core_4core__take {
  int __pyx_n;
  PyObject *li;
  PyObject *ri;
  struct __pyx_obj_4cupy_4core_4core_ndarray *out;
};

/* "cupy/core/core.pyx":3128
 * 
 * 
 * cpdef _scatter_op_single(ndarray a, ndarray indices, v,             # <<<<<<<<<<<<<<
 *                          Py_ssize_t li=0, Py_ssize_t ri=0, op=''):
 *     # When op == 'update', this function behaves similarly to
 */
struct __pyx_opt_args_4cupy_4core_4core__scatter_op_single {
  int __pyx_n;
  Py_ssize_t li;
  Py_ssize_t ri;
  PyObject *op;
};

/* "cupy/core/core.pyx":3263
 * 
 * 
 * cpdef ndarray _diagonal(ndarray a, Py_ssize_t offset=0, Py_ssize_t axis1=0,             # <<<<<<<<<<<<<<
 *                         Py_ssize_t axis2=1):
 *     cdef Py_ssize_t ndim = a.ndim
 */
struct __pyx_opt_args_4cupy_4core_4core__diagonal {
  int __pyx_n;
  Py_ssize_t offset;
  Py_ssize_t axis1;
  Py_ssize_t axis2;
};

/* "cupy/core/core.pyx":3413
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray dot(ndarray a, ndarray b, ndarray out=None):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t a_ndim, b_ndim, a_axis, b_axis, n, m, k
 *     cdef bint input_a_is_vec, input_b_is_vec
 */
struct __pyx_opt_args_4cupy_4core_4core_dot {
  int __pyx_n;
  struct __pyx_obj_4cupy_4core_4core_ndarray *out;
};

/* "cupy/core/core.pyx":3520
 * 
 * 
 * cpdef ndarray matmul(ndarray a, ndarray b, ndarray out=None):             # <<<<<<<<<<<<<<
 *     """ Returns the matrix product of two arrays and is the implementation of
 *     the `@` operator introduced in Python 3.5 following PEP465.
 */
struct __pyx_opt_args_4cupy_4core_4core_matmul {
  int __pyx_n;
  struct __pyx_obj_4cupy_4core_4core_ndarray *out;
};

/* "cupy/core/core.pyx":3924
 * # -----------------------------------------------------------------------------
 * 
 * cpdef create_comparison(name, op, doc='', require_sortable_dtype=True):             # <<<<<<<<<<<<<<
 * 
 *     if require_sortable_dtype:
 */
struct __pyx_opt_args_4cupy_4core_4core_create_comparison {
  int __pyx_n;
  PyObject *doc;
  PyObject *require_sortable_dtype;
};

/* "cupy/core/core.pyx":4284
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                    keepdims=False):
 *     assert a.dtype.kind != 'c', 'Variance for complex numbers is not ' \
 */
struct __pyx_opt_args_4cupy_4core_4core__var {
  int __pyx_n;
  PyObject *axis;
  PyObject *dtype;
  PyObject *out;
  PyObject *ddof;
  PyObject *keepdims;
};

/* "cupy/core/core.pyx":4310
 * 
 * 
 * cpdef _std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False):             # <<<<<<<<<<<<<<
 *     ret = _var(a, axis=axis, dtype=dtype, ddof=ddof, keepdims=keepdims)
 *     return sqrt(ret, dtype=dtype, out=out)
 */
struct __pyx_opt_args_4cupy_4core_4core__std {
  int __pyx_n;
  PyObject *axis;
  PyObject *dtype;
  PyObject *out;
  PyObject *ddof;
  PyObject *keepdims;
};

/* "cupy/core/core.pyx":4485
 * 
 * 
 * cpdef ndarray scan(ndarray a, ndarray out=None):             # <<<<<<<<<<<<<<
 *     """Return the prefix sum(scan) of the elements.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_scan {
  int __pyx_n;
  struct __pyx_obj_4cupy_4core_4core_ndarray *out;
};

/* "device.pxd":7
 * cpdef str get_compute_capability()
 * 
 * cdef class Device:             # <<<<<<<<<<<<<<
 *     cdef:
 *         public int id
 */
struct __pyx_obj_4cupy_4cuda_6device_Device {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_6device_Device *__pyx_vtab;
  int id;
  PyObject *_device_stack;
};


/* "memory.pxd":7
 * 
 * 
 * cdef class Memory:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_Memory {
  PyObject_HEAD
  size_t ptr;
  Py_ssize_t size;
  struct __pyx_obj_4cupy_4cuda_6device_Device *device;
};


/* "memory.pxd":15
 * 
 * 
 * cdef class MemoryPointer:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *__pyx_vtab;
  size_t ptr;
  struct __pyx_obj_4cupy_4cuda_6device_Device *device;
  struct __pyx_obj_4cupy_4cuda_6memory_Memory *mem;
};


/* "memory.pxd":41
 * 
 * 
 * cdef class SingleDeviceMemoryPool:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_6memory_SingleDeviceMemoryPool *__pyx_vtab;
  PyObject *_allocator;
  PyObject *_in_use;
  PyObject *_free;
  PyObject *__weakref__;
  PyObject *_weakref;
  PyObject *_free_lock;
  PyObject *_in_use_lock;
  Py_ssize_t _allocation_unit_size;
  int _device_id;
  std::map<size_t,std::vector<int> >  _index;
};


/* "memory.pxd":85
 *                                       chunk, size_t stream_ptr) except *
 * 
 * cdef class MemoryPool:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPool *__pyx_vtab;
  PyObject *_pools;
};


/* "cupy/cuda/function.pxd":1
 * cdef class CPointer:             # <<<<<<<<<<<<<<
 *     cdef void* ptr
 * 
 */
struct __pyx_obj_4cupy_4cuda_8function_CPointer {
  PyObject_HEAD
  void *ptr;
};


/* "cupy/cuda/function.pxd":5
 * 
 * 
 * cdef class Function:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_8function_Function {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_8function_Function *__pyx_vtab;
  struct __pyx_obj_4cupy_4cuda_8function_Module *module;
  size_t ptr;
};


/* "cupy/cuda/function.pxd":15
 * 
 * 
 * cdef class Module:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_8function_Module {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *__pyx_vtab;
  size_t ptr;
};


/* "cupy/cuda/function.pxd":26
 * 
 * 
 * cdef class LinkState:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_8function_LinkState {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_8function_LinkState *__pyx_vtab;
  size_t ptr;
};


/* "pinned_memory.pxd":2
 * 
 * cdef class PinnedMemoryPointer:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *__pyx_vtab;
  PyObject *mem;
  size_t ptr;
  Py_ssize_t _shape[1];
  Py_ssize_t _strides[1];
};


/* "pinned_memory.pxd":22
 * 
 * 
 * cdef class PinnedMemoryPool:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPool {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_13pinned_memory_PinnedMemoryPool *__pyx_vtab;
  PyObject *_alloc;
  PyObject *_in_use;
  PyObject *_free;
  PyObject *__weakref__;
  PyObject *_weakref;
  PyObject *_lock;
  Py_ssize_t _allocation_unit_size;
};


/* "runtime.pxd":5
 * ###############################################################################
 * 
 * cdef class PointerAttributes:             # <<<<<<<<<<<<<<
 *     cdef:
 *         public int device
 */
struct __pyx_obj_4cupy_4cuda_7runtime_PointerAttributes {
  PyObject_HEAD
  int device;
  size_t devicePointer;
  size_t hostPointer;
  int isManaged;
  int memoryType;
};


/* "cupy/core/core.pxd":7
 * 
 * 
 * cdef class ndarray:             # <<<<<<<<<<<<<<
 *     cdef:
 *         object __weakref__
 */
struct __pyx_obj_4cupy_4core_4core_ndarray {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *__pyx_vtab;
  PyObject *__weakref__;
  Py_ssize_t size;
  std::vector<Py_ssize_t>  _shape;
  std::vector<Py_ssize_t>  _strides;
  int _c_contiguous;
  int _f_contiguous;
  PyObject *dtype;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *data;
  struct __pyx_obj_4cupy_4core_4core_ndarray *base;
};


/* "cupy/core/core.pxd":70
 * 
 * 
 * cdef class Indexer:             # <<<<<<<<<<<<<<
 *     cdef:
 *         readonly Py_ssize_t size
 */
struct __pyx_obj_4cupy_4core_4core_Indexer {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4core_4core_Indexer *__pyx_vtab;
  Py_ssize_t size;
  PyObject *shape;
};


/* "cupy/core/carray.pxi":17
 * 
 * 
 * cdef class CArray(CPointer):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4core_4core_CArray {
  struct __pyx_obj_4cupy_4cuda_8function_CPointer __pyx_base;
  struct __pyx_t_4cupy_4core_4core__CArray val;
};


/* "cupy/core/carray.pxi":38
 * 
 * 
 * cdef class CIndexer(CPointer):             # <<<<<<<<<<<<<<
 *     cdef:
 *         _CIndexer val
 */
struct __pyx_obj_4cupy_4core_4core_CIndexer {
  struct __pyx_obj_4cupy_4cuda_8function_CPointer __pyx_base;
  struct __pyx_t_4cupy_4core_4core__CIndexer val;
};


/* "cupy/core/elementwise.pxi":249
 * 
 * 
 * cdef class ParameterInfo:             # <<<<<<<<<<<<<<
 *     cdef:
 *         readonly str name
 */
struct __pyx_obj_4cupy_4core_4core_ParameterInfo {
  PyObject_HEAD
  PyObject *name;
  PyObject *dtype;
  PyObject *ctype;
  int raw;
  int is_const;
};


/* "cupy/core/elementwise.pxi":442
 * 
 * 
 * cdef class ElementwiseKernel:             # <<<<<<<<<<<<<<
 * 
 *     """User-defined elementwise kernel.
 */
struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel {
  PyObject_HEAD
  PyObject *in_params;
  PyObject *out_params;
  Py_ssize_t nin;
  Py_ssize_t nout;
  Py_ssize_t nargs;
  PyObject *params;
  PyObject *operation;
  PyObject *name;
  int reduce_dims;
  PyObject *preamble;
  PyObject *kwargs;
};


/* "cupy/core/core.pyx":2277
 * 
 * 
 * cdef class broadcast:             # <<<<<<<<<<<<<<
 *     """Object that performs broadcasting.
 * 
 */
struct __pyx_obj_4cupy_4core_4core_broadcast {
  PyObject_HEAD
  PyObject *values;
  PyObject *shape;
  Py_ssize_t size;
  Py_ssize_t nd;
};


/* "cupy/core/elementwise.pxi":420
 * 
 * @util.memoize(for_each_device=True)
 * def _get_elementwise_kernel(args_info, types, params, operation, name,             # <<<<<<<<<<<<<<
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)
 */
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel {
  PyObject_HEAD
  PyObject *__pyx_v_types;
};


/* "cupy/core/elementwise.pxi":424
 *     kernel_params = _get_kernel_params(params, args_info)
 *     types_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k) for k, v in types)             # <<<<<<<<<<<<<<
 *     preamble = types_preamble + '\n' + preamble
 * 
 */
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr {
  PyObject_HEAD
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *__pyx_outer_scope;
  PyObject *__pyx_v_k;
  PyObject *__pyx_v_v;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "cupy/core/elementwise.pxi":708
 *     """
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                  default_casting=None):
 *         self.name = name
 */
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ {
  PyObject_HEAD
  PyObject *__pyx_v_nin;
  PyObject *__pyx_v_nout;
};


/* "cupy/core/elementwise.pxi":722
 *             self._default_casting = default_casting
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)             # <<<<<<<<<<<<<<
 *             for i in range(nin))
 *         _out_params = tuple(
 */
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr {
  PyObject_HEAD
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *__pyx_outer_scope;
  PyObject *__pyx_v_i;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "cupy/core/elementwise.pxi":725
 *             for i in range(nin))
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)             # <<<<<<<<<<<<<<
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 */
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr {
  PyObject_HEAD
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *__pyx_outer_scope;
  PyObject *__pyx_v_i;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "cupy/core/reduction.pxi":273
 * 
 * @util.memoize(for_each_device=True)
 * def _get_reduction_kernel(             # <<<<<<<<<<<<<<
 *         params, args_info, types,
 *         name, block_size, reduce_type, identity, map_expr, reduce_expr,
 */
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel {
  PyObject_HEAD
  PyObject *__pyx_v_types;
};


/* "cupy/core/reduction.pxi":281
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)             # <<<<<<<<<<<<<<
 *         for k, v in types)
 *     input_expr = '\n'.join(
 */
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr {
  PyObject_HEAD
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *__pyx_outer_scope;
  PyObject *__pyx_v_k;
  PyObject *__pyx_v_v;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "View.MemoryView":104
 * 
 * @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":278
 * 
 * @cname('__pyx_MemviewEnum')
 * cdef class Enum(object):             # <<<<<<<<<<<<<<
 *     cdef object name
 *     def __init__(self, name):
 */
struct __pyx_MemviewEnum_obj {
  PyObject_HEAD
  PyObject *name;
};


/* "View.MemoryView":329
 * 
 * @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":960
 * 
 * @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 *);
};



/* "device.pxd":7
 * cpdef str get_compute_capability()
 * 
 * cdef class Device:             # <<<<<<<<<<<<<<
 *     cdef:
 *         public int id
 */

struct __pyx_vtabstruct_4cupy_4cuda_6device_Device {
  PyObject *(*use)(struct __pyx_obj_4cupy_4cuda_6device_Device *, int __pyx_skip_dispatch);
  PyObject *(*synchronize)(struct __pyx_obj_4cupy_4cuda_6device_Device *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4cupy_4cuda_6device_Device *__pyx_vtabptr_4cupy_4cuda_6device_Device;


/* "memory.pxd":15
 * 
 * 
 * cdef class MemoryPointer:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer {
  PyObject *(*copy_from_device)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, Py_ssize_t, int __pyx_skip_dispatch);
  PyObject *(*copy_from_device_async)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, size_t, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_device_async *__pyx_optional_args);
  PyObject *(*copy_from_host)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, PyObject *, size_t, int __pyx_skip_dispatch);
  PyObject *(*copy_from_host_async)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, PyObject *, size_t, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_host_async *__pyx_optional_args);
  PyObject *(*copy_from)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, PyObject *, size_t, int __pyx_skip_dispatch);
  PyObject *(*copy_from_async)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, PyObject *, size_t, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_async *__pyx_optional_args);
  PyObject *(*copy_to_host)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, PyObject *, size_t, int __pyx_skip_dispatch);
  PyObject *(*copy_to_host_async)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, PyObject *, size_t, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_to_host_async *__pyx_optional_args);
  PyObject *(*memset)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, int, size_t, int __pyx_skip_dispatch);
  PyObject *(*memset_async)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, int, size_t, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_memset_async *__pyx_optional_args);
};
static struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *__pyx_vtabptr_4cupy_4cuda_6memory_MemoryPointer;


/* "memory.pxd":41
 * 
 * 
 * cdef class SingleDeviceMemoryPool:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_4cupy_4cuda_6memory_SingleDeviceMemoryPool {
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *(*_alloc)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, Py_ssize_t, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *(*malloc)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, Py_ssize_t, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *(*_malloc)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, Py_ssize_t, int __pyx_skip_dispatch);
  PyObject *(*free)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, size_t, Py_ssize_t, int __pyx_skip_dispatch);
  PyObject *(*free_all_blocks)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4cuda_6memory_22SingleDeviceMemoryPool_free_all_blocks *__pyx_optional_args);
  PyObject *(*free_all_free)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, int __pyx_skip_dispatch);
  PyObject *(*n_free_blocks)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, int __pyx_skip_dispatch);
  PyObject *(*used_bytes)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, int __pyx_skip_dispatch);
  PyObject *(*free_bytes)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, int __pyx_skip_dispatch);
  PyObject *(*total_bytes)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, int __pyx_skip_dispatch);
  Py_ssize_t (*_round_size)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, Py_ssize_t, int __pyx_skip_dispatch);
  int (*_bin_index_from_size)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, Py_ssize_t, int __pyx_skip_dispatch);
  PyObject *(*_arena)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, size_t, int __pyx_skip_dispatch);
  std::vector<int>  *(*_arena_index)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, size_t);
  PyObject *(*_append_to_free_list)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, Py_ssize_t, PyObject *, size_t, int __pyx_skip_dispatch);
  int (*_remove_from_free_list)(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool *, Py_ssize_t, PyObject *, size_t, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4cupy_4cuda_6memory_SingleDeviceMemoryPool *__pyx_vtabptr_4cupy_4cuda_6memory_SingleDeviceMemoryPool;


/* "memory.pxd":85
 *                                       chunk, size_t stream_ptr) except *
 * 
 * cdef class MemoryPool:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPool {
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *(*malloc)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool *, Py_ssize_t, int __pyx_skip_dispatch);
  PyObject *(*free_all_blocks)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4cuda_6memory_10MemoryPool_free_all_blocks *__pyx_optional_args);
  PyObject *(*free_all_free)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool *, int __pyx_skip_dispatch);
  PyObject *(*n_free_blocks)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool *, int __pyx_skip_dispatch);
  PyObject *(*used_bytes)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool *, int __pyx_skip_dispatch);
  PyObject *(*free_bytes)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool *, int __pyx_skip_dispatch);
  PyObject *(*total_bytes)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPool *__pyx_vtabptr_4cupy_4cuda_6memory_MemoryPool;


/* "cupy/cuda/function.pxd":5
 * 
 * 
 * cdef class Function:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_4cupy_4cuda_8function_Function {
  PyObject *(*linear_launch)(struct __pyx_obj_4cupy_4cuda_8function_Function *, size_t, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4cuda_8function_8Function_linear_launch *__pyx_optional_args);
};
static struct __pyx_vtabstruct_4cupy_4cuda_8function_Function *__pyx_vtabptr_4cupy_4cuda_8function_Function;


/* "cupy/cuda/function.pxd":15
 * 
 * 
 * cdef class Module:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_4cupy_4cuda_8function_Module {
  PyObject *(*load_file)(struct __pyx_obj_4cupy_4cuda_8function_Module *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*load)(struct __pyx_obj_4cupy_4cuda_8function_Module *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*get_global_var)(struct __pyx_obj_4cupy_4cuda_8function_Module *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*get_function)(struct __pyx_obj_4cupy_4cuda_8function_Module *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *__pyx_vtabptr_4cupy_4cuda_8function_Module;


/* "cupy/cuda/function.pxd":26
 * 
 * 
 * cdef class LinkState:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_4cupy_4cuda_8function_LinkState {
  PyObject *(*add_ptr_data)(struct __pyx_obj_4cupy_4cuda_8function_LinkState *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*complete)(struct __pyx_obj_4cupy_4cuda_8function_LinkState *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4cupy_4cuda_8function_LinkState *__pyx_vtabptr_4cupy_4cuda_8function_LinkState;


/* "pinned_memory.pxd":2
 * 
 * cdef class PinnedMemoryPointer:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer {
  Py_ssize_t (*size)(struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *__pyx_vtabptr_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer;


/* "pinned_memory.pxd":22
 * 
 * 
 * cdef class PinnedMemoryPool:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_4cupy_4cuda_13pinned_memory_PinnedMemoryPool {
  struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *(*malloc)(struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPool *, Py_ssize_t, int __pyx_skip_dispatch);
  PyObject *(*free)(struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPool *, size_t, Py_ssize_t, int __pyx_skip_dispatch);
  PyObject *(*free_all_blocks)(struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPool *, int __pyx_skip_dispatch);
  PyObject *(*n_free_blocks)(struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPool *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4cupy_4cuda_13pinned_memory_PinnedMemoryPool *__pyx_vtabptr_4cupy_4cuda_13pinned_memory_PinnedMemoryPool;


/* "cupy/core/core.pyx":71
 * 
 * 
 * cdef class ndarray:             # <<<<<<<<<<<<<<
 * 
 *     """Multi-dimensional array on a CUDA device.
 */

struct __pyx_vtabstruct_4cupy_4core_4core_ndarray {
  PyObject *(*tolist)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  PyObject *(*tofile)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tofile *__pyx_optional_args);
  PyObject *(*dump)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*dumps)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*astype)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*copy)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*view)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view *__pyx_optional_args);
  PyObject *(*fill)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*_reshape)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t> , int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*_transpose)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t> , int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*swapaxes)(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, Py_ssize_t, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*flatten)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*ravel)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*squeeze)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_squeeze *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*take)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_take *__pyx_optional_args);
  PyObject *(*repeat)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat *__pyx_optional_args);
  PyObject *(*choose)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_choose *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*diagonal)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_diagonal *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*max)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_max *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*argmax)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmax *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*min)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_min *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*argmin)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmin *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*clip)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*trace)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_trace *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*sum)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*mean)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_mean *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*var)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_var *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*std)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_std *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*prod)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*all)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_all *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*any)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*conj)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  PyObject *(*get)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_get *__pyx_optional_args);
  PyObject *(*set)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*reduced_view)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_reduced_view *__pyx_optional_args);
  PyObject *(*_update_c_contiguity)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  PyObject *(*_update_f_contiguity)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  PyObject *(*_update_contiguity)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  PyObject *(*_set_shape_and_strides)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  &, std::vector<Py_ssize_t>  &, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides *__pyx_optional_args);
  struct __pyx_obj_4cupy_4cuda_8function_CPointer *(*get_pointer)(struct __pyx_obj_4cupy_4core_4core_ndarray *);
};
static struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *__pyx_vtabptr_4cupy_4core_4core_ndarray;


/* "cupy/core/carray.pxi":50
 * 
 * 
 * cdef class Indexer:             # <<<<<<<<<<<<<<
 *     def __init__(self, tuple shape):
 *         cdef Py_ssize_t size = 1
 */

struct __pyx_vtabstruct_4cupy_4core_4core_Indexer {
  struct __pyx_obj_4cupy_4cuda_8function_CPointer *(*get_pointer)(struct __pyx_obj_4cupy_4core_4core_Indexer *);
};
static struct __pyx_vtabstruct_4cupy_4core_4core_Indexer *__pyx_vtabptr_4cupy_4core_4core_Indexer;


/* "View.MemoryView":104
 * 
 * @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":329
 * 
 * @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":960
 * 
 * @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)

/* 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

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* 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

/* 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

/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);

/* 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);

/* 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);

/* GetModuleGlobalName.proto */
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);

/* 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

/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* UnicodeAsUCS4.proto */
static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject*);

/* object_ord.proto */
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyObject_Ord(c)\
    (likely(PyUnicode_Check(c)) ? (long)__Pyx_PyUnicode_AsPy_UCS4(c) : __Pyx__PyObject_Ord(c))
#else
#define __Pyx_PyObject_Ord(c) __Pyx__PyObject_Ord(c)
#endif
static long __Pyx__PyObject_Ord(PyObject* c);

/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

/* 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, int nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#endif

/* 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);

/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* 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);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif

/* py_abs.proto */
#if CYTHON_USE_PYLONG_INTERNALS
static PyObject *__Pyx_PyLong_AbsNeg(PyObject *num);
#define __Pyx_PyNumber_Absolute(x)\
    ((likely(PyLong_CheckExact(x))) ?\
         (likely(Py_SIZE(x) >= 0) ? (Py_INCREF(x), (x)) : __Pyx_PyLong_AbsNeg(x)) :\
         PyNumber_Absolute(x))
#else
#define __Pyx_PyNumber_Absolute(x)  PyNumber_Absolute(x)
#endif

/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

/* IterFinish.proto */
static CYTHON_INLINE int __Pyx_IterFinish(void);

/* UnpackItemEndCheck.proto */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

/* IncludeStringH.proto */
#include <string.h>

/* 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

/* PyObjectLookupSpecial.proto */
#if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) {
    PyObject *res;
    PyTypeObject *tp = Py_TYPE(obj);
#if PY_MAJOR_VERSION < 3
    if (unlikely(PyInstance_Check(obj)))
        return __Pyx_PyObject_GetAttrStr(obj, attr_name);
#endif
    res = _PyType_Lookup(tp, attr_name);
    if (likely(res)) {
        descrgetfunc f = Py_TYPE(res)->tp_descr_get;
        if (!f) {
            Py_INCREF(res);
        } else {
            res = f(res, obj, (PyObject *)tp);
        }
    } else {
        PyErr_SetObject(PyExc_AttributeError, attr_name);
    }
    return res;
}
#else
#define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
#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

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_EqObjC(op1, op2, intval, inplace)\
    PyObject_RichCompare(op1, op2, Py_EQ)
    #endif

/* 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);

/* SetItemInt.proto */
#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
               __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
                                               int is_list, int wraparound, int boundscheck);

/* KeywordStringCheck.proto */
static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);

/* None.proto */
static CYTHON_INLINE Py_ssize_t __Pyx_mod_Py_ssize_t(Py_ssize_t, Py_ssize_t);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_SubtractObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
#endif

/* 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

/* RaiseNoneIterError.proto */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

/* SliceObject.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_FloorDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_FloorDivideObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceFloorDivide(op1, op2) : PyNumber_FloorDivide(op1, op2))
#endif

/* UnpackUnboundCMethod.proto */
typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;

/* CallUnboundCMethod1.proto */
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#else
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg)  __Pyx__CallUnboundCMethod1(cfunc, self, arg)
#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);

/* None.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)))

/* 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);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

/* StringJoin.proto */
#if PY_MAJOR_VERSION < 3
#define __Pyx_PyString_Join __Pyx_PyBytes_Join
#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
#else
#define __Pyx_PyString_Join PyUnicode_Join
#define __Pyx_PyBaseString_Join PyUnicode_Join
#endif
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION < 3
    #define __Pyx_PyBytes_Join _PyString_Join
    #else
    #define __Pyx_PyBytes_Join _PyBytes_Join
    #endif
#else
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values);
#endif

/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
#define __Pyx_PyObject_Dict_GetItem(obj, name)\
    (likely(PyDict_CheckExact(obj)) ?\
     __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
#endif

/* PyDictContains.proto */
static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
    int result = PyDict_Contains(dict, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* pyfrozenset_new.proto */
static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it);

/* PySetContains.proto */
static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq);

/* CallUnboundCMethod0.proto */
static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_CallUnboundCMethod0(cfunc, self)\
    (likely((cfunc)->func) ?\
        (likely((cfunc)->flag == METH_NOARGS) ?  (*((cfunc)->func))(self, NULL) :\
         (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\
            (PY_VERSION_HEX >= 0x030700A0 ?\
                (*(__Pyx_PyCFunctionFast)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\
                (*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\
          (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\
            (*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\
            (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ?  ((*(PyCFunctionWithKeywords)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
               ((cfunc)->flag == METH_VARARGS ?  (*((cfunc)->func))(self, __pyx_empty_tuple) :\
               __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\
        __Pyx__CallUnboundCMethod0(cfunc, self))
#else
#define __Pyx_CallUnboundCMethod0(cfunc, self)  __Pyx__CallUnboundCMethod0(cfunc, self)
#endif

/* SliceTupleAndList.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
#else
#define __Pyx_PyList_GetSlice(seq, start, stop)   PySequence_GetSlice(seq, start, stop)
#define __Pyx_PyTuple_GetSlice(seq, start, stop)  PySequence_GetSlice(seq, start, stop)
#endif

/* py_dict_items.proto */
static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d);

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

/* 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));
}

/* py_dict_pop.proto */
static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value);

/* CallUnboundCMethod2.proto */
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
#else
#define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2)  __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
#endif

/* PyObjectCallMethod1.proto */
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg);

/* append.proto */
static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);

/* dict_getitem_default.proto */
static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);

/* PyObjectSetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

/* BufferIndexError.proto */
static void __Pyx_RaiseBufferIndexError(int axis);

/* 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);

/* DelItemInt.proto */
#define __Pyx_DelItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_DelItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
               __Pyx_DelItem_Generic(o, to_py_func(i))))
static int __Pyx_DelItem_Generic(PyObject *o, PyObject *j);
static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i,
                                               int is_list, int wraparound);

/* WriteUnraisableException.proto */
static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

/* 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
}

/* PyFloatBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyFloat_TrueDivideCObj(PyObject *op1, PyObject *op2, double floatval, int inplace);
#else
#define __Pyx_PyFloat_TrueDivideCObj(op1, op2, floatval, inplace)\
    (inplace ? PyNumber_InPlaceTrueDivide(op1, op2) : PyNumber_TrueDivide(op1, op2))
#endif

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* HasAttr.proto */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);

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*/
/* 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));

/* 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

/* 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*/
/* None.proto */
static CYTHON_INLINE long __Pyx_div_long(long, long);

/* CallNextTpDealloc.proto */
static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc);

/* 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);

/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);

/* GetVTable.proto */
static void* __Pyx_GetVtable(PyObject *dict);

/* CalculateMetaclass.proto */
static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);

/* FetchCommonType.proto */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

/* CythonFunction.proto */
#define __Pyx_CyFunction_USED 1
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CyFunction_GetClosure(f)\
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f)\
    (((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f)\
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
    PyCFunctionObject func;
#if PY_VERSION_HEX < 0x030500A0
    PyObject *func_weakreflist;
#endif
    PyObject *func_dict;
    PyObject *func_name;
    PyObject *func_qualname;
    PyObject *func_doc;
    PyObject *func_globals;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj;
    void *defaults;
    int defaults_pyobjects;
    int flags;
    PyObject *defaults_tuple;
    PyObject *defaults_kwdict;
    PyObject *(*defaults_getter)(PyObject *);
    PyObject *func_annotations;
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
    __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *self,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
                                                         size_t size,
                                                         int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
                                                             PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
                                                              PyObject *dict);
static int __pyx_CyFunction_init(void);

/* SetNameInClass.proto */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
#elif CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
#else
#define __Pyx_SetNameInClass(ns, name, value)  PyObject_SetItem(ns, name, value)
#endif

/* Py3ClassCreate.proto */
static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
                                           PyObject *mkw, PyObject *modname, PyObject *doc);
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
                                      PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);

/* 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);

/* None.proto */
#include <new>

#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);

/* CppExceptionConversion.proto */
#ifndef __Pyx_CppExn2PyErr
#include <new>
#include <typeinfo>
#include <stdexcept>
#include <ios>
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

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

/* RealImag.proto */
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #define __Pyx_CREAL(z) ((z).real())
    #define __Pyx_CIMAG(z) ((z).imag())
  #else
    #define __Pyx_CREAL(z) (__real__(z))
    #define __Pyx_CIMAG(z) (__imag__(z))
  #endif
#else
    #define __Pyx_CREAL(z) ((z).real)
    #define __Pyx_CIMAG(z) ((z).imag)
#endif
#if defined(__cplusplus) && CYTHON_CCOMPLEX\
        && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
    #define __Pyx_SET_CREAL(z,x) ((z).real(x))
    #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
    #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
    #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif

/* Arithmetic.proto */
#if CYTHON_CCOMPLEX
    #define __Pyx_c_eq_double(a, b)   ((a)==(b))
    #define __Pyx_c_sum_double(a, b)  ((a)+(b))
    #define __Pyx_c_diff_double(a, b) ((a)-(b))
    #define __Pyx_c_prod_double(a, b) ((a)*(b))
    #define __Pyx_c_quot_double(a, b) ((a)/(b))
    #define __Pyx_c_neg_double(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
    #define __Pyx_c_conj_double(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_abs_double(z)     (::std::abs(z))
        #define __Pyx_c_pow_double(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zero_double(z) ((z)==0)
    #define __Pyx_c_conj_double(z)    (conj(z))
    #if 1
        #define __Pyx_c_abs_double(z)     (cabs(z))
        #define __Pyx_c_pow_double(a, b)  (cpow(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
    static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
    #endif
#endif

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_PY_LONG_LONG(PY_LONG_LONG value);

/* MemviewDtypeToObject.proto */
static CYTHON_INLINE PyObject *__pyx_memview_get_Py_ssize_t(const char *itemp);
static CYTHON_INLINE int __pyx_memview_set_Py_ssize_t(const char *itemp, PyObject *obj);

/* Arithmetic.proto */
#if CYTHON_CCOMPLEX
    #define __Pyx_c_eq_float(a, b)   ((a)==(b))
    #define __Pyx_c_sum_float(a, b)  ((a)+(b))
    #define __Pyx_c_diff_float(a, b) ((a)-(b))
    #define __Pyx_c_prod_float(a, b) ((a)*(b))
    #define __Pyx_c_quot_float(a, b) ((a)/(b))
    #define __Pyx_c_neg_float(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
    #define __Pyx_c_conj_float(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_abs_float(z)     (::std::abs(z))
        #define __Pyx_c_pow_float(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zero_float(z) ((z)==0)
    #define __Pyx_c_conj_float(z)    (conjf(z))
    #if 1
        #define __Pyx_c_abs_float(z)     (cabsf(z))
        #define __Pyx_c_pow_float(a, b)  (cpowf(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
    static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
    #if 1
        static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
    #endif
#endif

/* 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);

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_As_PY_LONG_LONG(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);

/* CoroutineBase.proto */
typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *);
typedef struct {
    PyObject_HEAD
    __pyx_coroutine_body_t body;
    PyObject *closure;
    PyObject *exc_type;
    PyObject *exc_value;
    PyObject *exc_traceback;
    PyObject *gi_weakreflist;
    PyObject *classobj;
    PyObject *yieldfrom;
    PyObject *gi_name;
    PyObject *gi_qualname;
    PyObject *gi_modulename;
    PyObject *gi_code;
    int resume_label;
    char is_running;
} __pyx_CoroutineObject;
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
    PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
    PyObject *name, PyObject *qualname, PyObject *module_name);
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name);
static int __Pyx_Coroutine_clear(PyObject *self);
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
static PyObject *__Pyx_Coroutine_Close(PyObject *self);
static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
#define __Pyx_Coroutine_SwapException(self) {\
    __Pyx_ExceptionSwap(&(self)->exc_type, &(self)->exc_value, &(self)->exc_traceback);\
    __Pyx_Coroutine_ResetFrameBackpointer(self);\
    }
#define __Pyx_Coroutine_ResetAndClearException(self) {\
    __Pyx_ExceptionReset((self)->exc_type, (self)->exc_value, (self)->exc_traceback);\
    (self)->exc_type = (self)->exc_value = (self)->exc_traceback = NULL;\
    }
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
#endif
static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self);

/* PatchModuleWithCoroutine.proto */
static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);

/* PatchGeneratorABC.proto */
static int __Pyx_patch_abc(void);

/* Generator.proto */
#define __Pyx_Generator_USED
static PyTypeObject *__pyx_GeneratorType = 0;
#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
#define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
    __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
static PyObject *__Pyx_Generator_Next(PyObject *self);
static int __pyx_Generator_init(void);

/* IsLittleEndian.proto */
static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);

/* BufferFormatCheck.proto */
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
                              __Pyx_BufFmt_StackElem* stack,
                              __Pyx_TypeInfo* type);

/* TypeInfoCompare.proto */
static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b);

/* MemviewSliceValidateAndInit.proto */
static int __Pyx_ValidateAndInit_memviewslice(
                int *axes_specs,
                int c_or_f_flag,
                int buf_flags,
                int ndim,
                __Pyx_TypeInfo *dtype,
                __Pyx_BufFmt_StackElem stack[],
                __Pyx_memviewslice *memviewslice,
                PyObject *original_obj);

/* ObjectToMemviewSlice.proto */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_Py_ssize_t(PyObject *, int writable_flag);

/* ObjectToMemviewSlice.proto */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_Py_ssize_t(PyObject *, int writable_flag);

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* FunctionExport.proto */
static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);

/* PyIdentifierFromString.proto */
#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

/* ModuleImport.proto */
static PyObject *__Pyx_ImportModule(const char *name);

/* TypeImport.proto */
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);

/* FunctionImport.proto */
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_tolist(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_tofile(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_fid, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tofile *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_dump(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_file, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_dumps(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_astype(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_copy(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_fill(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray__reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_shape, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray__transpose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_axes, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_swapaxes(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, Py_ssize_t __pyx_v_axis1, Py_ssize_t __pyx_v_axis2, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_flatten(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_ravel(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_squeeze(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_squeeze *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_take(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_indices, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_take *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_repeat(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_repeats, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_choose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_choices, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_choose *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_diagonal(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_diagonal *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_max(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_max *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_argmax(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmax *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_min(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_min *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_argmin(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmin *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_clip(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_trace(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_trace *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_sum(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_mean(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_mean *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_var(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_var *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_std(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_std *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_prod(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_all(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_all *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_any(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_conj(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_get(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_get *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_set(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_arr, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_reduced_view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_reduced_view *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__update_c_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__update_f_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__update_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__set_shape_and_strides(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  &__pyx_v_shape, std::vector<Py_ssize_t>  &__pyx_v_strides, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4cuda_8function_CPointer *__pyx_f_4cupy_4core_4core_7ndarray_get_pointer(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto*/
static struct __pyx_obj_4cupy_4cuda_8function_CPointer *__pyx_f_4cupy_4core_4core_7Indexer_get_pointer(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self); /* proto*/
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 'libcpp' */

/* Module declarations from 'libcpp.vector' */

/* Module declarations from 'cupy.cuda' */

/* Module declarations from 'libcpp.utility' */

/* Module declarations from 'libcpp.map' */

/* Module declarations from 'cupy.cuda.device' */
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6device_Device = 0;
static int (*__pyx_f_4cupy_4cuda_6device_get_device_id)(int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_6device_get_cublas_handle)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6device_get_compute_capability)(int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.cuda.memory' */
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_Memory = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_MemoryPointer = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_SingleDeviceMemoryPool = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_MemoryPool = 0;
static struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *(*__pyx_f_4cupy_4cuda_6memory_alloc)(Py_ssize_t, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.cuda.function' */
static PyTypeObject *__pyx_ptype_4cupy_4cuda_8function_CPointer = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_8function_Function = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_8function_Module = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_8function_LinkState = 0;

/* Module declarations from 'cpython.version' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;

/* Module declarations from 'libc.string' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from 'cpython.object' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'cpython.exc' */

/* Module declarations from 'cpython.module' */

/* Module declarations from 'cpython.mem' */

/* Module declarations from 'cpython.tuple' */

/* Module declarations from 'cpython.list' */

/* Module declarations from 'cpython.sequence' */

/* Module declarations from 'cpython.mapping' */

/* Module declarations from 'cpython.iterator' */

/* Module declarations from 'cpython.number' */

/* Module declarations from 'cpython.int' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.bool' */
static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;

/* Module declarations from 'cpython.long' */

/* Module declarations from 'cpython.float' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.complex' */
static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;

/* Module declarations from 'cpython.string' */

/* Module declarations from 'cpython.unicode' */

/* Module declarations from 'cpython.dict' */

/* Module declarations from 'cpython.instance' */

/* Module declarations from 'cpython.function' */

/* Module declarations from 'cpython.method' */

/* Module declarations from 'cpython.weakref' */

/* Module declarations from 'cpython.getargs' */

/* Module declarations from 'cpython.pythread' */

/* Module declarations from 'cpython.pystate' */

/* Module declarations from 'cpython.cobject' */

/* Module declarations from 'cpython.oldbuffer' */

/* Module declarations from 'cpython.set' */

/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'cpython.bytes' */

/* Module declarations from 'cpython.pycapsule' */

/* Module declarations from 'cpython' */

/* Module declarations from 'cython.view' */

/* Module declarations from 'cython' */

/* Module declarations from 'cupy.core._dtype' */
static PyObject *(*__pyx_f_4cupy_4core_6_dtype_get_dtype)(PyObject *, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.core' */

/* Module declarations from 'cupy.core.internal' */
static Py_ssize_t (*__pyx_f_4cupy_4core_8internal_prod)(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_8internal_prod *__pyx_optional_args); /*proto*/
static Py_ssize_t (*__pyx_f_4cupy_4core_8internal_prod_ssize_t)(std::vector<Py_ssize_t>  &, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_8internal_prod_ssize_t *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_4cupy_4core_8internal_get_size)(PyObject *, int __pyx_skip_dispatch); /*proto*/
static int (*__pyx_f_4cupy_4core_8internal_vector_equal)(std::vector<Py_ssize_t>  &, std::vector<Py_ssize_t>  &, int __pyx_skip_dispatch); /*proto*/
static void (*__pyx_f_4cupy_4core_8internal_get_reduced_dims)(std::vector<Py_ssize_t>  &, std::vector<Py_ssize_t>  &, Py_ssize_t, std::vector<Py_ssize_t>  &, std::vector<Py_ssize_t>  &); /*proto*/
static std::vector<Py_ssize_t>  (*__pyx_f_4cupy_4core_8internal_get_contiguous_strides)(std::vector<Py_ssize_t>  &, Py_ssize_t, int, int __pyx_skip_dispatch); /*proto*/
static int (*__pyx_f_4cupy_4core_8internal_get_c_contiguity)(std::vector<Py_ssize_t>  &, std::vector<Py_ssize_t>  &, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/
static std::vector<Py_ssize_t>  (*__pyx_f_4cupy_4core_8internal_infer_unknown_dimension)(std::vector<Py_ssize_t>  &, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4core_8internal_complete_slice)(PyObject *, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4core_8internal_complete_slice_list)(PyObject *, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.cuda.cublas' */
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_setMathMode)(size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_sgemm)(size_t, int, int, int, int, int, float, size_t, int, size_t, int, float, size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_dgemm)(size_t, int, int, int, int, int, double, size_t, int, size_t, int, double, size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_cgemm)(size_t, int, int, int, int, int, __pyx_t_float_complex, size_t, int, size_t, int, __pyx_t_float_complex, size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_zgemm)(size_t, int, int, int, int, int, __pyx_t_double_complex, size_t, int, size_t, int, __pyx_t_double_complex, size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_sgemmEx)(size_t, int, int, int, int, int, float, size_t, int, int, size_t, int, int, float, size_t, int, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_gemmEx)(size_t, int, int, int, int, int, size_t, size_t, int, int, size_t, int, int, size_t, size_t, int, int, int, int, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.cuda.pinned_memory' */
static PyTypeObject *__pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPool = 0;
static PyObject *(*__pyx_f_4cupy_4cuda_13pinned_memory__add_to_watch_list)(PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *(*__pyx_f_4cupy_4cuda_13pinned_memory_alloc_pinned_memory)(Py_ssize_t, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.cuda.runtime' */
static PyTypeObject *__pyx_ptype_4cupy_4cuda_7runtime_PointerAttributes = 0;
static int (*__pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion)(int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.cuda.stream' */
static size_t (*__pyx_f_4cupy_4cuda_6stream_get_current_stream_ptr)(void); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6stream_get_current_stream)(int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.core.core' */
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_ndarray = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_Indexer = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_CArray = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_CIndexer = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_ParameterInfo = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_ElementwiseKernel = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_broadcast = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_1_genexpr = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_2___init__ = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_3_genexpr = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_4_genexpr = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_6_genexpr = 0;
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 *__pyx_v_4cupy_4core_4core__cupy_header_list = 0;
static PyObject *__pyx_v_4cupy_4core_4core__cupy_header = 0;
static PyObject *__pyx_v_4cupy_4core_4core__cupy_extra_header_list = 0;
static PyObject *__pyx_v_4cupy_4core_4core__header_path_cache = 0;
static PyObject *__pyx_v_4cupy_4core_4core__header_source = 0;
static PyObject *__pyx_v_4cupy_4core_4core__typenames_base = 0;
static PyObject *__pyx_v_4cupy_4core_4core__typenames = 0;
static PyObject *__pyx_v_4cupy_4core_4core__python_scalar_type = 0;
static PyObject *__pyx_v_4cupy_4core_4core__numpy_scalar_type = 0;
static PyObject *__pyx_v_4cupy_4core_4core__python_scalar_type_set = 0;
static PyObject *__pyx_v_4cupy_4core_4core__numpy_scalar_type_set = 0;
static PyObject *__pyx_v_4cupy_4core_4core__kind_score = 0;
static PyObject *__pyx_v_4cupy_4core_4core__python_type_to_numpy_type = 0;
static PY_LONG_LONG __pyx_v_4cupy_4core_4core__int_min;
static PY_LONG_LONG __pyx_v_4cupy_4core_4core__int_max;
static PyObject *__pyx_v_4cupy_4core_4core__int_type = 0;
static PyObject *__pyx_v_4cupy_4core_4core__id = 0;
static PyObject *__pyx_v_4cupy_4core_4core__divmod_float = 0;
static PyObject *__pyx_v_4cupy_4core_4core__min_max_preamble = 0;
static PyObject *__pyx_v_4cupy_4core_4core__argmin = 0;
static PyObject *__pyx_v_4cupy_4core_4core__argmax = 0;
static Py_ssize_t __pyx_v_4cupy_4core_4core_PY_SSIZE_T_MAX;
static PyObject *__pyx_v_4cupy_4core_4core__concatenate_kernel_same_size = 0;
static PyObject *__pyx_v_4cupy_4core_4core__concatenate_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__take_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__take_kernel_0axis = 0;
static PyObject *__pyx_v_4cupy_4core_4core__choose_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__choose_clip_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__scatter_update_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__scatter_add_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__scatter_update_mask_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__scatter_add_mask_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__getitem_mask_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__cuda_runtime_version = 0;
static PyObject *__pyx_v_4cupy_4core_4core__tensordot_core_mul_sum = 0;
static PyObject *__pyx_v_4cupy_4core_4core__var_core = 0;
static PyObject *__pyx_v_4cupy_4core_4core__var_core_out = 0;
static PyObject *__pyx_v_4cupy_4core_4core__mean = 0;
static PyObject *__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i;
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 struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_ascontiguousarray(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray *__pyx_optional_args); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__should_use_rop(PyObject *, PyObject *); /*proto*/
static int __pyx_f_4cupy_4core_4core__normalize_order(PyObject *); /*proto*/
static std::vector<Py_ssize_t>  __pyx_f_4cupy_4core_4core__get_strides_for_nocopy_reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  &, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_header_dir_path(int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_header_source(int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_f_4cupy_4core_4core_compile_with_cache(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_simple_elementwise_kernel(PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__get_simple_elementwise_kernel *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__python_scalar_to_numpy_scalar(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_typename(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__preprocess_args(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_args_info(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_kernel_params(PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__reduce_dims(PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__broadcast(PyObject *, PyObject *, int); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_out_args(PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_out_args_with_params(PyObject *, PyObject *, PyObject *, PyObject *, struct __pyx_opt_args_4cupy_4core_4core__get_out_args_with_params *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__guess_routine_from_in_types(PyObject *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__guess_routine_from_dtype(PyObject *, PyObject *); /*proto*/
static int __pyx_f_4cupy_4core_4core__check_should_use_min_scalar(PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__guess_routine(PyObject *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_create_ufunc(PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_create_ufunc *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_simple_reduction_kernel(PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_axis(PyObject *, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_out_shape(PyObject *, PyObject *, PyObject *, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_trans_args(PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_inout_args(PyObject *, PyObject *, struct __pyx_obj_4cupy_4core_4core_Indexer *, struct __pyx_obj_4cupy_4core_4core_Indexer *, PyObject *, PyObject *, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_create_reduction_func(PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_create_reduction_func *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_array(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_array *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_asfortranarray(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_asfortranarray *__pyx_optional_args); /*proto*/
static std::vector<Py_ssize_t>  __pyx_f_4cupy_4core_4core_normalize_axis_tuple(PyObject *, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_moveaxis(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_rollaxis(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_rollaxis *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_broadcast_to(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__repeat(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__repeat *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_concatenate_method(PyObject *, int, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__concatenate(PyObject *, Py_ssize_t, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__concatenate_single_kernel(PyObject *, Py_ssize_t, PyObject *, PyObject *, int, int __pyx_skip_dispatch); /*proto*/
static Py_ssize_t __pyx_f_4cupy_4core_4core_size(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_size *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__create_bit_op(PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__create_bit_op *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__prepare_slice_list(PyObject *, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/
static Py_ssize_t __pyx_f_4cupy_4core_4core__get_mask_index(PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__prepare_advanced_indexing(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__simple_getitem(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__prepare_mask_indexing_single(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__getitem_mask_single(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, int, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__take(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__take *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__scatter_op_single(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__scatter_op_single *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__scatter_op_mask_single(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, Py_ssize_t, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__scatter_op(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__diagonal(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__diagonal *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__prepare_multiple_array_indexing(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__getitem_multiple(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_dot(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_dot *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__get_all_addresses(size_t, std::vector<size_t>  &, std::vector<size_t>  &, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__mat_ptrs(struct __pyx_obj_4cupy_4core_4core_ndarray *); /*proto*/
static int __pyx_f_4cupy_4core_4core__get_stride_for_strided_batched_gemm(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_matmul(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_matmul *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_tensordot_core(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, Py_ssize_t, Py_ssize_t, std::vector<Py_ssize_t> , int __pyx_skip_dispatch); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__to_cublas_vector(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_create_comparison(PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_create_comparison *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_create_arithmetic(PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__var(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__var *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__std(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__std *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_scan(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_scan *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_Indexer__set_state(struct __pyx_obj_4cupy_4core_4core_Indexer *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_ParameterInfo__set_state(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_ElementwiseKernel__set_state(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_broadcast__set_state(struct __pyx_obj_4cupy_4core_4core_broadcast *, PyObject *); /*proto*/
static std::vector<Py_ssize_t>  __pyx_convert_vector_from_py_Py_ssize_t(PyObject *); /*proto*/
static std::vector<size_t>  __pyx_convert_vector_from_py_size_t(PyObject *); /*proto*/
static PyObject *__pyx_convert_vector_to_py_Py_ssize_t(const std::vector<Py_ssize_t>  &); /*proto*/
static PyObject *__pyx_convert_vector_to_py_size_t(const std::vector<size_t>  &); /*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*/
static __Pyx_TypeInfo __Pyx_TypeInfo_Py_ssize_t = { "Py_ssize_t", NULL, sizeof(Py_ssize_t), { 0 }, 0, IS_UNSIGNED(Py_ssize_t) ? 'U' : 'I', IS_UNSIGNED(Py_ssize_t), 0 };
#define __Pyx_MODULE_NAME "cupy.core.core"
extern int __pyx_module_is_main_cupy__core__core;
int __pyx_module_is_main_cupy__core__core = 0;

/* Implementation of 'cupy.core.core' */
static PyObject *__pyx_builtin_ImportError;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_property;
static PyObject *__pyx_builtin_super;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_chr;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_NotImplemented;
static PyObject *__pyx_builtin_sum;
static PyObject *__pyx_builtin_oct;
static PyObject *__pyx_builtin_hex;
static PyObject *__pyx_builtin_open;
static PyObject *__pyx_builtin_zip;
static PyObject *__pyx_builtin_map;
static PyObject *__pyx_builtin_MemoryError;
static PyObject *__pyx_builtin_Ellipsis;
static PyObject *__pyx_builtin_id;
static const char __pyx_k_0[] = "0";
static const char __pyx_k_A[] = "A";
static const char __pyx_k_B[] = "B->?";
static const char __pyx_k_C[] = "C";
static const char __pyx_k_D[] = "D";
static const char __pyx_k_F[] = "F";
static const char __pyx_k_H[] = "H->?";
static const char __pyx_k_I[] = "-I ";
static const char __pyx_k_K[] = "K";
static const char __pyx_k_L[] = "L->?";
static const char __pyx_k_O[] = "O";
static const char __pyx_k_Q[] = "Q->?";
static const char __pyx_k_a[] = "a";
static const char __pyx_k_b[] = "b";
static const char __pyx_k_c[] = "c";
static const char __pyx_k_d[] = "d";
static const char __pyx_k_e[] = "e";
static const char __pyx_k_f[] = "f";
static const char __pyx_k_h[] = "h->?";
static const char __pyx_k_i[] = "i";
static const char __pyx_k_k[] = "k";
static const char __pyx_k_l[] = "l->?";
static const char __pyx_k_m[] = "m";
static const char __pyx_k_n[] = "n";
static const char __pyx_k_p[] = "p";
static const char __pyx_k_q[] = "?->q";
static const char __pyx_k_s[] = "%s";
static const char __pyx_k_t[] = "t";
static const char __pyx_k_u[] = "u";
static const char __pyx_k_v[] = "v";
static const char __pyx_k_x[] = "x";
static const char __pyx_k_BB[] = "BB->?";
static const char __pyx_k_DD[] = "DD->?";
static const char __pyx_k_FF[] = "FF->?";
static const char __pyx_k_HH[] = "HH->?";
static const char __pyx_k_II[] = "II->?";
static const char __pyx_k_LL[] = "LL->?";
static const char __pyx_k_QQ[] = "QQ->?";
static const char __pyx_k__6[] = "";
static const char __pyx_k_bb[] = "bb->?";
static const char __pyx_k_dd[] = "dd->?";
static const char __pyx_k_ee[] = "ee->?";
static const char __pyx_k_ff[] = "ff->?";
static const char __pyx_k_hh[] = "hh->?";
static const char __pyx_k_id[] = "id";
static const char __pyx_k_ii[] = "ii->?";
static const char __pyx_k_li[] = "li";
static const char __pyx_k_ll[] = "ll->?";
static const char __pyx_k_op[] = "op";
static const char __pyx_k_os[] = "os";
static const char __pyx_k_qq[] = "qq->?";
static const char __pyx_k_ri[] = "ri";
static const char __pyx_k_B_B[] = "B->B";
static const char __pyx_k_B_L[] = "B->L";
static const char __pyx_k_B_d[] = "B->d";
static const char __pyx_k_B_q[] = "B->q";
static const char __pyx_k_D_2[] = "D->?";
static const char __pyx_k_D_D[] = "D->D";
static const char __pyx_k_D_d[] = "D->d";
static const char __pyx_k_F_2[] = "F->?";
static const char __pyx_k_F_F[] = "F->F";
static const char __pyx_k_F_f[] = "F->f";
static const char __pyx_k_H_H[] = "H->H";
static const char __pyx_k_H_L[] = "H->L";
static const char __pyx_k_H_d[] = "H->d";
static const char __pyx_k_H_q[] = "H->q";
static const char __pyx_k_I_2[] = "I->?";
static const char __pyx_k_I_I[] = "I->I";
static const char __pyx_k_I_L[] = "I->L";
static const char __pyx_k_I_d[] = "I->d";
static const char __pyx_k_I_q[] = "I->q";
static const char __pyx_k_I_s[] = "-I%s";
static const char __pyx_k_L_L[] = "L->L";
static const char __pyx_k_L_d[] = "L->d";
static const char __pyx_k_L_q[] = "L->q";
static const char __pyx_k_PY3[] = "PY3";
static const char __pyx_k_Q_Q[] = "Q->Q";
static const char __pyx_k_Q_d[] = "Q->d";
static const char __pyx_k_Q_q[] = "Q->q";
static const char __pyx_k_T_a[] = "T a";
static const char __pyx_k_T_y[] = "T y";
static const char __pyx_k__53[] = "\n";
static const char __pyx_k__56[] = ", ";
static const char __pyx_k__57[] = ",";
static const char __pyx_k__71[] = "->";
static const char __pyx_k_a_b[] = "a + b";
static const char __pyx_k_add[] = "add";
static const char __pyx_k_all[] = "all";
static const char __pyx_k_any[] = "any";
static const char __pyx_k_arr[] = "arr";
static const char __pyx_k_ary[] = "ary";
static const char __pyx_k_b_2[] = "\077\077->b";
static const char __pyx_k_b_b[] = "b->b";
static const char __pyx_k_b_l[] = "b->l";
static const char __pyx_k_biu[] = "biu";
static const char __pyx_k_chr[] = "chr";
static const char __pyx_k_d_2[] = "d->?";
static const char __pyx_k_d_3[] = "?->d";
static const char __pyx_k_d_D[] = "d->D";
static const char __pyx_k_d_d[] = "d->d";
static const char __pyx_k_d_q[] = "d->q";
static const char __pyx_k_doc[] = "doc";
static const char __pyx_k_e_2[] = "e->?";
static const char __pyx_k_e_e[] = "e->e";
static const char __pyx_k_e_q[] = "e->q";
static const char __pyx_k_f_2[] = "f->?";
static const char __pyx_k_f_F[] = "f->F";
static const char __pyx_k_f_f[] = "f->f";
static const char __pyx_k_f_q[] = "f->q";
static const char __pyx_k_fid[] = "fid";
static const char __pyx_k_fmt[] = "fmt";
static const char __pyx_k_get[] = "get";
static const char __pyx_k_h_d[] = "h->d";
static const char __pyx_k_h_h[] = "h->h";
static const char __pyx_k_h_l[] = "h->l";
static const char __pyx_k_h_q[] = "h->q";
static const char __pyx_k_hex[] = "hex";
static const char __pyx_k_i_2[] = "i->?";
static const char __pyx_k_i_d[] = "i->d";
static const char __pyx_k_i_i[] = "i->i";
static const char __pyx_k_i_l[] = "i->l";
static const char __pyx_k_i_q[] = "i->q";
static const char __pyx_k_in0[] = "in0";
static const char __pyx_k_inf[] = "-inf";
static const char __pyx_k_int[] = "int";
static const char __pyx_k_kth[] = "kth";
static const char __pyx_k_l_2[] = "?->l";
static const char __pyx_k_l_d[] = "l->d";
static const char __pyx_k_l_l[] = "l->l";
static const char __pyx_k_l_q[] = "l->q";
static const char __pyx_k_map[] = "map";
static const char __pyx_k_max[] = "max";
static const char __pyx_k_min[] = "min";
static const char __pyx_k_new[] = "__new__";
static const char __pyx_k_nin[] = "nin";
static const char __pyx_k_obj[] = "obj";
static const char __pyx_k_oct[] = "oct";
static const char __pyx_k_ops[] = "ops";
static const char __pyx_k_out[] = "out";
static const char __pyx_k_pop[] = "pop";
static const char __pyx_k_ptr[] = "ptr";
static const char __pyx_k_q_2[] = "q->?";
static const char __pyx_k_q_d[] = "q->d";
static const char __pyx_k_q_q[] = "q->q";
static const char __pyx_k_raw[] = "_raw_";
static const char __pyx_k_ret[] = "ret";
static const char __pyx_k_ror[] = "__ror__";
static const char __pyx_k_s_2[] = "s";
static const char __pyx_k_s_s[] = "%s->%s";
static const char __pyx_k_sep[] = "sep";
static const char __pyx_k_set[] = "set";
static const char __pyx_k_six[] = "six";
static const char __pyx_k_std[] = "std";
static const char __pyx_k_sum[] = "sum";
static const char __pyx_k_sys[] = "sys";
static const char __pyx_k_tup[] = "tup";
static const char __pyx_k_var[] = "var";
static const char __pyx_k_zip[] = "zip";
static const char __pyx_k_BB_B[] = "BB->B";
static const char __pyx_k_BB_d[] = "BB->d";
static const char __pyx_k_DD_D[] = "DD->D";
static const char __pyx_k_FF_F[] = "FF->F";
static const char __pyx_k_HH_H[] = "HH->H";
static const char __pyx_k_HH_d[] = "HH->d";
static const char __pyx_k_II_I[] = "II->I";
static const char __pyx_k_II_d[] = "II->d";
static const char __pyx_k_LL_L[] = "LL->L";
static const char __pyx_k_LL_d[] = "LL->d";
static const char __pyx_k_QQ_Q[] = "QQ->Q";
static const char __pyx_k_QQ_d[] = "QQ->d";
static const char __pyx_k__105[] = "\077\077->?";
static const char __pyx_k__227[] = "_";
static const char __pyx_k__247[] = "?->?";
static const char __pyx_k__294[] = "&";
static const char __pyx_k__295[] = "|";
static const char __pyx_k__296[] = "^";
static const char __pyx_k__300[] = "<<";
static const char __pyx_k__301[] = ">>";
static const char __pyx_k__312[] = ">";
static const char __pyx_k__313[] = ">=";
static const char __pyx_k__314[] = "<";
static const char __pyx_k__315[] = "<=";
static const char __pyx_k__316[] = "==";
static const char __pyx_k__317[] = "!=";
static const char __pyx_k__338[] = "+";
static const char __pyx_k__362[] = "*";
static const char __pyx_k__377[] = "-";
static const char __pyx_k__401[] = "\077\077?->?";
static const char __pyx_k_amax[] = "_amax";
static const char __pyx_k_amin[] = "_amin";
static const char __pyx_k_arch[] = "arch";
static const char __pyx_k_args[] = "args";
static const char __pyx_k_axis[] = "axis";
static const char __pyx_k_base[] = "base";
static const char __pyx_k_bb_b[] = "bb->b";
static const char __pyx_k_bb_d[] = "bb->d";
static const char __pyx_k_bool[] = "bool_";
static const char __pyx_k_call[] = "__call__";
static const char __pyx_k_char[] = "char";
static const char __pyx_k_clip[] = "clip";
static const char __pyx_k_conj[] = "conj";
static const char __pyx_k_copy[] = "copy";
static const char __pyx_k_cuda[] = "cuda";
static const char __pyx_k_cupy[] = "cupy";
static const char __pyx_k_data[] = "data";
static const char __pyx_k_dd_d[] = "dd->d";
static const char __pyx_k_ddof[] = "ddof";
static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_dump[] = "dump";
static const char __pyx_k_ee_e[] = "ee->e";
static const char __pyx_k_elem[] = "elem";
static const char __pyx_k_exit[] = "__exit__";
static const char __pyx_k_fdFD[] = "fdFD";
static const char __pyx_k_ff_f[] = "ff->f";
static const char __pyx_k_file[] = "__file__";
static const char __pyx_k_fill[] = "fill";
static const char __pyx_k_grid[] = "grid";
static const char __pyx_k_hh_d[] = "hh->d";
static const char __pyx_k_hh_h[] = "hh->h";
static const char __pyx_k_ii_d[] = "ii->d";
static const char __pyx_k_ii_i[] = "ii->i";
static const char __pyx_k_imag[] = "imag";
static const char __pyx_k_init[] = "__init__";
static const char __pyx_k_int8[] = "int8";
static const char __pyx_k_intp[] = "intp";
static const char __pyx_k_item[] = "item";
static const char __pyx_k_join[] = "join";
static const char __pyx_k_kern[] = "kern";
static const char __pyx_k_kind[] = "kind";
static const char __pyx_k_less[] = "less";
static const char __pyx_k_ll_d[] = "ll->d";
static const char __pyx_k_ll_l[] = "ll->l";
static const char __pyx_k_long[] = "__long__";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_mask[] = "mask";
static const char __pyx_k_mean[] = "mean";
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_nout[] = "nout";
static const char __pyx_k_open[] = "open";
static const char __pyx_k_pack[] = "pack";
static const char __pyx_k_path[] = "path";
static const char __pyx_k_prev[] = "prev";
static const char __pyx_k_prod[] = "prod";
static const char __pyx_k_qq_d[] = "qq->d";
static const char __pyx_k_qq_q[] = "qq->q";
static const char __pyx_k_radd[] = "__radd__";
static const char __pyx_k_rand[] = "__rand__";
static const char __pyx_k_rdiv[] = "__rdiv__";
static const char __pyx_k_read[] = "read";
static const char __pyx_k_real[] = "real";
static const char __pyx_k_repr[] = "__repr__";
static const char __pyx_k_rmod[] = "__rmod__";
static const char __pyx_k_rmul[] = "__rmul__";
static const char __pyx_k_rpow[] = "__rpow__";
static const char __pyx_k_rsub[] = "__rsub__";
static const char __pyx_k_rxor[] = "__rxor__";
static const char __pyx_k_self[] = "self";
static const char __pyx_k_send[] = "send";
static const char __pyx_k_size[] = "size";
static const char __pyx_k_sort[] = "sort";
static const char __pyx_k_sqrt[] = "sqrt";
static const char __pyx_k_step[] = "step";
static const char __pyx_k_stop[] = "stop";
static const char __pyx_k_take[] = "take";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_true[] = "true";
static const char __pyx_k_type[] = "type";
static const char __pyx_k_util[] = "util";
static const char __pyx_k_view[] = "view";
static const char __pyx_k_warn[] = "warn";
static const char __pyx_k_wrap[] = "wrap";
static const char __pyx_k_ASCII[] = "ASCII";
static const char __pyx_k_BBB_B[] = "BBB->B";
static const char __pyx_k_BB_BB[] = "BB->BB";
static const char __pyx_k_B_B_2[] = "B?->B";
static const char __pyx_k_D_D_2[] = "D?->D";
static const char __pyx_k_F_F_2[] = "F?->F";
static const char __pyx_k_Flags[] = "Flags";
static const char __pyx_k_HHH_H[] = "HHH->H";
static const char __pyx_k_HH_HH[] = "HH->HH";
static const char __pyx_k_H_H_2[] = "H?->H";
static const char __pyx_k_III_I[] = "III->I";
static const char __pyx_k_II_II[] = "II->II";
static const char __pyx_k_I_I_2[] = "I?->I";
static const char __pyx_k_LLL_L[] = "LLL->L";
static const char __pyx_k_LL_LL[] = "LL->LL";
static const char __pyx_k_L_L_2[] = "L?->L";
static const char __pyx_k_QQQ_Q[] = "QQQ->Q";
static const char __pyx_k_QQ_QQ[] = "QQ->QQ";
static const char __pyx_k_Q_Q_2[] = "Q?->Q";
static const char __pyx_k_T_in0[] = "T in0";
static const char __pyx_k_T_out[] = "T out";
static const char __pyx_k_U_out[] = "U out";
static const char __pyx_k_a_b_2[] = "a & b";
static const char __pyx_k_a_b_3[] = "a | b";
static const char __pyx_k_a_b_4[] = "a * b";
static const char __pyx_k_a_max[] = "a_max";
static const char __pyx_k_a_min[] = "a_min";
static const char __pyx_k_all_2[] = "_all";
static const char __pyx_k_angle[] = "angle";
static const char __pyx_k_any_2[] = "_any";
static const char __pyx_k_array[] = "array";
static const char __pyx_k_axis1[] = "axis1";
static const char __pyx_k_axis2[] = "axis2";
static const char __pyx_k_b_b_2[] = "b?->b";
static const char __pyx_k_bb_bb[] = "bb->bb";
static const char __pyx_k_bbb_b[] = "bbb->b";
static const char __pyx_k_block[] = "block";
static const char __pyx_k_broad[] = "broad";
static const char __pyx_k_class[] = "__class__";
static const char __pyx_k_close[] = "close";
static const char __pyx_k_ctype[] = "ctype";
static const char __pyx_k_d_d_2[] = "d?->d";
static const char __pyx_k_dd_dd[] = "dd->dd";
static const char __pyx_k_ddd_d[] = "ddd->d";
static const char __pyx_k_dgeam[] = "dgeam";
static const char __pyx_k_doc_2[] = "__doc__";
static const char __pyx_k_dtype[] = "dtype";
static const char __pyx_k_dumps[] = "dumps";
static const char __pyx_k_e_e_2[] = "e?->e";
static const char __pyx_k_ee_ee[] = "ee->ee";
static const char __pyx_k_eee_e[] = "eee->e";
static const char __pyx_k_empty[] = "empty";
static const char __pyx_k_enter[] = "__enter__";
static const char __pyx_k_equal[] = "equal";
static const char __pyx_k_error[] = "error";
static const char __pyx_k_f_f_2[] = "f?->f";
static const char __pyx_k_false[] = "false";
static const char __pyx_k_ff_ff[] = "ff->ff";
static const char __pyx_k_fff_f[] = "fff->f";
static const char __pyx_k_flags[] = "flags";
static const char __pyx_k_float[] = "float";
static const char __pyx_k_h_h_2[] = "h?->h";
static const char __pyx_k_hh_hh[] = "hh->hh";
static const char __pyx_k_hhh_h[] = "hhh->h";
static const char __pyx_k_i_i_2[] = "i?->i";
static const char __pyx_k_ii_ii[] = "ii->ii";
static const char __pyx_k_iii_i[] = "iii->i";
static const char __pyx_k_iinfo[] = "iinfo";
static const char __pyx_k_index[] = "index";
static const char __pyx_k_inf_2[] = "inf";
static const char __pyx_k_int16[] = "int16";
static const char __pyx_k_int32[] = "int32";
static const char __pyx_k_int64[] = "int64";
static const char __pyx_k_items[] = "items";
static const char __pyx_k_l_l_2[] = "l?->l";
static const char __pyx_k_laxis[] = "laxis";
static const char __pyx_k_ll_ll[] = "ll->ll";
static const char __pyx_k_lll_l[] = "lll->l";
static const char __pyx_k_lower[] = "lower";
static const char __pyx_k_moves[] = "moves";
static const char __pyx_k_nargs[] = "nargs";
static const char __pyx_k_ndmin[] = "ndmin";
static const char __pyx_k_numpy[] = "numpy";
static const char __pyx_k_ops_2[] = "_ops";
static const char __pyx_k_order[] = "order";
static const char __pyx_k_out_a[] = "out = a";
static const char __pyx_k_param[] = "param";
static const char __pyx_k_power[] = "power";
static const char __pyx_k_q_q_2[] = "q?->q";
static const char __pyx_k_qq_qq[] = "qq->qq";
static const char __pyx_k_qqq_q[] = "qqq->q";
static const char __pyx_k_raise[] = "raise";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_ravel[] = "ravel";
static const char __pyx_k_raw_2[] = "raw";
static const char __pyx_k_raxis[] = "raxis";
static const char __pyx_k_s_s_s[] = "%s %s%s";
static const char __pyx_k_sgeam[] = "sgeam";
static const char __pyx_k_shape[] = "shape";
static const char __pyx_k_short[] = "short";
static const char __pyx_k_split[] = "split";
static const char __pyx_k_start[] = "start";
static const char __pyx_k_strip[] = "strip";
static const char __pyx_k_subok[] = "subok";
static const char __pyx_k_super[] = "super";
static const char __pyx_k_throw[] = "throw";
static const char __pyx_k_trace[] = "trace";
static const char __pyx_k_trans[] = "trans";
static const char __pyx_k_types[] = "types";
static const char __pyx_k_ufunc[] = "ufunc";
static const char __pyx_k_uint8[] = "uint8";
static const char __pyx_k_uintp[] = "uintp";
static const char __pyx_k_value[] = "value";
static const char __pyx_k_var_2[] = "_var";
static const char __pyx_k_zeros[] = "zeros";
static const char __pyx_k_Device[] = "Device";
static const char __pyx_k_T_in_d[] = "T in%d";
static const char __pyx_k_T_out0[] = "T out0";
static const char __pyx_k_append[] = "append";
static const char __pyx_k_arange[] = "arange";
static const char __pyx_k_argmax[] = "argmax";
static const char __pyx_k_argmin[] = "argmin";
static const char __pyx_k_arrays[] = "arrays";
static const char __pyx_k_astype[] = "astype";
static const char __pyx_k_bool_2[] = "bool";
static const char __pyx_k_choose[] = "choose";
static const char __pyx_k_clip_2[] = "_clip";
static const char __pyx_k_ctypes[] = "ctypes";
static const char __pyx_k_cublas[] = "cublas";
static const char __pyx_k_cupy_2[] = "cupy_";
static const char __pyx_k_device[] = "device";
static const char __pyx_k_divide[] = "divide";
static const char __pyx_k_divmod[] = "divmod";
static const char __pyx_k_double[] = "double";
static const char __pyx_k_encode[] = "encode";
static const char __pyx_k_extend[] = "extend";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_in_str[] = "in_str";
static const char __pyx_k_invert[] = "invert";
static const char __pyx_k_kernel[] = "kernel";
static const char __pyx_k_kwargs[] = "kwargs";
static const char __pyx_k_memptr[] = "memptr";
static const char __pyx_k_module[] = "__module__";
static const char __pyx_k_n_args[] = "n_args";
static const char __pyx_k_name_2[] = "__name__";
static const char __pyx_k_nanmax[] = "nanmax";
static const char __pyx_k_nanmin[] = "nanmin";
static const char __pyx_k_nbytes[] = "nbytes";
static const char __pyx_k_object[] = "object";
static const char __pyx_k_offset[] = "offset";
static const char __pyx_k_out0_0[] = "out0 = 0";
static const char __pyx_k_out0_a[] = "out0 = a";
static const char __pyx_k_params[] = "params";
static const char __pyx_k_pickle[] = "pickle";
static const char __pyx_k_record[] = "record";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_repeat[] = "repeat";
static const char __pyx_k_rundim[] = "rundim";
static const char __pyx_k_slices[] = "slices";
static const char __pyx_k_source[] = "source";
static const char __pyx_k_stream[] = "stream";
static const char __pyx_k_stride[] = "stride";
static const char __pyx_k_string[] = "string";
static const char __pyx_k_struct[] = "struct";
static const char __pyx_k_thrust[] = "thrust";
static const char __pyx_k_tofile[] = "tofile";
static const char __pyx_k_tolist[] = "tolist";
static const char __pyx_k_uint16[] = "uint16";
static const char __pyx_k_uint32[] = "uint32";
static const char __pyx_k_uint64[] = "uint64";
static const char __pyx_k_unpack[] = "unpack";
static const char __pyx_k_unsafe[] = "unsafe";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_S_x_T_y[] = "S x, T y";
static const char __pyx_k_T_out_d[] = "T out%d";
static const char __pyx_k_a_shape[] = "a_shape";
static const char __pyx_k_abspath[] = "abspath";
static const char __pyx_k_argsort[] = "argsort";
static const char __pyx_k_cPickle[] = "cPickle";
static const char __pyx_k_casting[] = "casting";
static const char __pyx_k_choices[] = "choices";
static const char __pyx_k_dirname[] = "dirname";
static const char __pyx_k_dtype_2[] = "_dtype";
static const char __pyx_k_flatten[] = "flatten";
static const char __pyx_k_float16[] = "float16";
static const char __pyx_k_float32[] = "float32";
static const char __pyx_k_float64[] = "float64";
static const char __pyx_k_fortran[] = "fortran";
static const char __pyx_k_genexpr[] = "genexpr";
static const char __pyx_k_greater[] = "greater";
static const char __pyx_k_in_args[] = "in_args";
static const char __pyx_k_include[] = "include";
static const char __pyx_k_indexer[] = "indexer";
static const char __pyx_k_indices[] = "indices";
static const char __pyx_k_integer[] = "integer";
static const char __pyx_k_maximum[] = "maximum";
static const char __pyx_k_maxsize[] = "maxsize";
static const char __pyx_k_memoize[] = "memoize";
static const char __pyx_k_memview[] = "memview";
static const char __pyx_k_ndarray[] = "ndarray";
static const char __pyx_k_no_bool[] = "no_bool";
static const char __pyx_k_options[] = "options";
static const char __pyx_k_out_str[] = "out_str";
static const char __pyx_k_prepare[] = "__prepare__";
static const char __pyx_k_raw_T_a[] = "raw T a";
static const char __pyx_k_rdivmod[] = "__rdivmod__";
static const char __pyx_k_repeats[] = "repeats";
static const char __pyx_k_reshape[] = "_reshape";
static const char __pyx_k_rlshift[] = "__rlshift__";
static const char __pyx_k_rmatmul[] = "__rmatmul__";
static const char __pyx_k_routine[] = "routine";
static const char __pyx_k_rrshift[] = "__rrshift__";
static const char __pyx_k_shape_2[] = "_shape";
static const char __pyx_k_squeeze[] = "squeeze";
static const char __pyx_k_strides[] = "strides";
static const char __pyx_k_ufunc_s[] = "<ufunc '%s'>";
static const char __pyx_k_CIndexer[] = "CIndexer";
static const char __pyx_k_Ellipsis[] = "Ellipsis";
static const char __pyx_k_Sequence[] = "Sequence";
static const char __pyx_k_Template[] = "Template";
static const char __pyx_k_absolute[] = "absolute";
static const char __pyx_k_can_cast[] = "can_cast";
static const char __pyx_k_compiler[] = "compiler";
static const char __pyx_k_cupy_all[] = "cupy_all";
static const char __pyx_k_cupy_any[] = "cupy_any";
static const char __pyx_k_cupy_max[] = "cupy_max";
static const char __pyx_k_cupy_min[] = "cupy_min";
static const char __pyx_k_cupy_sum[] = "cupy_sum";
static const char __pyx_k_diagonal[] = "diagonal";
static const char __pyx_k_floating[] = "floating";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_identity[] = "identity";
static const char __pyx_k_in_sahpe[] = "in_sahpe";
static const char __pyx_k_in_shape[] = "in_shape";
static const char __pyx_k_in_types[] = "in_types";
static const char __pyx_k_is_const[] = "is_const";
static const char __pyx_k_isscalar[] = "isscalar";
static const char __pyx_k_itemsize[] = "itemsize";
static const char __pyx_k_keepdims[] = "keepdims";
static const char __pyx_k_map_expr[] = "map_expr";
static const char __pyx_k_module_2[] = "module";
static const char __pyx_k_multiply[] = "multiply";
static const char __pyx_k_negative[] = "negative";
static const char __pyx_k_newshape[] = "newshape";
static const char __pyx_k_out0_in0[] = "out0 = in0";
static const char __pyx_k_out_args[] = "out_args";
static const char __pyx_k_params_2[] = "_params";
static const char __pyx_k_preamble[] = "preamble";
static const char __pyx_k_property[] = "property";
static const char __pyx_k_pyx_type[] = "__pyx_type";
static const char __pyx_k_qualname[] = "__qualname__";
static const char __pyx_k_rollaxis[] = "rollaxis";
static const char __pyx_k_rtruediv[] = "__rtruediv__";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_src_ndim[] = "src_ndim";
static const char __pyx_k_subtract[] = "subtract";
static const char __pyx_k_swapaxes[] = "swapaxes";
static const char __pyx_k_var_core[] = "_var_core";
static const char __pyx_k_warnings[] = "warnings";
static const char __pyx_k_AxisError[] = "_AxisError";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_args_info[] = "args_info";
static const char __pyx_k_cachd_dir[] = "cachd_dir";
static const char __pyx_k_complex64[] = "complex64";
static const char __pyx_k_cupy_clip[] = "cupy_clip";
static const char __pyx_k_cupy_conj[] = "cupy_conj";
static const char __pyx_k_cupy_copy[] = "cupy_copy";
static const char __pyx_k_cupy_core[] = "cupy.core";
static const char __pyx_k_cupy_cuda[] = "cupy.cuda";
static const char __pyx_k_cupy_imag[] = "cupy_imag";
static const char __pyx_k_cupy_mean[] = "cupy_mean";
static const char __pyx_k_cupy_prod[] = "cupy_prod";
static const char __pyx_k_cupy_real[] = "cupy_real";
static const char __pyx_k_cupy_sqrt[] = "cupy_sqrt";
static const char __pyx_k_cupy_take[] = "cupy_take";
static const char __pyx_k_dst_dtype[] = "dst_dtype";
static const char __pyx_k_each_size[] = "each_size";
static const char __pyx_k_enumerate[] = "enumerate";
static const char __pyx_k_in_params[] = "in_params";
static const char __pyx_k_include_s[] = "#include <%s>\n";
static const char __pyx_k_int_iinfo[] = "_int_iinfo";
static const char __pyx_k_long_long[] = "long long";
static const char __pyx_k_loop_prep[] = "loop_prep";
static const char __pyx_k_metaclass[] = "__metaclass__";
static const char __pyx_k_not_equal[] = "not_equal";
static const char __pyx_k_operation[] = "operation";
static const char __pyx_k_out_shape[] = "out_shape";
static const char __pyx_k_out_types[] = "out_types";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_raw_T_out[] = "raw T out";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_remainder[] = "remainder";
static const char __pyx_k_reshape_2[] = "reshape";
static const char __pyx_k_ret_shape[] = "ret_shape";
static const char __pyx_k_rfloordiv[] = "__rfloordiv__";
static const char __pyx_k_same_kind[] = "same_kind";
static const char __pyx_k_src_dtype[] = "src_dtype";
static const char __pyx_k_start_adr[] = "start_adr";
static const char __pyx_k_transpose[] = "_transpose";
static const char __pyx_k_type_dict[] = "type_dict";
static const char __pyx_k_ulonglong[] = "ulonglong";
static const char __pyx_k_CArray_s_d[] = "CArray<%s, %d>";
static const char __pyx_k_CIndexer_d[] = "CIndexer<%d>";
static const char __pyx_k_IndexError[] = "IndexError";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_after_loop[] = "after_loop";
static const char __pyx_k_bit_length[] = "bit_length";
static const char __pyx_k_bitwise_or[] = "bitwise_or";
static const char __pyx_k_block_size[] = "block_size";
static const char __pyx_k_clp2_count[] = "clp2_count";
static const char __pyx_k_complex128[] = "complex128";
static const char __pyx_k_cupy_angle[] = "cupy_angle";
static const char __pyx_k_cupy_power[] = "cupy_power";
static const char __pyx_k_frombuffer[] = "frombuffer";
static const char __pyx_k_in_indexer[] = "in_indexer";
static const char __pyx_k_inout_args[] = "inout_args";
static const char __pyx_k_input_expr[] = "input_expr";
static const char __pyx_k_issubdtype[] = "issubdtype";
static const char __pyx_k_left_shift[] = "left_shift";
static const char __pyx_k_less_equal[] = "less_equal";
static const char __pyx_k_my_max_a_b[] = "my_max(a, b)";
static const char __pyx_k_my_min_a_b[] = "my_min(a, b)";
static const char __pyx_k_out0_in0_2[] = "out0 = !in0";
static const char __pyx_k_out0_in0_3[] = "out0 = ~in0";
static const char __pyx_k_out0_in0_4[] = "out0 = -in0";
static const char __pyx_k_out_params[] = "out_params";
static const char __pyx_k_preamble_2[] = "_preamble";
static const char __pyx_k_pyx_result[] = "__pyx_result";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_shared_mem[] = "shared_mem";
static const char __pyx_k_substitute[] = "substitute";
static const char __pyx_k_AxisError_2[] = "AxisError";
static const char __pyx_k_ImportError[] = "ImportError";
static const char __pyx_k_MemoryError[] = "MemoryError";
static const char __pyx_k_PickleError[] = "PickleError";
static const char __pyx_k_array_split[] = "array_split";
static const char __pyx_k_bitwise_and[] = "bitwise_and";
static const char __pyx_k_bitwise_xor[] = "bitwise_xor";
static const char __pyx_k_broad_shape[] = "broad_shape";
static const char __pyx_k_collections[] = "collections";
static const char __pyx_k_cupy_argmax[] = "cupy_argmax";
static const char __pyx_k_cupy_argmin[] = "cupy_argmin";
static const char __pyx_k_cupy_choose[] = "cupy_choose";
static const char __pyx_k_cupy_divide[] = "cupy_divide";
static const char __pyx_k_cupy_divmod[] = "cupy_divmod";
static const char __pyx_k_cupy_invert[] = "cupy_invert";
static const char __pyx_k_cupy_nanmax[] = "cupy_nanmax";
static const char __pyx_k_cupy_nanmin[] = "cupy_nanmin";
static const char __pyx_k_destination[] = "destination";
static const char __pyx_k_has_element[] = "_has_element";
static const char __pyx_k_imag_setter[] = "_imag_setter";
static const char __pyx_k_in_params_2[] = "_in_params";
static const char __pyx_k_index_dtype[] = "index_dtype";
static const char __pyx_k_out_alpha_a[] = "out = alpha * a";
static const char __pyx_k_out_indexer[] = "out_indexer";
static const char __pyx_k_output_expr[] = "output_expr";
static const char __pyx_k_real_setter[] = "_real_setter";
static const char __pyx_k_reduce_dims[] = "reduce_dims";
static const char __pyx_k_reduce_expr[] = "reduce_expr";
static const char __pyx_k_reduce_type[] = "reduce_type";
static const char __pyx_k_result_type[] = "result_type";
static const char __pyx_k_right_shift[] = "right_shift";
static const char __pyx_k_signed_char[] = "signed char";
static const char __pyx_k_transpose_2[] = "transpose";
static const char __pyx_k_true_divide[] = "true_divide";
static const char __pyx_k_typedef_s_s[] = "typedef %s %s;";
static const char __pyx_k_ufunc_types[] = "ufunc.types";
static const char __pyx_k_Axes_overrun[] = "Axes overrun";
static const char __pyx_k_Axis_overrun[] = "Axis overrun";
static const char __pyx_k_RuntimeError[] = "RuntimeError";
static const char __pyx_k_Wrong_type_s[] = "Wrong type %s";
static const char __pyx_k_block_size_2[] = "_block_size";
static const char __pyx_k_block_stride[] = "block_stride";
static const char __pyx_k_c_contiguous[] = "c_contiguous";
static const char __pyx_k_cgemmBatched[] = "cgemmBatched";
static const char __pyx_k_create_ufunc[] = "create_ufunc";
static const char __pyx_k_dgemmBatched[] = "dgemmBatched";
static const char __pyx_k_floor_divide[] = "floor_divide";
static const char __pyx_k_in_arg_dtype[] = "in_arg_dtype";
static const char __pyx_k_input_expr_2[] = "_input_expr";
static const char __pyx_k_merge_kernel[] = "merge_kernel";
static const char __pyx_k_out0_a_index[] = "out0 = a.index";
static const char __pyx_k_out0_a_value[] = "out0 = a.value";
static const char __pyx_k_out0_abs_in0[] = "out0 = abs(in0)";
static const char __pyx_k_out0_arg_in0[] = "out0 = arg(in0)";
static const char __pyx_k_out0_in0_in1[] = "out0 = in0 / in1";
static const char __pyx_k_out_params_2[] = "_out_params";
static const char __pyx_k_pre_map_expr[] = "pre_map_expr";
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
static const char __pyx_k_reduced_view[] = "reduced_view";
static const char __pyx_k_sgemmBatched[] = "sgemmBatched";
static const char __pyx_k_stringsource[] = "stringsource";
static const char __pyx_k_ufunc___call[] = "ufunc.__call__";
static const char __pyx_k_ufunc___init[] = "ufunc.__init__";
static const char __pyx_k_ufunc___repr[] = "ufunc.__repr__";
static const char __pyx_k_unsigned_int[] = "unsigned int";
static const char __pyx_k_version_info[] = "version_info";
static const char __pyx_k_zgemmBatched[] = "zgemmBatched";
static const char __pyx_k_CIndexer__ind[] = "CIndexer _ind";
static const char __pyx_k_complex_float[] = "complex<float>";
static const char __pyx_k_cublas_handle[] = "cublas_handle";
static const char __pyx_k_cupy_absolute[] = "cupy_absolute";
static const char __pyx_k_cupy_negative[] = "cupy_negative";
static const char __pyx_k_dtype_is_None[] = "dtype is None";
static const char __pyx_k_get_cuda_path[] = "get_cuda_path";
static const char __pyx_k_greater_equal[] = "greater_equal";
static const char __pyx_k_in_args_dtype[] = "in_args_dtype";
static const char __pyx_k_integer_types[] = "integer_types";
static const char __pyx_k_kernel_params[] = "kernel_params";
static const char __pyx_k_linear_launch[] = "linear_launch";
static const char __pyx_k_my_argmax_a_b[] = "my_argmax(a, b)";
static const char __pyx_k_my_argmin_a_b[] = "my_argmin(a, b)";
static const char __pyx_k_out0_conj_in0[] = "out0 = conj(in0)";
static const char __pyx_k_out0_fabs_in0[] = "out0 = fabs(in0)";
static const char __pyx_k_out0_imag_in0[] = "out0.imag(in0)";
static const char __pyx_k_out0_in0_imag[] = "out0 = in0.imag()";
static const char __pyx_k_out0_in0_real[] = "out0 = in0.real()";
static const char __pyx_k_out0_real_in0[] = "out0.real(in0)";
static const char __pyx_k_out0_sqrt_in0[] = "out0 = sqrt(in0)";
static const char __pyx_k_out_arg_dtype[] = "out_arg_dtype";
static const char __pyx_k_out_clp2_size[] = "out_clp2_size";
static const char __pyx_k_output_expr_2[] = "_output_expr";
static const char __pyx_k_post_map_expr[] = "post_map_expr";
static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_reduce_kernel[] = "reduce_kernel";
static const char __pyx_k_repeated_axis[] = "repeated axis";
static const char __pyx_k_routine_cache[] = "_routine_cache";
static const char __pyx_k_type_preamble[] = "type_preamble";
static const char __pyx_k_unknown_ctype[] = "unknown_ctype";
static const char __pyx_k_unsigned_char[] = "unsigned char";
static const char __pyx_k_x_mean_x_mean[] = "(x - mean) * (x - mean)";
static const char __pyx_k_0_1__raw__1__i[] = "{0} &{1} = _raw_{1}[_i];";
static const char __pyx_k_AttributeError[] = "AttributeError";
static const char __pyx_k_ComplexWarning[] = "ComplexWarning";
static const char __pyx_k_NotImplemented[] = "NotImplemented";
static const char __pyx_k_Syntax_error_s[] = "Syntax error: %s";
static const char __pyx_k_all_type_chars[] = "all_type_chars";
static const char __pyx_k_array_priority[] = "__array_priority__";
static const char __pyx_k_asfortranarray[] = "asfortranarray";
static const char __pyx_k_complex_double[] = "complex<double>";
static const char __pyx_k_cupy_core_core[] = "cupy.core.core";
static const char __pyx_k_cupy_remainder[] = "cupy_remainder";
static const char __pyx_k_get_param_info[] = "_get_param_info";
static const char __pyx_k_nonzero_kernel[] = "_nonzero_kernel";
static const char __pyx_k_out0_fabsf_in0[] = "out0 = fabsf(in0)";
static const char __pyx_k_out0_in0_s_in1[] = "out0 = in0 %s in1";
static const char __pyx_k_out_args_dtype[] = "out_args_dtype";
static const char __pyx_k_sum_auto_dtype[] = "_sum_auto_dtype";
static const char __pyx_k_sum_keep_dtype[] = "_sum_keep_dtype";
static const char __pyx_k_thrust_enabled[] = "thrust_enabled";
static const char __pyx_k_types_preamble[] = "types_preamble";
static const char __pyx_k_unsigned_short[] = "unsigned short";
static const char __pyx_k_Invalid_dtype_s[] = "Invalid dtype: %s";
static const char __pyx_k_ReductionKernel[] = "ReductionKernel";
static const char __pyx_k_View_MemoryView[] = "View.MemoryView";
static const char __pyx_k_allocate_buffer[] = "allocate_buffer";
static const char __pyx_k_bhilqBHILQefdFD[] = "?bhilqBHILQefdFD";
static const char __pyx_k_complexfloating[] = "complexfloating";
static const char __pyx_k_cupy_carray_cuh[] = "cupy/carray.cuh";
static const char __pyx_k_cupy_copy_where[] = "cupy_copy_where";
static const char __pyx_k_cupy_take_0axis[] = "cupy_take_0axis";
static const char __pyx_k_default_casting[] = "default_casting";
static const char __pyx_k_dtype_is_object[] = "dtype_is_object";
static const char __pyx_k_for_each_device[] = "for_each_device";
static const char __pyx_k_if_in1_out0_in0[] = "if (in1) out0 = in0";
static const char __pyx_k_prod_auto_dtype[] = "_prod_auto_dtype";
static const char __pyx_k_prod_keep_dtype[] = "_prod_keep_dtype";
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_cupy_atomics_cuh[] = "cupy/atomics.cuh";
static const char __pyx_k_cupy_choose_clip[] = "cupy_choose_clip";
static const char __pyx_k_cupy_complex_cuh[] = "cupy/complex.cuh";
static const char __pyx_k_cupy_concatenate[] = "cupy_concatenate";
static const char __pyx_k_cupy_imag_setter[] = "cupy_imag_setter";
static const char __pyx_k_cupy_real_setter[] = "cupy_real_setter";
static const char __pyx_k_cupy_scatter_add[] = "cupy_scatter_add";
static const char __pyx_k_cupy_true_divide[] = "cupy_true_divide";
static const char __pyx_k_elementwise_copy[] = "elementwise_copy";
static const char __pyx_k_find_common_type[] = "find_common_type";
static const char __pyx_k_get_as_parameter[] = "get_as_parameter";
static const char __pyx_k_get_ufunc_kernel[] = "_get_ufunc_kernel";
static const char __pyx_k_in_ndarray_types[] = "in_ndarray_types";
static const char __pyx_k_my_max_float_a_b[] = "my_max_float(a, b)";
static const char __pyx_k_my_min_float_a_b[] = "my_min_float(a, b)";
static const char __pyx_k_nonzero_kernel_2[] = "nonzero_kernel";
static const char __pyx_k_out0_pow_in0_in1[] = "out0 = pow(in0, in1)";
static const char __pyx_k_partition_kernel[] = "_partition_kernel";
static const char __pyx_k_Axis_exceeds_ndim[] = "Axis exceeds ndim";
static const char __pyx_k_Axis_out_of_range[] = "Axis out of range";
static const char __pyx_k_IndexOrValueError[] = "IndexOrValueError";
static const char __pyx_k_Unknown_keyword_s[] = "Unknown keyword \"%s\"";
static const char __pyx_k_Wrong_arguments_s[] = "Wrong arguments %s";
static const char __pyx_k_ascontiguousarray[] = "ascontiguousarray";
static const char __pyx_k_cupy_floor_divide[] = "cupy_floor_divide";
static const char __pyx_k_cupy_getitem_mask[] = "cupy_getitem_mask";
static const char __pyx_k_default_casting_2[] = "_default_casting";
static const char __pyx_k_kth_out_of_bounds[] = "kth(={}) out of bounds {}";
static const char __pyx_k_nonzero_1d_kernel[] = "_nonzero_1d_kernel";
static const char __pyx_k_out0_in0_0_0_M_PI[] = "out0 = in0 >= 0 ? 0 : M_PI";
static const char __pyx_k_out0_powf_in0_in1[] = "out0 = powf(in0, in1)";
static const char __pyx_k_out_ndarray_types[] = "out_ndarray_types";
static const char __pyx_k_pyx_unpickle_Enum[] = "__pyx_unpickle_Enum";
static const char __pyx_k_requires_a_ndim_1[] = "requires a.ndim >= 1";
static const char __pyx_k_update_contiguity[] = "_update_contiguity";
static const char __pyx_k_Illegal_conditions[] = "Illegal conditions";
static const char __pyx_k_S_x_T_mean_T_alpha[] = "S x, T mean, T alpha";
static const char __pyx_k_Unsupported_type_s[] = "Unsupported type %s";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_compile_with_cache[] = "compile_with_cache";
static const char __pyx_k_cupy_core_core_pyx[] = "cupy/core/core.pyx";
static const char __pyx_k_decide_params_type[] = "_decide_params_type";
static const char __pyx_k_in0_type_in0_raw_0[] = "in0 != type_in0_raw(0)";
static const char __pyx_k_incompatible_shape[] = "incompatible shape";
static const char __pyx_k_index_out_of_range[] = "index out of range";
static const char __pyx_k_out0_in0_0_in0_in0[] = "out0 = in0 > 0 ? in0 : -in0";
static const char __pyx_k_out0_out0_type_in0[] = "out0 = out0_type(in0)";
static const char __pyx_k_partition_kernel_2[] = "partition_kernel";
static const char __pyx_k_raw_P_x_int64_base[] = "raw P x, int64 base";
static const char __pyx_k_strided_and_direct[] = "<strided and direct>";
static const char __pyx_k_unsigned_long_long[] = "unsigned long long";
static const char __pyx_k_Broadcasting_failed[] = "Broadcasting failed";
static const char __pyx_k_Cannot_use_out_in_s[] = "Cannot use 'out' in %s";
static const char __pyx_k_NotImplementedError[] = "NotImplementedError";
static const char __pyx_k_Unsupported_dtype_s[] = "Unsupported dtype %s";
static const char __pyx_k_cgemmStridedBatched[] = "cgemmStridedBatched";
static const char __pyx_k_cupy_complex_cexp_h[] = "cupy/complex/cexp.h";
static const char __pyx_k_cupy_complex_clog_h[] = "cupy/complex/clog.h";
static const char __pyx_k_cupy_complex_cpow_h[] = "cupy/complex/cpow.h";
static const char __pyx_k_cupy_scatter_update[] = "cupy_scatter_update";
static const char __pyx_k_cupy_sum_with_dtype[] = "cupy_sum_with_dtype";
static const char __pyx_k_dgemmStridedBatched[] = "dgemmStridedBatched";
static const char __pyx_k_indices_or_sections[] = "indices_or_sections";
static const char __pyx_k_int32__block_stride[] = "int32 _block_stride";
static const char __pyx_k_my_argmax_float_a_b[] = "my_argmax_float(a, b)";
static const char __pyx_k_my_argmin_float_a_b[] = "my_argmin_float(a, b)";
static const char __pyx_k_nonzero_1d_kernel_2[] = "nonzero_1d_kernel";
static const char __pyx_k_sgemmStridedBatched[] = "sgemmStridedBatched";
static const char __pyx_k_typedef_s_in_d_type[] = "typedef %s in%d_type;";
static const char __pyx_k_update_c_contiguity[] = "_update_c_contiguity";
static const char __pyx_k_update_f_contiguity[] = "_update_f_contiguity";
static const char __pyx_k_zgemmStridedBatched[] = "zgemmStridedBatched";
static const char __pyx_k_Invalid_axes_value_s[] = "Invalid axes value: %s";
static const char __pyx_k_Invalid_index_type_s[] = "Invalid index type: %s";
static const char __pyx_k_axis_out_of_bounds_0[] = "axis {} out of bounds [0, {})";
static const char __pyx_k_const_0_1__raw__1__j[] = "const {0} {1} = _raw_{1}[_j];";
static const char __pyx_k_cupy_complex_ccosh_h[] = "cupy/complex/ccosh.h";
static const char __pyx_k_cupy_complex_cexpf_h[] = "cupy/complex/cexpf.h";
static const char __pyx_k_cupy_complex_clogf_h[] = "cupy/complex/clogf.h";
static const char __pyx_k_cupy_complex_cproj_h[] = "cupy/complex/cproj.h";
static const char __pyx_k_cupy_complex_csinh_h[] = "cupy/complex/csinh.h";
static const char __pyx_k_cupy_complex_csqrt_h[] = "cupy/complex/csqrt.h";
static const char __pyx_k_cupy_complex_ctanh_h[] = "cupy/complex/ctanh.h";
static const char __pyx_k_cupy_prod_with_dtype[] = "cupy_prod_with_dtype";
static const char __pyx_k_get_reduction_kernel[] = "_get_reduction_kernel";
static const char __pyx_k_is_valid_kernel_name[] = "is_valid_kernel_name";
static const char __pyx_k_order_not_understood[] = "order not understood";
static const char __pyx_k_out0_type_out0_raw_a[] = "out0 = type_out0_raw(a)";
static const char __pyx_k_pyx_unpickle_Indexer[] = "__pyx_unpickle_Indexer";
static const char __pyx_k_strided_and_indirect[] = "<strided and indirect>";
static const char __pyx_k_t_n__raw__n__ind_get[] = "{t} &{n} = _raw_{n}[_ind.get()];";
static const char __pyx_k_typedef_s_out_d_type[] = "typedef %s out%d_type;";
static const char __pyx_k_Invalid_kernel_name_s[] = "Invalid kernel name: \"%s\"";
static const char __pyx_k_Output_dtype_mismatch[] = "Output dtype mismatch";
static const char __pyx_k_Output_shape_mismatch[] = "Output shape mismatch";
static const char __pyx_k_contiguous_and_direct[] = "<contiguous and direct>";
static const char __pyx_k_cupy_complex_catrig_h[] = "cupy/complex/catrig.h";
static const char __pyx_k_cupy_complex_ccoshf_h[] = "cupy/complex/ccoshf.h";
static const char __pyx_k_cupy_complex_csinhf_h[] = "cupy/complex/csinhf.h";
static const char __pyx_k_cupy_complex_csqrtf_h[] = "cupy/complex/csqrtf.h";
static const char __pyx_k_cupy_complex_ctanhf_h[] = "cupy/complex/ctanhf.h";
static const char __pyx_k_cupy_scatter_add_mask[] = "cupy_scatter_add_mask";
static const char __pyx_k_inclusive_scan_kernel[] = "inclusive_scan_kernel";
static const char __pyx_k_len_of_unsized_object[] = "len() of unsized object";
static const char __pyx_k_len_shape_len_strides[] = "len(shape) != len(strides)";
static const char __pyx_k_set_shape_and_strides[] = "_set_shape_and_strides";
static const char __pyx_k_update_c_contiguity_2[] = "update_c_contiguity";
static const char __pyx_k_Loop_size_is_Undecided[] = "Loop size is Undecided";
static const char __pyx_k_MemoryView_of_r_object[] = "<MemoryView of %r object>";
static const char __pyx_k_ReductionKernel___call[] = "ReductionKernel.__call__";
static const char __pyx_k_ReductionKernel___init[] = "ReductionKernel.__init__";
static const char __pyx_k_cupy_complex_catrigf_h[] = "cupy/complex/catrigf.h";
static const char __pyx_k_cupy_complex_complex_h[] = "cupy/complex/complex.h";
static const char __pyx_k_elementwise_copy_where[] = "elementwise_copy_where";
static const char __pyx_k_get_elementwise_kernel[] = "_get_elementwise_kernel";
static const char __pyx_k_partition_merge_kernel[] = "partition_merge_kernel";
static const char __pyx_k_pyx_unpickle_broadcast[] = "__pyx_unpickle_broadcast";
static const char __pyx_k_require_sortable_dtype[] = "require_sortable_dtype";
static const char __pyx_k_shapes_and_not_aligned[] = "shapes ({}) and ({}) not aligned";
static const char __pyx_k_tensordot_core_mul_sum[] = "_tensordot_core_mul_sum";
static const char __pyx_k_Axis_dimension_mismatch[] = "Axis dimension mismatch";
static const char __pyx_k_MemoryView_of_r_at_0x_x[] = "<MemoryView of %r at 0x%x>";
static const char __pyx_k_Out_shape_is_mismatched[] = "Out shape is mismatched";
static const char __pyx_k_clipmode_not_understood[] = "clipmode not understood";
static const char __pyx_k_contiguous_and_indirect[] = "<contiguous and indirect>";
static const char __pyx_k_cupy_core_reduction_pxi[] = "cupy/core/reduction.pxi";
static const char __pyx_k_duplicate_value_in_axis[] = "duplicate value in 'axis'";
static const char __pyx_k_inclusive_scan_kernel_2[] = "_inclusive_scan_kernel";
static const char __pyx_k_min_max_st_type_in0_raw[] = "min_max_st<type_in0_raw>";
static const char __pyx_k_y_choices_i_n_channel_a[] = "y = choices[i + n_channel * a]";
static const char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'";
static const char __pyx_k_IndexOrValueError___init[] = "IndexOrValueError.__init__";
static const char __pyx_k_Please_set_the_CUDA_path[] = "Please set the CUDA path ";
static const char __pyx_k_Type_is_mismatched_s_s_s[] = "Type is mismatched. %s %s %s";
static const char __pyx_k_cupy_scatter_update_mask[] = "cupy_scatter_update_mask";
static const char __pyx_k_this_op_is_not_supported[] = "this op is not supported";
static const char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d.";
static const char __pyx_k_cupy_complex_arithmetic_h[] = "cupy/complex/arithmetic.h";
static const char __pyx_k_cupy_core_elementwise_pxi[] = "cupy/core/elementwise.pxi";
static const char __pyx_k_same_shape_and_contiguous[] = "same_shape_and_contiguous";
static const char __pyx_k_simple_reduction_function[] = "simple_reduction_function";
static const char __pyx_k_Type_is_mismatched_s_s_s_s[] = "Type is mismatched. %s %s %s %s";
static const char __pyx_k_cupy_complex_complex_inl_h[] = "cupy/complex/complex_inl.h";
static const char __pyx_k_cupy_concatenate_same_size[] = "cupy_concatenate_same_size";
static const char __pyx_k_if_mask_a_v_mask_scanned_1[] = "if (mask) a = v[mask_scanned - 1]";
static const char __pyx_k_order_not_understood_order[] = "order not understood. order={}";
static const char __pyx_k_out0__floor_divide_in0_in1[] = "out0 = _floor_divide(in0, in1)";
static const char __pyx_k_pyx_unpickle_ParameterInfo[] = "__pyx_unpickle_ParameterInfo";
static const char __pyx_k_subok_is_not_supported_yet[] = "subok is not supported yet";
static const char __pyx_k_too_many_indices_for_array[] = "too many indices for array";
static const char __pyx_k_add_scan_blocked_sum_kernel[] = "add_scan_blocked_sum_kernel";
static const char __pyx_k_cupy_complex_math_private_h[] = "cupy/complex/math_private.h";
static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array";
static const char __pyx_k_min_max_st_type_in0_raw_in0[] = "min_max_st<type_in0_raw>(in0)";
static const char __pyx_k_T_a_bool_mask_S_mask_scanned[] = "T a, bool mask, S mask_scanned";
static const char __pyx_k_array_cannot_be_set_to_array[] = "{} array cannot be set to {} array";
static const char __pyx_k_casting_is_not_supported_yet[] = "casting is not supported yet";
static const char __pyx_k_if_mask_a_a_v_mask_scanned_1[] = "if (mask) a = a + v[mask_scanned - 1]";
static const char __pyx_k_if_mask_out_mask_scanned_1_a[] = "if (mask) out[mask_scanned - 1] = a";
static const char __pyx_k_provided_op_is_not_supported[] = "provided op is not supported";
static const char __pyx_k_template_typename_T___device[] = "\n    template<typename T>\n    __device__ void bitonic_sort_step(CArray<T, 1> a,\n            ptrdiff_t x, ptrdiff_t y, int i, ptrdiff_t s, ptrdiff_t w) {\n        for (ptrdiff_t j = i; j < (y - x) / 2; j += 32) {\n            ptrdiff_t n = j + (j & -w);\n            T v = a[n + x], u = a[n + w + x];\n            if (n & s ? v < u : v > u) {\n                a[n + x] = u;\n                a[n + w + x] = v;\n            }\n        }\n    }\n\n    // Sort a[x:y].\n    template<typename T>\n    __device__ void bitonic_sort(\n            CArray<T, 1> a, ptrdiff_t x, ptrdiff_t y, int i) {\n        for (ptrdiff_t s = 2; s <= y - x; s *= 2) {\n            for (ptrdiff_t w = s / 2; w >= 1; w /= 2) {\n                bitonic_sort_step<T>(a, x, y, i, s, w);\n            }\n        }\n    }\n\n    // Merge first k elements and the next 32 times t elements.\n    template<typename T>\n    __device__ void merge(\n            CArray<T, 1> a, int k, int i, ptrdiff_t x, ptrdiff_t z, int u) {\n        for (int s = i; s < u; s += 32) {\n            if (a[x + k - s - 1] > a[z + s]) {\n                T tmp = a[x + k - s - 1];\n                a[x + k - s - 1] = a[z + s];\n                a[z + s] = tmp;\n            }\n        }\n\n        // After merge step, the first k elements are already bitonic.\n        // Therefore, we do not need to fully sort.\n        for (int w = k / 2; w >= 1; w /= 2) {\n            bitonic_sort_step<T>(a, x, k + x, i, k, w);\n        }\n    }\n\n    extern \"C\" {\n    // In this function, 32 threads handle one subarray. This number equals to\n    // the warp size. The first k elements are always sorted and the next 32\n    // times t elements stored values that have possibilities to be selected.\n    __global__ void ${name}(\n            CArray<${dtype}, 1> a, int k, ptrdiff_t n, int t, ptrdiff_t sz) {\n\n        // This thread handles a[z:m].\n        ptrdiff_t i = static_cast<ptrdiff_t>(blockIdx.x) * blockDim.x\n            + threadIdx.x;\n        ptr""diff_t z = i / 32 * n / sz;\n        ptrdiff_t m = (i / 32 + 1) * n / sz;\n        int id = i % 32;\n        int x = 0;\n\n        bitonic_sort<${dtype}>(a, z, k + z, id);\n        ptrdiff_t j;\n        for (j = k + id + z; j < m - (m - z) % 32; j += 32) {\n            if (a[j] < a[k - 1 + z]) {\n                ${dtype} tmp = a[k + 32 * x + id + z];\n                a[k + 32 * x + id + z] = a[j];\n                a[j] = tmp;\n                ++x;\n            }\n\n            // If at least one thread in the warp has found t values that\n            // can be selected, we update the first k elements.\n    #if __CUDACC_VER_MAJOR__ >= 9\n            if (__any_sync(0xffffffff, x >= t)) {\n    #else\n            if (__any(x >= t)) {\n    #endif\n                bitonic_sort<${dtype}>(a, k + z, 32 * t + k + z, id);\n                merge<${dtype}>(a, k, id, z, k + z, min(k, 32 * t));\n                x = 0;\n            }\n        }\n        if (j < m && a[j] < a[k - 1 + z]) {\n            ${dtype} tmp = a[k + 32 * x + id + z];\n            a[k + 32 * x + id + z] = a[j];\n            a[j] = tmp;\n        }\n\n        // Finally, we merge the first k elements and the remainders to be\n        // stored.\n        bitonic_sort<${dtype}>(a, k + z, 32 * t + k + z, id);\n        merge<${dtype}>(a, k, id, z, k + z, min(k, 32 * t));\n    }\n\n    __global__ void ${merge_kernel}(\n            CArray<${dtype}, 1> a, int k, ptrdiff_t n, int sz, int s) {\n        ptrdiff_t i = static_cast<ptrdiff_t>(blockIdx.x) * blockDim.x\n            + threadIdx.x;\n        ptrdiff_t z = i / 32 * 2 * s * n / sz;\n        ptrdiff_t m = (i / 32 * 2 + 1) * s * n / sz;\n        int id = i % 32;\n        merge<${dtype}>(a, k, id, z, m, k);\n    }\n    }\n    ";
  static const char __pyx_k_add_scan_blocked_sum_kernel_2[] = "_add_scan_blocked_sum_kernel";
  static const char __pyx_k_get_simple_elementwise_kernel[] = "_get_simple_elementwise_kernel";
  static const char __pyx_k_get_simple_reduction_function[] = "_get_simple_reduction_function";
  static const char __pyx_k_invalid_entry_in_choice_array[] = "invalid entry in choice array";
  static const char __pyx_k_ndarray___getitem___line_1507[] = "ndarray.__getitem__ (line 1507)";
  static const char __pyx_k_ndarray___setitem___line_1553[] = "ndarray.__setitem__ (line 1553)";
  static const char __pyx_k_ufunc___init___locals_genexpr[] = "ufunc.__init__.<locals>.genexpr";
  static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data.";
  static const char __pyx_k_Input_array_should_be_1D_array[] = "Input array should be 1D array.";
  static const char __pyx_k_Output_array_size_is_Undecided[] = "Output array size is Undecided";
  static const char __pyx_k_Provided_out_is_the_wrong_size[] = "Provided out is the wrong size";
  static const char __pyx_k_S_wrap_indices_indices_adim_if[] = "\n      S wrap_indices = indices % adim;\n      if (wrap_indices < 0) wrap_indices += adim;\n      ptrdiff_t li = i / (rdim * cdim);\n      ptrdiff_t ri = i % rdim;\n      a[(li * adim + wrap_indices) * rdim + ri] = v;\n    ";
  static const char __pyx_k_S_x_a_if_a_0_x_0_else_if_a_n_x[] = "\n      S x = a;\n      if (a < 0) {\n        x = 0;\n      } else if (a >= n) {\n        x = n - 1;\n      }\n      y = choices[i + n_channel * x];\n    ";
  static const char __pyx_k_min_max_st_type_in0_raw_in0__J[] = "min_max_st<type_in0_raw>(in0, _J)";
  static const char __pyx_k_pyx_unpickle_ElementwiseKernel[] = "__pyx_unpickle_ElementwiseKernel";
  static const char __pyx_k_repeats_should_not_be_negative[] = "'repeats' should not be negative: {}";
  static const char __pyx_k_strided_and_direct_or_indirect[] = "<strided and direct or indirect>";
  static const char __pyx_k_template_typename_T_struct_min[] = "\ntemplate <typename T>\nstruct min_max_st{\n    T value;\n    int index;\n    __device__ min_max_st() : index(-1) { }\n    __device__ min_max_st(T v) : value(v), index(0) { }\n    __device__ min_max_st(T v, int i) : value(v), index(i) { }\n};\n\ntemplate <typename T>\ninline __device__ bool is_nan(T x) {\n    return x != x;\n}\n\ntemplate <typename T>\n__device__ min_max_st<T> my_min(\n        const min_max_st<T>& a, const min_max_st<T>& b) {\n    if (a.index == -1) return b;\n    if (b.index == -1) return a;\n    return min_max_st<T>(min(a.value, b.value));\n}\ntemplate <typename T>\n__device__ min_max_st<T> my_min_float(\n        const min_max_st<T>& a, const min_max_st<T>& b) {\n    if (a.index == -1) return b;\n    if (b.index == -1) return a;\n    if (is_nan(a.value)) return a;\n    if (is_nan(b.value)) return b;\n    return min_max_st<T>(min(a.value, b.value));\n}\n\ntemplate <typename T>\n__device__ min_max_st<T> my_max(\n        const min_max_st<T>& a, const min_max_st<T>& b) {\n    if (a.index == -1) return b;\n    if (b.index == -1) return a;\n    return min_max_st<T>(max(a.value, b.value));\n}\ntemplate <typename T>\n__device__ min_max_st<T> my_max_float(\n        const min_max_st<T>& a, const min_max_st<T>& b) {\n    if (a.index == -1) return b;\n    if (b.index == -1) return a;\n    if (is_nan(a.value)) return a;\n    if (is_nan(b.value)) return b;\n    return min_max_st<T>(max(a.value, b.value));\n}\n\ntemplate <typename T>\n__device__ min_max_st<T> my_argmin(\n        const min_max_st<T>& a, const min_max_st<T>& b) {\n    if (a.index == -1) return b;\n    if (b.index == -1) return a;\n    if (a.value == b.value)\n        return min_max_st<T>(a.value, min(a.index, b.index));\n    return (a.value <= b.value) ? a : b;\n}\ntemplate <typename T>\n__device__ min_max_st<T> my_argmin_float(\n        const min_max_st<T>& a, const min_max_st<T>& b) {\n    if (a.index == -1) return b;\n    if (b.index == -1) return a;\n    if (a.value == b.value)\n        retur""n min_max_st<T>(a.value, min(a.index, b.index));\n    if (is_nan(a.value)) return a;\n    if (is_nan(b.value)) return b;\n    return (a.value <= b.value) ? a : b;\n}\n\ntemplate <typename T>\n__device__ min_max_st<T> my_argmax(\n        const min_max_st<T>& a, const min_max_st<T>& b) {\n    if (a.index == -1) return b;\n    if (b.index == -1) return a;\n    if (a.value == b.value)\n        return min_max_st<T>(a.value, min(a.index, b.index));\n    return (a.value >= b.value) ? a : b;\n}\ntemplate <typename T>\n__device__ min_max_st<T> my_argmax_float(\n        const min_max_st<T>& a, const min_max_st<T>& b) {\n    if (a.index == -1) return b;\n    if (b.index == -1) return a;\n    if (a.value == b.value)\n        return min_max_st<T>(a.value, min(a.index, b.index));\n    if (is_nan(a.value)) return a;\n    if (is_nan(b.value)) return b;\n    return (a.value >= b.value) ? a : b;\n}\n";
  static const char __pyx_k_All_arrays_must_have_same_shape[] = "All arrays must have same shape except the axis to concatenate";
  static const char __pyx_k_Computes_the_bitwise_AND_of_two[] = "Computes the bitwise AND of two arrays elementwise.\n\n    Only integer and boolean arrays are handled.\n\n    .. seealso:: :data:`numpy.bitwise_and`\n\n    ";
  static const char __pyx_k_Computes_the_bitwise_XOR_of_two[] = "Computes the bitwise XOR of two arrays elementwise.\n\n    Only integer and boolean arrays are handled.\n\n    .. seealso:: :data:`numpy.bitwise_xor`\n\n    ";
  static const char __pyx_k_Not_supported_dtype_combination[] = "Not supported dtype combination.";
  static const char __pyx_k_S_wrap_indices_indices_index_ra[] = "\n      S wrap_indices = indices % index_range;\n      if (wrap_indices < 0) wrap_indices += index_range;\n\n      ptrdiff_t li = i / (rdim * cdim);\n      ptrdiff_t ri = i % rdim;\n      out = a[(li * adim + wrap_indices) * rdim + ri];\n    ";
  static const char __pyx_k_Scalar_operands_are_not_allowed[] = "Scalar operands are not allowed, use '*' instead";
  static const char __pyx_k_Shifts_the_bits_of_each_integer[] = "Shifts the bits of each integer element to the left.\n\n    Only integer arrays are handled.\n\n    .. seealso:: :data:`numpy.left_shift`\n\n    ";
  static const char __pyx_k_Sorting_arrays_with_the_rank_of[] = "Sorting arrays with the rank of zero is not supported";
  static const char __pyx_k_Sorting_non_contiguous_array_is[] = "Sorting non-contiguous array is not supported.";
  static const char __pyx_k_Specified_size_can_be_used_only[] = "Specified 'size' can be used only if all of the ndarray are 'raw'.";
  static const char __pyx_k_Subtracts_arguments_elementwise[] = "Subtracts arguments elementwise.\n\n    .. seealso:: :data:`numpy.subtract`\n\n    ";
  static const char __pyx_k_Variance_for_complex_numbers_is[] = "Variance for complex numbers is not implemented. Current implemention does not convert the dtype";
  static const char __pyx_k_Wrong_number_of_arguments_for_s[] = "Wrong number of arguments for %s";
  static const char __pyx_k_Wrong_type_s_of_arguments_for_s[] = "Wrong type (%s) of arguments for %s";
  static const char __pyx_k_axis_entry_d_is_out_of_bounds_d[] = "'axis' entry %d is out of bounds [-%d, %d)";
  static const char __pyx_k_axis_is_out_of_bounds_for_array[] = "axis {} is out of bounds for array of dimension {}";
  static const char __pyx_k_const_in_0__type_in_0__raw_in_0[] = "const in{0}_type in{0}(_raw_in{0}[_ind.get()]);";
  static const char __pyx_k_const_type_in0_raw_in0__raw_in0[] = "const type_in0_raw in0 = _raw_in0[_in_ind.get()];";
  static const char __pyx_k_extern_C___global___void_name_C[] = "\n    extern \"C\" __global__ void ${name}(CArray<${dtype}, 1> src_dst){\n        long long n = src_dst.size();\n        unsigned int idxBase = (blockDim.x + 1) * (blockIdx.x + 1);\n        unsigned int idxAdded = idxBase + threadIdx.x;\n        unsigned int idxAdd = idxBase - 1;\n\n        if(idxAdded < n){\n            src_dst[idxAdded] += src_dst[idxAdd];\n        }\n    }\n    ";
  static const char __pyx_k_extern_C___global___void_name_c[] = "\n    extern \"C\" __global__ void ${name}(const CArray<${dtype}, 1> src,\n        CArray<${dtype}, 1> dst){\n        long long n = src.size();\n        extern __shared__ ${dtype} temp[];\n        unsigned int thid = threadIdx.x;\n        unsigned int block = 2 * blockIdx.x * blockDim.x;\n\n        unsigned int idx0 = thid + block;\n        unsigned int idx1 = thid + blockDim.x + block;\n\n        temp[thid] = (idx0 < n) ? src[idx0] : (${dtype})0;\n        temp[thid + blockDim.x] = (idx1 < n) ? src[idx1] : (${dtype})0;\n        __syncthreads();\n\n        for(int i = 1; i <= ${block_size}; i <<= 1){\n            int index = (threadIdx.x + 1) * i * 2 - 1;\n            if (index < (${block_size} << 1)){\n                temp[index] = temp[index] + temp[index - i];\n            }\n            __syncthreads();\n        }\n\n        for(int i = ${block_size} >> 1; i > 0; i >>= 1){\n            int index = (threadIdx.x + 1) * i * 2 - 1;\n            if(index + i < (${block_size} << 1)){\n                temp[index + i] = temp[index + i] + temp[index];\n            }\n            __syncthreads();\n        }\n\n        if(idx0 < n){\n            dst[idx0] = temp[thid];\n        }\n        if(idx1 < n){\n            dst[idx1] = temp[thid + blockDim.x];\n        }\n    }\n    ";
  static const char __pyx_k_get_elementwise_kernel_locals_g[] = "_get_elementwise_kernel.<locals>.genexpr";
  static const char __pyx_k_get_reduction_kernel_locals_gen[] = "_get_reduction_kernel.<locals>.genexpr";
  static const char __pyx_k_if_in1_0_out0_0_out1_0_else_out[] = "\n    if (in1 == 0) {\n        out0 = 0;\n        out1 = 0;\n    } else {\n        out0_type a = _floor_divide(in0, in1);\n        out0 = a;\n        out1 = in0 - a * in1;\n    }";
  static const char __pyx_k_non_scalar_numpy_ndarray_cannot[] = "non-scalar numpy.ndarray cannot be used for fill";
  static const char __pyx_k_operands_could_not_be_broadcast[] = "operands could not be broadcast together with remapped shapes";
  static const char __pyx_k_out0_rint_pow_double_in0_double[] = "out0 = rint(pow((double)in0, (double)in1))";
  static const char __pyx_k_out0_type_a__floor_divide_in0_i[] = "\n    out0_type a = _floor_divide(in0, in1);\n    out0 = a;\n    out1 = in0 - a * in1";
  static const char __pyx_k_preamble_extern_C___global___vo[] = "\n    ${preamble}\n    extern \"C\" __global__ void ${name}(${params}) {\n      ${loop_prep};\n      CUPY_FOR(i, _ind.size()) {\n        _ind.set(i);\n        ${operation};\n      }\n      ${after_loop};\n    }\n    ";
  static const char __pyx_k_ptrdiff_t_axis_ind__ind_get_axi[] = "\n    ptrdiff_t axis_ind = _ind.get()[axis];\n    ptrdiff_t left = 0;\n    ptrdiff_t right = cum_sizes.size();\n\n    while (left < right - 1) {\n      ptrdiff_t m = (left + right) / 2;\n      if (axis_ind < cum_sizes[m]) {\n        right = m;\n      } else {\n        left = m;\n      }\n    }\n\n    ptrdiff_t array_ind = left;\n    axis_ind -= cum_sizes[left];\n    char* ptr = reinterpret_cast<char*>(x[array_ind]);\n    for (int j = _ind.ndim - 1; j >= 0; --j) {\n      ptrdiff_t ind[] = {array_ind, j};\n      ptrdiff_t offset;\n      if (j == axis) {\n        offset = axis_ind;\n      } else {\n        offset = _ind.get()[j];\n      }\n      ptr += x_strides[ind] * offset;\n    }\n\n    y = *reinterpret_cast<T*>(ptr);\n    ";
  static const char __pyx_k_ptrdiff_t_middle_i_base_ptrdiff[] = "\n    ptrdiff_t middle = i / base;\n    ptrdiff_t top = middle / x.size();\n    ptrdiff_t array_ind = middle - top * x.size();\n    ptrdiff_t offset = i + (top - middle) * base;\n    y = reinterpret_cast<T*>(x[array_ind])[offset];\n    ";
  static const char __pyx_k_repeats_and_axis_of_a_should_be[] = "'repeats' and 'axis' of 'a' should be same length: {} != {}";
  static const char __pyx_k_repeats_should_be_int_or_sequen[] = "'repeats' should be int or sequence: {}";
  static const char __pyx_k_scatter_add_only_supports_int32[] = "scatter_add only supports int32, float32, uint32, uint64 as data type";
  static const char __pyx_k_self_ptr_cannot_be_converted_to[] = "self.ptr cannot be converted to a Python object for pickling";
  static const char __pyx_k_source_and_destination_argument[] = "`source` and `destination` arguments must have the same number of elements";
  static const char __pyx_k_static_cast_U_x_static_cast_U_y[] = "static_cast<U>(x) * static_cast<U>(y)";
  static const char __pyx_k_total_size_of_new_array_must_be[] = "total size of new array must be unchanged";
  static const char __pyx_k_type_preamble_preamble_define_R[] = "\n    ${type_preamble}\n    ${preamble}\n    #define REDUCE(a, b) (${reduce_expr})\n    #define POST_MAP(a) (${post_map_expr})\n    #define _REDUCE(_offset) if (_tid < _offset) {       _type_reduce _a = _sdata[_tid], _b = _sdata[(_tid + _offset)];       _sdata[_tid] = REDUCE(_a, _b);     }\n\n    typedef ${reduce_type} _type_reduce;\n    extern \"C\" __global__ void ${name}(${params}) {\n      extern __shared__ _type_reduce _sdata_raw[];\n      _type_reduce *_sdata = _sdata_raw;\n      unsigned int _tid = threadIdx.x;\n\n      int _J_offset = _tid / _block_stride;\n      int _j_offset = _J_offset * _out_ind.size();\n      int _J_stride = ${block_size} / _block_stride;\n      long long _j_stride = (long long)_J_stride * _out_ind.size();\n\n      for (int _i_base = blockIdx.x * _block_stride;\n           _i_base < _out_ind.size();\n           _i_base += gridDim.x * _block_stride) {\n        _type_reduce _s = _type_reduce(${identity});\n        int _i = _i_base + _tid % _block_stride;\n        int _J = _J_offset;\n        for (long long _j = _i + _j_offset; _j < _in_ind.size();\n             _j += _j_stride, _J += _J_stride) {\n          _in_ind.set(_j);\n          ${input_expr}\n          _type_reduce _a = static_cast<_type_reduce>(${pre_map_expr});\n          _s = REDUCE(_s, _a);\n        }\n        if (_block_stride < ${block_size}) {\n          _sdata[_tid] = _s;\n          __syncthreads();\n          if (_block_stride <= 256) {\n            _REDUCE(256);\n            __syncthreads();\n            if (_block_stride <= 128) {\n              _REDUCE(128);\n              __syncthreads();\n              if (_block_stride <= 64) {\n                _REDUCE(64);\n                __syncthreads();\n                if (_block_stride <= 32) {\n                  _REDUCE(32);\n                  if (_block_stride <= 16) {\n                    _REDUCE(16);\n                    if (_block_stride <= 8) {\n                      _REDUCE(8);\n                      if (_block_stride <="" 4) {\n                        _REDUCE(4);\n                        if (_block_stride <= 2) {\n                          _REDUCE(2);\n                          if (_block_stride <= 1) {\n                            _REDUCE(1);\n                          }\n                        }\n                      }\n                    }\n                  }\n                }\n              }\n            }\n          }\n          _s = _sdata[_tid];\n          __syncthreads();\n        }\n        if (_J_offset == 0 && _i < _out_ind.size()) {\n          _out_ind.set(_i);\n          ${output_expr}\n          POST_MAP(_s);\n        }\n      }\n    }";
  static const char __pyx_k_x___setitem___slices_y_x_slices[] = "x.__setitem__(slices, y) <==> x[slices] = y\n\n        Supports both basic and advanced indexing.\n\n        .. note::\n\n            Currently, it does not support ``slices`` that consists of more\n            than one boolean arrays\n\n        .. note::\n\n            CuPy handles out-of-bounds indices differently from NumPy when\n            using integer array indexing.\n            NumPy handles them by raising an error, but CuPy wraps around them.\n\n            >>> import cupy\n            >>> x = cupy.arange(3)\n            >>> x[[1, 3]] = 10\n            >>> x\n            array([10, 10,  2])\n\n        .. note::\n\n            The behavior differs from NumPy when integer arrays in ``slices``\n            reference the same location multiple times.\n            In that case, the value that is actually stored is undefined.\n\n            >>> import cupy\n            >>> a = cupy.zeros((2,))\n            >>> i = cupy.arange(10000) % 2\n            >>> v = cupy.arange(10000).astype(cupy.float)\n            >>> a[i] = v\n            >>> a  # doctest: +SKIP\n            array([9150., 9151.])\n\n            On the other hand, NumPy stores the value corresponding to the\n            last index among the indices referencing duplicate locations.\n\n            >>> import numpy\n            >>> a_cpu = numpy.zeros((2,))\n            >>> i_cpu = numpy.arange(10000) % 2\n            >>> v_cpu = numpy.arange(10000).astype(numpy.float)\n            >>> a_cpu[i_cpu] = v_cpu\n            >>> a_cpu\n            array([9998., 9999.])\n\n        ";
  static const char __pyx_k_Adds_two_arrays_elementwise_seea[] = "Adds two arrays elementwise.\n\n    .. seealso:: :data:`numpy.add`\n\n    ";
  static const char __pyx_k_All_arrays_to_concatenate_must_h[] = "All arrays to concatenate must have the same ndim";
  static const char __pyx_k_Array_device_must_be_same_as_the[] = "Array device must be same as the current device: array device = %d while current = %d";
  static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides";
  static const char __pyx_k_CIndexer__in_ind_CIndexer__out_i[] = "CIndexer _in_ind, CIndexer _out_ind";
  static const char __pyx_k_Can_not_use_i_as_a_parameter_nam[] = "Can not use 'i' as a parameter name";
  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_concatenate_from_empty_tu[] = "Cannot concatenate from empty tuple";
  static const char __pyx_k_Cannot_create_writable_memory_vi[] = "Cannot create writable memory view from read-only memoryview";
  static const char __pyx_k_Cannot_set_to_non_contiguous_arr[] = "Cannot set to non-contiguous array";
  static const char __pyx_k_Cannot_specify_out_as_both_a_pos[] = "Cannot specify 'out' as both a positional and keyword argument";
  static const char __pyx_k_Casting_complex_values_to_real_d[] = "Casting complex values to real discards the imaginary part";
  static const char __pyx_k_Changing_the_dtype_of_a_0d_array[] = "Changing the dtype of a 0d array is only supported if the itemsize is unchanged";
  static const char __pyx_k_Computes_the_bitwise_NOT_of_an_a[] = "Computes the bitwise NOT of an array elementwise.\n\n    Only integer and boolean arrays are handled.\n\n    .. seealso:: :data:`numpy.invert`\n\n    ";
  static const char __pyx_k_Computes_the_bitwise_OR_of_two_a[] = "Computes the bitwise OR of two arrays elementwise.\n\n    Only integer and boolean arrays are handled.\n\n    .. seealso:: :data:`numpy.bitwise_or`\n\n    ";
  static const char __pyx_k_Computes_the_remainder_of_Python[] = "Computes the remainder of Python division elementwise.\n\n    .. seealso:: :data:`numpy.remainder`\n\n    ";
  static const char __pyx_k_Computes_x1_x2_elementwise_seeal[] = "Computes ``x1 ** x2`` elementwise.\n\n    .. seealso:: :data:`numpy.power`\n\n    ";
  static const char __pyx_k_Divides_arguments_elementwise_se[] = "Divides arguments elementwise.\n\n    .. seealso:: :data:`numpy.divide`\n\n    ";
  static const char __pyx_k_Elementwise_absolute_value_funct[] = "Elementwise absolute value function.\n\n    .. seealso:: :data:`numpy.absolute`\n\n    ";
  static const char __pyx_k_Elementwise_floor_division_i_e_i[] = "Elementwise floor division (i.e. integer quotient).\n\n    .. seealso:: :data:`numpy.floor_divide`\n\n    ";
  static const char __pyx_k_Elementwise_true_division_i_e_di[] = "Elementwise true division (i.e. division as floating values).\n\n    .. seealso:: :data:`numpy.true_divide`\n\n    ";
  static const char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array";
  static const char __pyx_k_Incompatible_checksums_s_vs_0x05[] = "Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))";
  static const char __pyx_k_Incompatible_checksums_s_vs_0x6d[] = "Incompatible checksums (%s vs 0x6d47339 = (shape, size))";
  static const char __pyx_k_Incompatible_checksums_s_vs_0x73[] = "Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))";
  static const char __pyx_k_Incompatible_checksums_s_vs_0x7d[] = "Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))";
  static const char __pyx_k_Incompatible_checksums_s_vs_0xb0[] = "Incompatible checksums (%s vs 0xb068931 = (name))";
  static const char __pyx_k_Index_s_is_out_of_bounds_for_axi[] = "Index %s is out of bounds for axis %s with size %s";
  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_Multiplies_two_arrays_elementwis[] = "Multiplies two arrays elementwise.\n\n    .. seealso:: :data:`numpy.multiply`\n\n    ";
  static const char __pyx_k_Negative_dimensions_are_not_allo[] = "Negative dimensions are not allowed";
  static const char __pyx_k_Only_cupy_arrays_can_be_concaten[] = "Only cupy arrays can be concatenated";
  static const char __pyx_k_Only_numpy_ndarray_can_be_set_to[] = "Only numpy.ndarray can be set to cupy.ndarray";
  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_Output_arguments_must_be_cupy_nd[] = "Output arguments must be cupy.ndarray";
  static const char __pyx_k_Output_arguments_type_must_be_cu[] = "Output arguments type must be cupy.ndarray";
  static const char __pyx_k_Output_array_has_an_invalid_size[] = "Output array has an invalid size";
  static const char __pyx_k_Output_array_must_be_C_contiguou[] = "Output array must be C-contiguous";
  static const char __pyx_k_Returns_the_angle_of_the_complex[] = "Returns the angle of the complex argument.\n\n    .. seealso:: :data:`numpy.angle`\n\n    ";
  static const char __pyx_k_Returns_the_complex_conjugate_el[] = "Returns the complex conjugate, element-wise.\n\n    .. seealso:: :data:`numpy.conj`\n\n    ";
  static const char __pyx_k_Returns_the_imaginary_part_of_th[] = "Returns the imaginary part of the elements of the array.\n\n    .. seealso:: :data:`numpy.imag`\n\n    ";
  static const char __pyx_k_Returns_the_real_part_of_the_ele[] = "Returns the real part of the elements of the array.\n\n    .. seealso:: :data:`numpy.real`\n\n    ";
  static const char __pyx_k_S_a_raw_T_choices_int32_n_channe[] = "S a, raw T choices, int32 n_channel";
  static const char __pyx_k_S_wrap_indices_indices_adim_if_2[] = "\n      S wrap_indices = indices % adim;\n      if (wrap_indices < 0) wrap_indices += adim;\n      ptrdiff_t li = i / (rdim * cdim);\n      ptrdiff_t ri = i % rdim;\n      atomicAdd(&a[(li * adim + wrap_indices) * rdim + ri], v[i]);\n    ";
  static const char __pyx_k_Sets_the_imaginary_part_of_the_e[] = "Sets the imaginary part of the elements of the array.\n    ";
  static const char __pyx_k_Sets_the_real_part_of_the_elemen[] = "Sets the real part of the elements of the array.\n    ";
  static const char __pyx_k_Shape_mismatch_Old_shape_new_sha[] = "Shape mismatch. Old shape: {}, new shape: {}";
  static const char __pyx_k_Sorting_arrays_with_dtype_is_not[] = "Sorting arrays with dtype '{}' is not supported";
  static const char __pyx_k_T_v_S_indices_int32_cdim_int32_r[] = "T v, S indices, int32 cdim, int32 rdim, int32 adim";
  static const char __pyx_k_Takes_numerical_negative_element[] = "Takes numerical negative elementwise.\n\n    .. seealso:: :data:`numpy.negative`\n\n    ";
  static const char __pyx_k_Tests_elementwise_if_x1_x2_seeal[] = "Tests elementwise if ``x1 > x2``.\n\n    .. seealso:: :data:`numpy.greater`\n\n    ";
  static const char __pyx_k_The_out_array_as_input_is_curren[] = "The out array as input is currently not supported";
  static const char __pyx_k_The_truth_value_of_an_array_with[] = "The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()";
  static const char __pyx_k_Thrust_is_needed_to_use_cupy_arg[] = "Thrust is needed to use cupy.argsort. Please install CUDA Toolkit with Thrust then reinstall CuPy after uninstalling it.";
  static const char __pyx_k_Thrust_is_needed_to_use_cupy_sor[] = "Thrust is needed to use cupy.sort. Please install CUDA Toolkit with Thrust then reinstall CuPy after uninstalling it.";
  static const char __pyx_k_To_change_to_a_dtype_of_a_differ[] = "To change to a dtype of a different size, the array must be C-contiguous";
  static const char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object";
  static const char __pyx_k_Universal_function_Attributes_uf[] = "Universal function.\n\n    Attributes:\n        ~ufunc.name (str): The name of the universal function.\n        nin (int): Number of input arguments.\n        nout (int): Number of output arguments.\n        nargs (int): Number of all arguments.\n\n    ";
  static const char __pyx_k_User_defined_reduction_kernel_Th[] = "User-defined reduction kernel.\n\n    This class can be used to define a reduction kernel with or without\n    broadcasting.\n\n    The kernel is compiled at an invocation of the\n    :meth:`~ReductionKernel.__call__` method, which is cached for each device.\n    The compiled binary is also cached into a file under the\n    ``$HOME/.cupy/kernel_cache/`` directory with a hashed file name. The cached\n    binary is reused by other processes.\n\n    Args:\n        in_params (str): Input argument list.\n        out_params (str): Output argument list.\n        map_expr (str): Mapping expression for input values.\n        reduce_expr (str): Reduction expression.\n        post_map_expr (str): Mapping expression for reduced values.\n        identity (str): Identity value for starting the reduction.\n        name (str): Name of the kernel function. It should be set for\n            readability of the performance profiling.\n        reduce_type (str): Type of values to be used for reduction. This type\n            is used to store the special variables ``a``.\n        reduce_dims (bool): If ``True``, input arrays are reshaped without copy\n            to smaller dimensions for efficiency.\n        preamble (str): Fragment of the CUDA-C/C++ code that is inserted at the\n            top of the cu file.\n        options (tuple of str): Additional compilation options.\n\n    ";
  static const char __pyx_k_all_elements_of_repeats_should_n[] = "all elements of 'repeats' should not be negative: {}";
  static const char __pyx_k_array_clip_must_set_either_max_o[] = "array_clip: must set either max or min";
  static const char __pyx_k_arrays_used_as_indices_must_be_o[] = "arrays used as indices must be of integer or boolean type. (actual: {})";
  static const char __pyx_k_axis1_0_and_axis2_1_must_be_with[] = "axis1(={0}) and axis2(={1}) must be within range (ndim={2})";
  static const char __pyx_k_cannot_select_an_axis_to_squeeze[] = "cannot select an axis to squeeze out which has size not equal to one";
  static const char __pyx_k_cannot_specify_out_as_both_a_pos[] = "cannot specify 'out' as both a positional and keyword argument";
  static const char __pyx_k_cupy_ndarray_does_not_have_imagi[] = "cupy.ndarray does not have imaginary part to set";
  static const char __pyx_k_currently_CuPy_only_supports_sli[] = "currently, CuPy only supports slices that consist of one boolean array.";
  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_input_operand_has_more_dimension[] = "input operand has more dimensions than allowed by the axis remapping";
  static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
  static const char __pyx_k_only_integers_slices_ellipsis_nu[] = "only integers, slices (`:`), ellipsis (`...`),numpy.newaxis (`None`) and integer or boolean arrays are valid indices";
  static const char __pyx_k_out0_a__type_reduce__in_ind_size[] = "out0 = a / _type_reduce(_in_ind.size() / _out_ind.size())";
  static const char __pyx_k_out0_in0__floor_divide_in0_in1_i[] = "out0 = in0 - _floor_divide(in0, in1) * in1";
  static const char __pyx_k_out0_in0_in1_in1_in0_in2_in2_in0[] = "out0 = in0 < in1 ? in1 : (in0 > in2 ? in2 : in0)";
  static const char __pyx_k_out0_in1_0_0_floor_double_in0_do[] = "out0 = in1 == 0 ? 0 : floor((double)in0 / (double)in1)";
  static const char __pyx_k_out0_out0_type_in0_out0_type_in1[] = "out0 = (out0_type)in0 / (out0_type)in1";
  static const char __pyx_k_out_0__type_out_0__raw_out_0__in[] = "out{0}_type &out{0} = _raw_out{0}[_ind.get()];";
  static const char __pyx_k_output_typecode_could_not_be_coe[] = "output (typecode '{}') could not be coerced to provided output parameter (typecode '{}') according to the casting rule \"{}\"";
  static const char __pyx_k_raw_P_x_int32_axis_raw_int64_cum[] = "raw P x, int32 axis, raw int64 cum_sizes, raw int64 x_strides";
  static const char __pyx_k_raw_T_a_S_indices_int32_cdim_int[] = "raw T a, S indices, int32 cdim, int32 rdim, int32 adim, S index_range";
  static const char __pyx_k_raw_T_a_S_indices_int32_rdim_S_i[] = "raw T a, S indices, int32 rdim, S index_range";
  static const char __pyx_k_raw_T_v_S_indices_int32_cdim_int[] = "raw T v, S indices, int32 cdim, int32 rdim, int32 adim";
  static const char __pyx_k_raw_T_v_bool_mask_S_mask_scanned[] = "raw T v, bool mask, S mask_scanned";
  static const char __pyx_k_self_ptr_self_val_cannot_be_conv[] = "self.ptr,self.val cannot be converted to a Python object for pickling";
  static const char __pyx_k_shape_mismatch_objects_cannot_be[] = "shape mismatch: objects cannot be broadcast to a single shape";
  static const char __pyx_k_simple_reduction_function___call[] = "simple_reduction_function.__call__";
  static const char __pyx_k_simple_reduction_function___init[] = "simple_reduction_function.__init__";
  static const char __pyx_k_to_environment_variable_CUDA_PAT[] = "to environment variable `CUDA_PATH`";
  static const char __pyx_k_type_out0_raw_out0__raw_out0__ou[] = "type_out0_raw &out0 = _raw_out0[_out_ind.get()];";
  static const char __pyx_k_typedef_s_type_in0_raw_typedef_s[] = "typedef %s type_in0_raw; typedef %s type_out0_raw;";
  static const char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides.";
  static const char __pyx_k_x___getitem___y_x_y_Supports_bot[] = "x.__getitem__(y) <==> x[y]\n\n        Supports both basic and advanced indexing.\n\n        .. note::\n\n            Currently, it does not support ``slices`` that consists of more\n            than one boolean arrays\n\n        .. note::\n\n           CuPy handles out-of-bounds indices differently from NumPy.\n           NumPy handles them by raising an error, but CuPy wraps around them.\n\n        Example:\n\n            >>> a = cupy.arange(3)\n            >>> a[[1, 3]]\n            array([1, 0])\n\n        ";
  static const char __pyx_k_zero_dimensional_arrays_cannot_b[] = "zero-dimensional arrays cannot be concatenated";
  static const char __pyx_k_zero_size_array_to_reduction_ope[] = "zero-size array to reduction operation %s which has no identity";
  static const char __pyx_k_S_wrap_indices_indices_index_ra_2[] = "\n      S wrap_indices = indices % index_range;\n      if (wrap_indices < 0) wrap_indices += index_range;\n\n      out = a[wrap_indices * rdim + i % rdim];\n    ";
  static const char __pyx_k_Shifts_the_bits_of_each_integer_2[] = "Shifts the bits of each integer element to the right.\n\n    Only integer arrays are handled\n\n    .. seealso:: :data:`numpy.right_shift`\n\n    ";
  static const char __pyx_k_extern_C___global___void_name_c_2[] = "\n    extern \"C\" __global__ void ${name}(const CArray<${src_dtype}, 1> src,\n        const CArray<${index_dtype}, 1> scaned_index,\n        CArray<${index_dtype}, 1> dst){\n        int thid = blockIdx.x * blockDim.x + threadIdx.x;\n        ptrdiff_t n = src.size();\n        if (thid < n){\n            if (src[thid] != 0){\n                dst[scaned_index[thid] - 1] = thid;\n            }\n        }\n    }\n    ";
  static const char __pyx_k_extern_C___global___void_name_c_3[] = "\n        extern \"C\" __global__ void ${name}(const CArray<${src_dtype}, 1> src,\n            CIndexer<${src_ndim}> shape,\n            const CArray<${index_dtype}, 1> scaned_index,\n            CArray<${dst_dtype}, 1> dst){\n\n            int thid = blockIdx.x * blockDim.x + threadIdx.x;\n\n            if (thid < src.size()){\n                if (src[thid] != 0){\n                    ${index_dtype} idx = scaned_index[thid] - 1;\n                    int s = shape.size();\n\n                    shape.set(thid);\n\n                    for(int i = 0; i < ${src_ndim}; i++){\n                        dst[idx * ${src_ndim} + i] = shape.get()[i];\n                    }\n                }\n            }\n        }\n        ";
  static const char __pyx_k_S_a_raw_T_choices_int32_n_channe_2[] = "S a, raw T choices, int32 n_channel, int32 n";
  static const char __pyx_k_Tests_elementwise_if_x1_x2_seeal_2[] = "Tests elementwise if ``x1 >= x2``.\n\n    .. seealso:: :data:`numpy.greater_equal`\n\n    ";
  static const char __pyx_k_Tests_elementwise_if_x1_x2_seeal_3[] = "Tests elementwise if ``x1 < x2``.\n\n    .. seealso:: :data:`numpy.less`\n\n    ";
  static const char __pyx_k_Tests_elementwise_if_x1_x2_seeal_4[] = "Tests elementwise if ``x1 <= x2``.\n\n    .. seealso:: :data:`numpy.less_equal`\n\n    ";
  static const char __pyx_k_Tests_elementwise_if_x1_x2_seeal_5[] = "Tests elementwise if ``x1 == x2``.\n\n    .. seealso:: :data:`numpy.equal`\n\n    ";
  static const char __pyx_k_Tests_elementwise_if_x1_x2_seeal_6[] = "Tests elementwise if ``x1 != x2``.\n\n    .. seealso:: :data:`numpy.equal`\n\n    ";
  static const char __pyx_k_out0_in0__floor_divide_in0_in1_i_2[] = "out0 = (in0 - _floor_divide(in0, in1) * in1) * (in1 != 0)";
  static PyObject *__pyx_kp_s_0;
  static PyObject *__pyx_kp_s_0_1__raw__1__i;
  static PyObject *__pyx_n_s_A;
  static PyObject *__pyx_n_s_ASCII;
  static PyObject *__pyx_kp_s_Adds_two_arrays_elementwise_seea;
  static PyObject *__pyx_kp_s_All_arrays_must_have_same_shape;
  static PyObject *__pyx_kp_s_All_arrays_to_concatenate_must_h;
  static PyObject *__pyx_kp_s_Array_device_must_be_same_as_the;
  static PyObject *__pyx_n_s_AttributeError;
  static PyObject *__pyx_kp_s_Axes_overrun;
  static PyObject *__pyx_n_s_AxisError;
  static PyObject *__pyx_n_s_AxisError_2;
  static PyObject *__pyx_kp_s_Axis_dimension_mismatch;
  static PyObject *__pyx_kp_s_Axis_exceeds_ndim;
  static PyObject *__pyx_kp_s_Axis_out_of_range;
  static PyObject *__pyx_kp_s_Axis_overrun;
  static PyObject *__pyx_kp_s_B;
  static PyObject *__pyx_kp_s_BB;
  static PyObject *__pyx_kp_s_BBB_B;
  static PyObject *__pyx_kp_s_BB_B;
  static PyObject *__pyx_kp_s_BB_BB;
  static PyObject *__pyx_kp_s_BB_d;
  static PyObject *__pyx_kp_s_B_B;
  static PyObject *__pyx_kp_s_B_B_2;
  static PyObject *__pyx_kp_s_B_L;
  static PyObject *__pyx_kp_s_B_d;
  static PyObject *__pyx_kp_s_B_q;
  static PyObject *__pyx_kp_s_Broadcasting_failed;
  static PyObject *__pyx_kp_s_Buffer_view_does_not_expose_stri;
  static PyObject *__pyx_n_s_C;
  static PyObject *__pyx_kp_s_CArray_s_d;
  static PyObject *__pyx_n_s_CIndexer;
  static PyObject *__pyx_kp_s_CIndexer__in_ind_CIndexer__out_i;
  static PyObject *__pyx_kp_s_CIndexer__ind;
  static PyObject *__pyx_kp_s_CIndexer_d;
  static PyObject *__pyx_kp_s_Can_not_use_i_as_a_parameter_nam;
  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_concatenate_from_empty_tu;
  static PyObject *__pyx_kp_s_Cannot_create_writable_memory_vi;
  static PyObject *__pyx_kp_s_Cannot_index_with_type_s;
  static PyObject *__pyx_kp_s_Cannot_set_to_non_contiguous_arr;
  static PyObject *__pyx_kp_s_Cannot_specify_out_as_both_a_pos;
  static PyObject *__pyx_kp_s_Cannot_use_out_in_s;
  static PyObject *__pyx_kp_s_Casting_complex_values_to_real_d;
  static PyObject *__pyx_kp_s_Changing_the_dtype_of_a_0d_array;
  static PyObject *__pyx_n_s_ComplexWarning;
  static PyObject *__pyx_kp_s_Computes_the_bitwise_AND_of_two;
  static PyObject *__pyx_kp_s_Computes_the_bitwise_NOT_of_an_a;
  static PyObject *__pyx_kp_s_Computes_the_bitwise_OR_of_two_a;
  static PyObject *__pyx_kp_s_Computes_the_bitwise_XOR_of_two;
  static PyObject *__pyx_kp_s_Computes_the_remainder_of_Python;
  static PyObject *__pyx_kp_s_Computes_x1_x2_elementwise_seeal;
  static PyObject *__pyx_n_s_D;
  static PyObject *__pyx_kp_s_DD;
  static PyObject *__pyx_kp_s_DD_D;
  static PyObject *__pyx_kp_s_D_2;
  static PyObject *__pyx_kp_s_D_D;
  static PyObject *__pyx_kp_s_D_D_2;
  static PyObject *__pyx_kp_s_D_d;
  static PyObject *__pyx_n_s_Device;
  static PyObject *__pyx_kp_s_Divides_arguments_elementwise_se;
  static PyObject *__pyx_kp_s_Elementwise_absolute_value_funct;
  static PyObject *__pyx_kp_s_Elementwise_floor_division_i_e_i;
  static PyObject *__pyx_kp_s_Elementwise_true_division_i_e_di;
  static PyObject *__pyx_n_s_Ellipsis;
  static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr;
  static PyObject *__pyx_n_s_F;
  static PyObject *__pyx_kp_s_FF;
  static PyObject *__pyx_kp_s_FF_F;
  static PyObject *__pyx_kp_s_F_2;
  static PyObject *__pyx_kp_s_F_F;
  static PyObject *__pyx_kp_s_F_F_2;
  static PyObject *__pyx_kp_s_F_f;
  static PyObject *__pyx_n_s_Flags;
  static PyObject *__pyx_kp_s_H;
  static PyObject *__pyx_kp_s_HH;
  static PyObject *__pyx_kp_s_HHH_H;
  static PyObject *__pyx_kp_s_HH_H;
  static PyObject *__pyx_kp_s_HH_HH;
  static PyObject *__pyx_kp_s_HH_d;
  static PyObject *__pyx_kp_s_H_H;
  static PyObject *__pyx_kp_s_H_H_2;
  static PyObject *__pyx_kp_s_H_L;
  static PyObject *__pyx_kp_s_H_d;
  static PyObject *__pyx_kp_s_H_q;
  static PyObject *__pyx_kp_s_I;
  static PyObject *__pyx_kp_s_II;
  static PyObject *__pyx_kp_s_III_I;
  static PyObject *__pyx_kp_s_II_I;
  static PyObject *__pyx_kp_s_II_II;
  static PyObject *__pyx_kp_s_II_d;
  static PyObject *__pyx_kp_s_I_2;
  static PyObject *__pyx_kp_s_I_I;
  static PyObject *__pyx_kp_s_I_I_2;
  static PyObject *__pyx_kp_s_I_L;
  static PyObject *__pyx_kp_s_I_d;
  static PyObject *__pyx_kp_s_I_q;
  static PyObject *__pyx_kp_s_I_s;
  static PyObject *__pyx_kp_s_Illegal_conditions;
  static PyObject *__pyx_n_s_ImportError;
  static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x05;
  static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x6d;
  static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x73;
  static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x7d;
  static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xb0;
  static PyObject *__pyx_n_s_IndexError;
  static PyObject *__pyx_n_s_IndexOrValueError;
  static PyObject *__pyx_n_s_IndexOrValueError___init;
  static PyObject *__pyx_kp_s_Index_s_is_out_of_bounds_for_axi;
  static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte;
  static PyObject *__pyx_kp_s_Input_array_should_be_1D_array;
  static PyObject *__pyx_kp_s_Invalid_axes_value_s;
  static PyObject *__pyx_kp_s_Invalid_dtype_s;
  static PyObject *__pyx_kp_s_Invalid_index_type_s;
  static PyObject *__pyx_kp_s_Invalid_kernel_name_s;
  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_K;
  static PyObject *__pyx_kp_s_L;
  static PyObject *__pyx_kp_s_LL;
  static PyObject *__pyx_kp_s_LLL_L;
  static PyObject *__pyx_kp_s_LL_L;
  static PyObject *__pyx_kp_s_LL_LL;
  static PyObject *__pyx_kp_s_LL_d;
  static PyObject *__pyx_kp_s_L_L;
  static PyObject *__pyx_kp_s_L_L_2;
  static PyObject *__pyx_kp_s_L_d;
  static PyObject *__pyx_kp_s_L_q;
  static PyObject *__pyx_kp_s_Loop_size_is_Undecided;
  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_kp_s_Multiplies_two_arrays_elementwis;
  static PyObject *__pyx_kp_s_Negative_dimensions_are_not_allo;
  static PyObject *__pyx_n_s_NotImplemented;
  static PyObject *__pyx_n_s_NotImplementedError;
  static PyObject *__pyx_kp_s_Not_supported_dtype_combination;
  static PyObject *__pyx_n_b_O;
  static PyObject *__pyx_kp_s_Only_cupy_arrays_can_be_concaten;
  static PyObject *__pyx_kp_s_Only_numpy_ndarray_can_be_set_to;
  static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a;
  static PyObject *__pyx_kp_s_Out_shape_is_mismatched;
  static PyObject *__pyx_kp_s_Output_arguments_must_be_cupy_nd;
  static PyObject *__pyx_kp_s_Output_arguments_type_must_be_cu;
  static PyObject *__pyx_kp_s_Output_array_has_an_invalid_size;
  static PyObject *__pyx_kp_s_Output_array_must_be_C_contiguou;
  static PyObject *__pyx_kp_s_Output_array_size_is_Undecided;
  static PyObject *__pyx_kp_s_Output_dtype_mismatch;
  static PyObject *__pyx_kp_s_Output_shape_mismatch;
  static PyObject *__pyx_n_s_PY3;
  static PyObject *__pyx_n_s_PickleError;
  static PyObject *__pyx_kp_s_Please_set_the_CUDA_path;
  static PyObject *__pyx_kp_s_Provided_out_is_the_wrong_size;
  static PyObject *__pyx_kp_s_Q;
  static PyObject *__pyx_kp_s_QQ;
  static PyObject *__pyx_kp_s_QQQ_Q;
  static PyObject *__pyx_kp_s_QQ_Q;
  static PyObject *__pyx_kp_s_QQ_QQ;
  static PyObject *__pyx_kp_s_QQ_d;
  static PyObject *__pyx_kp_s_Q_Q;
  static PyObject *__pyx_kp_s_Q_Q_2;
  static PyObject *__pyx_kp_s_Q_d;
  static PyObject *__pyx_kp_s_Q_q;
  static PyObject *__pyx_n_s_ReductionKernel;
  static PyObject *__pyx_n_s_ReductionKernel___call;
  static PyObject *__pyx_n_s_ReductionKernel___init;
  static PyObject *__pyx_kp_s_Returns_the_angle_of_the_complex;
  static PyObject *__pyx_kp_s_Returns_the_complex_conjugate_el;
  static PyObject *__pyx_kp_s_Returns_the_imaginary_part_of_th;
  static PyObject *__pyx_kp_s_Returns_the_real_part_of_the_ele;
  static PyObject *__pyx_n_s_RuntimeError;
  static PyObject *__pyx_kp_s_S_a_raw_T_choices_int32_n_channe;
  static PyObject *__pyx_kp_s_S_a_raw_T_choices_int32_n_channe_2;
  static PyObject *__pyx_kp_s_S_wrap_indices_indices_adim_if;
  static PyObject *__pyx_kp_s_S_wrap_indices_indices_adim_if_2;
  static PyObject *__pyx_kp_s_S_wrap_indices_indices_index_ra;
  static PyObject *__pyx_kp_s_S_wrap_indices_indices_index_ra_2;
  static PyObject *__pyx_kp_s_S_x_T_mean_T_alpha;
  static PyObject *__pyx_kp_s_S_x_T_y;
  static PyObject *__pyx_kp_s_S_x_a_if_a_0_x_0_else_if_a_n_x;
  static PyObject *__pyx_kp_s_Scalar_operands_are_not_allowed;
  static PyObject *__pyx_n_s_Sequence;
  static PyObject *__pyx_kp_s_Sets_the_imaginary_part_of_the_e;
  static PyObject *__pyx_kp_s_Sets_the_real_part_of_the_elemen;
  static PyObject *__pyx_kp_s_Shape_mismatch_Old_shape_new_sha;
  static PyObject *__pyx_kp_s_Shifts_the_bits_of_each_integer;
  static PyObject *__pyx_kp_s_Shifts_the_bits_of_each_integer_2;
  static PyObject *__pyx_kp_s_Sorting_arrays_with_dtype_is_not;
  static PyObject *__pyx_kp_s_Sorting_arrays_with_the_rank_of;
  static PyObject *__pyx_kp_s_Sorting_non_contiguous_array_is;
  static PyObject *__pyx_kp_s_Specified_size_can_be_used_only;
  static PyObject *__pyx_kp_s_Subtracts_arguments_elementwise;
  static PyObject *__pyx_kp_s_Syntax_error_s;
  static PyObject *__pyx_kp_s_T_a;
  static PyObject *__pyx_kp_s_T_a_bool_mask_S_mask_scanned;
  static PyObject *__pyx_kp_s_T_in0;
  static PyObject *__pyx_kp_s_T_in_d;
  static PyObject *__pyx_kp_s_T_out;
  static PyObject *__pyx_kp_s_T_out0;
  static PyObject *__pyx_kp_s_T_out_d;
  static PyObject *__pyx_kp_s_T_v_S_indices_int32_cdim_int32_r;
  static PyObject *__pyx_kp_s_T_y;
  static PyObject *__pyx_kp_s_Takes_numerical_negative_element;
  static PyObject *__pyx_n_s_Template;
  static PyObject *__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal;
  static PyObject *__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_2;
  static PyObject *__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_3;
  static PyObject *__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_4;
  static PyObject *__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_5;
  static PyObject *__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_6;
  static PyObject *__pyx_kp_s_The_out_array_as_input_is_curren;
  static PyObject *__pyx_kp_s_The_truth_value_of_an_array_with;
  static PyObject *__pyx_kp_s_Thrust_is_needed_to_use_cupy_arg;
  static PyObject *__pyx_kp_s_Thrust_is_needed_to_use_cupy_sor;
  static PyObject *__pyx_kp_s_To_change_to_a_dtype_of_a_differ;
  static PyObject *__pyx_n_s_TypeError;
  static PyObject *__pyx_kp_s_Type_is_mismatched_s_s_s;
  static PyObject *__pyx_kp_s_Type_is_mismatched_s_s_s_s;
  static PyObject *__pyx_kp_s_U_out;
  static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object;
  static PyObject *__pyx_kp_s_Universal_function_Attributes_uf;
  static PyObject *__pyx_kp_s_Unknown_keyword_s;
  static PyObject *__pyx_kp_s_Unsupported_dtype_s;
  static PyObject *__pyx_kp_s_Unsupported_type_s;
  static PyObject *__pyx_kp_s_User_defined_reduction_kernel_Th;
  static PyObject *__pyx_n_s_ValueError;
  static PyObject *__pyx_kp_s_Variance_for_complex_numbers_is;
  static PyObject *__pyx_n_s_View_MemoryView;
  static PyObject *__pyx_kp_s_Wrong_arguments_s;
  static PyObject *__pyx_kp_s_Wrong_number_of_arguments_for_s;
  static PyObject *__pyx_kp_s_Wrong_type_s;
  static PyObject *__pyx_kp_s_Wrong_type_s_of_arguments_for_s;
  static PyObject *__pyx_kp_s__105;
  static PyObject *__pyx_n_s__227;
  static PyObject *__pyx_kp_s__247;
  static PyObject *__pyx_kp_s__294;
  static PyObject *__pyx_kp_s__295;
  static PyObject *__pyx_kp_s__296;
  static PyObject *__pyx_kp_s__300;
  static PyObject *__pyx_kp_s__301;
  static PyObject *__pyx_kp_s__312;
  static PyObject *__pyx_kp_s__313;
  static PyObject *__pyx_kp_s__314;
  static PyObject *__pyx_kp_s__315;
  static PyObject *__pyx_kp_s__316;
  static PyObject *__pyx_kp_s__317;
  static PyObject *__pyx_kp_s__338;
  static PyObject *__pyx_kp_s__362;
  static PyObject *__pyx_kp_s__377;
  static PyObject *__pyx_kp_s__401;
  static PyObject *__pyx_kp_s__53;
  static PyObject *__pyx_kp_s__56;
  static PyObject *__pyx_kp_s__57;
  static PyObject *__pyx_kp_s__6;
  static PyObject *__pyx_kp_s__71;
  static PyObject *__pyx_n_s_a;
  static PyObject *__pyx_kp_s_a_b;
  static PyObject *__pyx_kp_s_a_b_2;
  static PyObject *__pyx_kp_s_a_b_3;
  static PyObject *__pyx_kp_s_a_b_4;
  static PyObject *__pyx_n_s_a_max;
  static PyObject *__pyx_n_s_a_min;
  static PyObject *__pyx_n_s_a_shape;
  static PyObject *__pyx_n_s_absolute;
  static PyObject *__pyx_n_s_abspath;
  static PyObject *__pyx_n_s_add;
  static PyObject *__pyx_n_s_add_scan_blocked_sum_kernel;
  static PyObject *__pyx_n_s_add_scan_blocked_sum_kernel_2;
  static PyObject *__pyx_n_s_after_loop;
  static PyObject *__pyx_n_s_all;
  static PyObject *__pyx_n_s_all_2;
  static PyObject *__pyx_kp_s_all_elements_of_repeats_should_n;
  static PyObject *__pyx_n_s_all_type_chars;
  static PyObject *__pyx_n_s_allocate_buffer;
  static PyObject *__pyx_n_s_amax;
  static PyObject *__pyx_n_s_amin;
  static PyObject *__pyx_n_s_angle;
  static PyObject *__pyx_n_s_any;
  static PyObject *__pyx_n_s_any_2;
  static PyObject *__pyx_n_s_append;
  static PyObject *__pyx_n_s_arange;
  static PyObject *__pyx_n_s_arch;
  static PyObject *__pyx_n_s_argmax;
  static PyObject *__pyx_n_s_argmin;
  static PyObject *__pyx_n_s_args;
  static PyObject *__pyx_n_s_args_info;
  static PyObject *__pyx_n_s_argsort;
  static PyObject *__pyx_n_s_arr;
  static PyObject *__pyx_n_s_array;
  static PyObject *__pyx_kp_s_array_cannot_be_set_to_array;
  static PyObject *__pyx_kp_s_array_clip_must_set_either_max_o;
  static PyObject *__pyx_n_s_array_priority;
  static PyObject *__pyx_n_s_array_split;
  static PyObject *__pyx_n_s_arrays;
  static PyObject *__pyx_kp_s_arrays_used_as_indices_must_be_o;
  static PyObject *__pyx_n_s_ary;
  static PyObject *__pyx_n_s_ascontiguousarray;
  static PyObject *__pyx_n_s_asfortranarray;
  static PyObject *__pyx_n_s_astype;
  static PyObject *__pyx_n_s_axis;
  static PyObject *__pyx_n_s_axis1;
  static PyObject *__pyx_kp_s_axis1_0_and_axis2_1_must_be_with;
  static PyObject *__pyx_n_s_axis2;
  static PyObject *__pyx_kp_s_axis_entry_d_is_out_of_bounds_d;
  static PyObject *__pyx_kp_s_axis_is_out_of_bounds_for_array;
  static PyObject *__pyx_kp_s_axis_out_of_bounds_0;
  static PyObject *__pyx_n_s_b;
  static PyObject *__pyx_kp_s_b_2;
  static PyObject *__pyx_kp_s_b_b;
  static PyObject *__pyx_kp_s_b_b_2;
  static PyObject *__pyx_kp_s_b_l;
  static PyObject *__pyx_n_s_base;
  static PyObject *__pyx_kp_s_bb;
  static PyObject *__pyx_kp_s_bb_b;
  static PyObject *__pyx_kp_s_bb_bb;
  static PyObject *__pyx_kp_s_bb_d;
  static PyObject *__pyx_kp_s_bbb_b;
  static PyObject *__pyx_kp_s_bhilqBHILQefdFD;
  static PyObject *__pyx_n_s_bit_length;
  static PyObject *__pyx_n_s_bitwise_and;
  static PyObject *__pyx_n_s_bitwise_or;
  static PyObject *__pyx_n_s_bitwise_xor;
  static PyObject *__pyx_n_s_biu;
  static PyObject *__pyx_n_s_block;
  static PyObject *__pyx_n_s_block_size;
  static PyObject *__pyx_n_s_block_size_2;
  static PyObject *__pyx_n_s_block_stride;
  static PyObject *__pyx_n_s_bool;
  static PyObject *__pyx_n_s_bool_2;
  static PyObject *__pyx_n_s_broad;
  static PyObject *__pyx_n_s_broad_shape;
  static PyObject *__pyx_n_s_c;
  static PyObject *__pyx_n_u_c;
  static PyObject *__pyx_n_s_cPickle;
  static PyObject *__pyx_n_s_c_contiguous;
  static PyObject *__pyx_n_s_cachd_dir;
  static PyObject *__pyx_n_s_call;
  static PyObject *__pyx_n_s_can_cast;
  static PyObject *__pyx_kp_s_cannot_select_an_axis_to_squeeze;
  static PyObject *__pyx_kp_s_cannot_specify_out_as_both_a_pos;
  static PyObject *__pyx_n_s_casting;
  static PyObject *__pyx_kp_s_casting_is_not_supported_yet;
  static PyObject *__pyx_n_s_cgemmBatched;
  static PyObject *__pyx_n_s_cgemmStridedBatched;
  static PyObject *__pyx_n_s_char;
  static PyObject *__pyx_n_s_choices;
  static PyObject *__pyx_n_s_choose;
  static PyObject *__pyx_n_s_chr;
  static PyObject *__pyx_n_s_class;
  static PyObject *__pyx_n_s_cline_in_traceback;
  static PyObject *__pyx_n_s_clip;
  static PyObject *__pyx_n_s_clip_2;
  static PyObject *__pyx_kp_s_clipmode_not_understood;
  static PyObject *__pyx_n_s_close;
  static PyObject *__pyx_n_s_clp2_count;
  static PyObject *__pyx_n_s_collections;
  static PyObject *__pyx_n_s_compile_with_cache;
  static PyObject *__pyx_n_s_compiler;
  static PyObject *__pyx_n_s_complex128;
  static PyObject *__pyx_n_s_complex64;
  static PyObject *__pyx_kp_s_complex_double;
  static PyObject *__pyx_kp_s_complex_float;
  static PyObject *__pyx_n_s_complexfloating;
  static PyObject *__pyx_n_s_conj;
  static PyObject *__pyx_kp_s_const_0_1__raw__1__j;
  static PyObject *__pyx_kp_s_const_in_0__type_in_0__raw_in_0;
  static PyObject *__pyx_kp_s_const_type_in0_raw_in0__raw_in0;
  static PyObject *__pyx_kp_s_contiguous_and_direct;
  static PyObject *__pyx_kp_s_contiguous_and_indirect;
  static PyObject *__pyx_n_s_copy;
  static PyObject *__pyx_n_s_create_ufunc;
  static PyObject *__pyx_n_s_ctype;
  static PyObject *__pyx_n_s_ctypes;
  static PyObject *__pyx_n_s_cublas;
  static PyObject *__pyx_n_s_cublas_handle;
  static PyObject *__pyx_n_s_cuda;
  static PyObject *__pyx_n_s_cupy;
  static PyObject *__pyx_n_s_cupy_2;
  static PyObject *__pyx_n_s_cupy_absolute;
  static PyObject *__pyx_n_s_cupy_all;
  static PyObject *__pyx_n_s_cupy_angle;
  static PyObject *__pyx_n_s_cupy_any;
  static PyObject *__pyx_n_s_cupy_argmax;
  static PyObject *__pyx_n_s_cupy_argmin;
  static PyObject *__pyx_kp_s_cupy_atomics_cuh;
  static PyObject *__pyx_kp_s_cupy_carray_cuh;
  static PyObject *__pyx_n_s_cupy_choose;
  static PyObject *__pyx_n_s_cupy_choose_clip;
  static PyObject *__pyx_n_s_cupy_clip;
  static PyObject *__pyx_kp_s_cupy_complex_arithmetic_h;
  static PyObject *__pyx_kp_s_cupy_complex_catrig_h;
  static PyObject *__pyx_kp_s_cupy_complex_catrigf_h;
  static PyObject *__pyx_kp_s_cupy_complex_ccosh_h;
  static PyObject *__pyx_kp_s_cupy_complex_ccoshf_h;
  static PyObject *__pyx_kp_s_cupy_complex_cexp_h;
  static PyObject *__pyx_kp_s_cupy_complex_cexpf_h;
  static PyObject *__pyx_kp_s_cupy_complex_clog_h;
  static PyObject *__pyx_kp_s_cupy_complex_clogf_h;
  static PyObject *__pyx_kp_s_cupy_complex_complex_h;
  static PyObject *__pyx_kp_s_cupy_complex_complex_inl_h;
  static PyObject *__pyx_kp_s_cupy_complex_cpow_h;
  static PyObject *__pyx_kp_s_cupy_complex_cproj_h;
  static PyObject *__pyx_kp_s_cupy_complex_csinh_h;
  static PyObject *__pyx_kp_s_cupy_complex_csinhf_h;
  static PyObject *__pyx_kp_s_cupy_complex_csqrt_h;
  static PyObject *__pyx_kp_s_cupy_complex_csqrtf_h;
  static PyObject *__pyx_kp_s_cupy_complex_ctanh_h;
  static PyObject *__pyx_kp_s_cupy_complex_ctanhf_h;
  static PyObject *__pyx_kp_s_cupy_complex_cuh;
  static PyObject *__pyx_kp_s_cupy_complex_math_private_h;
  static PyObject *__pyx_n_s_cupy_concatenate;
  static PyObject *__pyx_n_s_cupy_concatenate_same_size;
  static PyObject *__pyx_n_s_cupy_conj;
  static PyObject *__pyx_n_s_cupy_copy;
  static PyObject *__pyx_n_s_cupy_copy_where;
  static PyObject *__pyx_n_s_cupy_core;
  static PyObject *__pyx_n_s_cupy_core_core;
  static PyObject *__pyx_kp_s_cupy_core_core_pyx;
  static PyObject *__pyx_kp_s_cupy_core_elementwise_pxi;
  static PyObject *__pyx_kp_s_cupy_core_reduction_pxi;
  static PyObject *__pyx_n_s_cupy_cuda;
  static PyObject *__pyx_n_s_cupy_divide;
  static PyObject *__pyx_n_s_cupy_divmod;
  static PyObject *__pyx_n_s_cupy_floor_divide;
  static PyObject *__pyx_n_s_cupy_getitem_mask;
  static PyObject *__pyx_n_s_cupy_imag;
  static PyObject *__pyx_n_s_cupy_imag_setter;
  static PyObject *__pyx_n_s_cupy_invert;
  static PyObject *__pyx_n_s_cupy_max;
  static PyObject *__pyx_n_s_cupy_mean;
  static PyObject *__pyx_n_s_cupy_min;
  static PyObject *__pyx_n_s_cupy_nanmax;
  static PyObject *__pyx_n_s_cupy_nanmin;
  static PyObject *__pyx_kp_s_cupy_ndarray_does_not_have_imagi;
  static PyObject *__pyx_n_s_cupy_negative;
  static PyObject *__pyx_n_s_cupy_power;
  static PyObject *__pyx_n_s_cupy_prod;
  static PyObject *__pyx_n_s_cupy_prod_with_dtype;
  static PyObject *__pyx_n_s_cupy_real;
  static PyObject *__pyx_n_s_cupy_real_setter;
  static PyObject *__pyx_n_s_cupy_remainder;
  static PyObject *__pyx_n_s_cupy_scatter_add;
  static PyObject *__pyx_n_s_cupy_scatter_add_mask;
  static PyObject *__pyx_n_s_cupy_scatter_update;
  static PyObject *__pyx_n_s_cupy_scatter_update_mask;
  static PyObject *__pyx_n_s_cupy_sqrt;
  static PyObject *__pyx_n_s_cupy_sum;
  static PyObject *__pyx_n_s_cupy_sum_with_dtype;
  static PyObject *__pyx_n_s_cupy_take;
  static PyObject *__pyx_n_s_cupy_take_0axis;
  static PyObject *__pyx_n_s_cupy_true_divide;
  static PyObject *__pyx_kp_s_currently_CuPy_only_supports_sli;
  static PyObject *__pyx_n_s_d;
  static PyObject *__pyx_kp_s_d_2;
  static PyObject *__pyx_kp_s_d_3;
  static PyObject *__pyx_kp_s_d_D;
  static PyObject *__pyx_kp_s_d_d;
  static PyObject *__pyx_kp_s_d_d_2;
  static PyObject *__pyx_kp_s_d_q;
  static PyObject *__pyx_n_s_data;
  static PyObject *__pyx_kp_s_dd;
  static PyObject *__pyx_kp_s_dd_d;
  static PyObject *__pyx_kp_s_dd_dd;
  static PyObject *__pyx_kp_s_ddd_d;
  static PyObject *__pyx_n_s_ddof;
  static PyObject *__pyx_n_s_decide_params_type;
  static PyObject *__pyx_n_s_default_casting;
  static PyObject *__pyx_n_s_default_casting_2;
  static PyObject *__pyx_n_s_destination;
  static PyObject *__pyx_n_s_device;
  static PyObject *__pyx_n_s_dgeam;
  static PyObject *__pyx_n_s_dgemmBatched;
  static PyObject *__pyx_n_s_dgemmStridedBatched;
  static PyObject *__pyx_n_s_diagonal;
  static PyObject *__pyx_n_s_dict;
  static PyObject *__pyx_n_s_dirname;
  static PyObject *__pyx_n_s_divide;
  static PyObject *__pyx_n_s_divmod;
  static PyObject *__pyx_n_s_doc;
  static PyObject *__pyx_n_s_doc_2;
  static PyObject *__pyx_n_s_double;
  static PyObject *__pyx_n_s_dst_dtype;
  static PyObject *__pyx_n_s_dtype;
  static PyObject *__pyx_n_s_dtype_2;
  static PyObject *__pyx_kp_s_dtype_is_None;
  static PyObject *__pyx_n_s_dtype_is_object;
  static PyObject *__pyx_n_s_dump;
  static PyObject *__pyx_n_s_dumps;
  static PyObject *__pyx_kp_s_duplicate_value_in_axis;
  static PyObject *__pyx_n_s_e;
  static PyObject *__pyx_kp_s_e_2;
  static PyObject *__pyx_kp_s_e_e;
  static PyObject *__pyx_kp_s_e_e_2;
  static PyObject *__pyx_kp_s_e_q;
  static PyObject *__pyx_n_s_each_size;
  static PyObject *__pyx_kp_s_ee;
  static PyObject *__pyx_kp_s_ee_e;
  static PyObject *__pyx_kp_s_ee_ee;
  static PyObject *__pyx_kp_s_eee_e;
  static PyObject *__pyx_n_s_elem;
  static PyObject *__pyx_n_s_elementwise_copy;
  static PyObject *__pyx_n_s_elementwise_copy_where;
  static PyObject *__pyx_n_s_empty;
  static PyObject *__pyx_n_s_encode;
  static PyObject *__pyx_n_s_enter;
  static PyObject *__pyx_n_s_enumerate;
  static PyObject *__pyx_n_s_equal;
  static PyObject *__pyx_n_s_error;
  static PyObject *__pyx_n_s_exit;
  static PyObject *__pyx_n_s_extend;
  static PyObject *__pyx_kp_s_extern_C___global___void_name_C;
  static PyObject *__pyx_kp_s_extern_C___global___void_name_c;
  static PyObject *__pyx_kp_s_extern_C___global___void_name_c_2;
  static PyObject *__pyx_kp_s_extern_C___global___void_name_c_3;
  static PyObject *__pyx_n_s_f;
  static PyObject *__pyx_kp_s_f_2;
  static PyObject *__pyx_kp_s_f_F;
  static PyObject *__pyx_kp_s_f_f;
  static PyObject *__pyx_kp_s_f_f_2;
  static PyObject *__pyx_kp_s_f_q;
  static PyObject *__pyx_n_s_false;
  static PyObject *__pyx_n_s_fdFD;
  static PyObject *__pyx_kp_s_ff;
  static PyObject *__pyx_kp_s_ff_f;
  static PyObject *__pyx_kp_s_ff_ff;
  static PyObject *__pyx_kp_s_fff_f;
  static PyObject *__pyx_n_s_fid;
  static PyObject *__pyx_n_s_file;
  static PyObject *__pyx_n_s_fill;
  static PyObject *__pyx_n_s_find_common_type;
  static PyObject *__pyx_n_s_flags;
  static PyObject *__pyx_n_s_flatten;
  static PyObject *__pyx_n_s_float;
  static PyObject *__pyx_n_s_float16;
  static PyObject *__pyx_n_s_float32;
  static PyObject *__pyx_n_s_float64;
  static PyObject *__pyx_n_s_floating;
  static PyObject *__pyx_n_s_floor_divide;
  static PyObject *__pyx_n_s_fmt;
  static PyObject *__pyx_n_s_for_each_device;
  static PyObject *__pyx_n_s_format;
  static PyObject *__pyx_n_s_fortran;
  static PyObject *__pyx_n_u_fortran;
  static PyObject *__pyx_n_s_frombuffer;
  static PyObject *__pyx_n_s_genexpr;
  static PyObject *__pyx_n_s_get;
  static PyObject *__pyx_n_s_get_as_parameter;
  static PyObject *__pyx_n_s_get_cuda_path;
  static PyObject *__pyx_n_s_get_elementwise_kernel;
  static PyObject *__pyx_n_s_get_elementwise_kernel_locals_g;
  static PyObject *__pyx_n_s_get_param_info;
  static PyObject *__pyx_n_s_get_reduction_kernel;
  static PyObject *__pyx_n_s_get_reduction_kernel_locals_gen;
  static PyObject *__pyx_n_s_get_simple_elementwise_kernel;
  static PyObject *__pyx_n_s_get_simple_reduction_function;
  static PyObject *__pyx_n_s_get_ufunc_kernel;
  static PyObject *__pyx_n_s_getstate;
  static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi;
  static PyObject *__pyx_n_s_greater;
  static PyObject *__pyx_n_s_greater_equal;
  static PyObject *__pyx_n_s_grid;
  static PyObject *__pyx_kp_s_h;
  static PyObject *__pyx_kp_s_h_d;
  static PyObject *__pyx_kp_s_h_h;
  static PyObject *__pyx_kp_s_h_h_2;
  static PyObject *__pyx_kp_s_h_l;
  static PyObject *__pyx_kp_s_h_q;
  static PyObject *__pyx_n_s_has_element;
  static PyObject *__pyx_n_s_hex;
  static PyObject *__pyx_kp_s_hh;
  static PyObject *__pyx_kp_s_hh_d;
  static PyObject *__pyx_kp_s_hh_h;
  static PyObject *__pyx_kp_s_hh_hh;
  static PyObject *__pyx_kp_s_hhh_h;
  static PyObject *__pyx_n_s_i;
  static PyObject *__pyx_kp_s_i_2;
  static PyObject *__pyx_kp_s_i_d;
  static PyObject *__pyx_kp_s_i_i;
  static PyObject *__pyx_kp_s_i_i_2;
  static PyObject *__pyx_kp_s_i_l;
  static PyObject *__pyx_kp_s_i_q;
  static PyObject *__pyx_n_s_id;
  static PyObject *__pyx_n_s_identity;
  static PyObject *__pyx_kp_s_if_in1_0_out0_0_out1_0_else_out;
  static PyObject *__pyx_kp_s_if_in1_out0_in0;
  static PyObject *__pyx_kp_s_if_mask_a_a_v_mask_scanned_1;
  static PyObject *__pyx_kp_s_if_mask_a_v_mask_scanned_1;
  static PyObject *__pyx_kp_s_if_mask_out_mask_scanned_1_a;
  static PyObject *__pyx_kp_s_ii;
  static PyObject *__pyx_kp_s_ii_d;
  static PyObject *__pyx_kp_s_ii_i;
  static PyObject *__pyx_kp_s_ii_ii;
  static PyObject *__pyx_kp_s_iii_i;
  static PyObject *__pyx_n_s_iinfo;
  static PyObject *__pyx_n_s_imag;
  static PyObject *__pyx_n_s_imag_setter;
  static PyObject *__pyx_n_s_import;
  static PyObject *__pyx_n_s_in0;
  static PyObject *__pyx_kp_s_in0_type_in0_raw_0;
  static PyObject *__pyx_n_s_in_arg_dtype;
  static PyObject *__pyx_n_s_in_args;
  static PyObject *__pyx_n_s_in_args_dtype;
  static PyObject *__pyx_n_s_in_indexer;
  static PyObject *__pyx_n_s_in_ndarray_types;
  static PyObject *__pyx_n_s_in_params;
  static PyObject *__pyx_n_s_in_params_2;
  static PyObject *__pyx_n_s_in_sahpe;
  static PyObject *__pyx_n_s_in_shape;
  static PyObject *__pyx_n_s_in_str;
  static PyObject *__pyx_n_s_in_types;
  static PyObject *__pyx_n_s_include;
  static PyObject *__pyx_kp_s_include_s;
  static PyObject *__pyx_n_s_inclusive_scan_kernel;
  static PyObject *__pyx_n_s_inclusive_scan_kernel_2;
  static PyObject *__pyx_kp_s_incompatible_shape;
  static PyObject *__pyx_n_s_index;
  static PyObject *__pyx_n_s_index_dtype;
  static PyObject *__pyx_kp_s_index_out_of_range;
  static PyObject *__pyx_n_s_indexer;
  static PyObject *__pyx_n_s_indices;
  static PyObject *__pyx_n_s_indices_or_sections;
  static PyObject *__pyx_kp_s_inf;
  static PyObject *__pyx_n_s_inf_2;
  static PyObject *__pyx_n_s_init;
  static PyObject *__pyx_n_s_inout_args;
  static PyObject *__pyx_n_s_input_expr;
  static PyObject *__pyx_n_s_input_expr_2;
  static PyObject *__pyx_kp_s_input_operand_has_more_dimension;
  static PyObject *__pyx_n_s_int;
  static PyObject *__pyx_n_s_int16;
  static PyObject *__pyx_n_s_int32;
  static PyObject *__pyx_kp_s_int32__block_stride;
  static PyObject *__pyx_n_s_int64;
  static PyObject *__pyx_n_s_int8;
  static PyObject *__pyx_n_s_int_iinfo;
  static PyObject *__pyx_n_s_integer;
  static PyObject *__pyx_n_s_integer_types;
  static PyObject *__pyx_n_s_intp;
  static PyObject *__pyx_kp_s_invalid_entry_in_choice_array;
  static PyObject *__pyx_n_s_invert;
  static PyObject *__pyx_n_s_is_const;
  static PyObject *__pyx_n_s_is_valid_kernel_name;
  static PyObject *__pyx_n_s_isscalar;
  static PyObject *__pyx_n_s_issubdtype;
  static PyObject *__pyx_n_s_item;
  static PyObject *__pyx_n_s_items;
  static PyObject *__pyx_n_s_itemsize;
  static PyObject *__pyx_kp_s_itemsize_0_for_cython_array;
  static PyObject *__pyx_n_s_join;
  static PyObject *__pyx_n_s_k;
  static PyObject *__pyx_n_s_keepdims;
  static PyObject *__pyx_n_s_kern;
  static PyObject *__pyx_n_s_kernel;
  static PyObject *__pyx_n_s_kernel_params;
  static PyObject *__pyx_n_s_kind;
  static PyObject *__pyx_n_s_kth;
  static PyObject *__pyx_kp_s_kth_out_of_bounds;
  static PyObject *__pyx_n_s_kwargs;
  static PyObject *__pyx_kp_s_l;
  static PyObject *__pyx_kp_s_l_2;
  static PyObject *__pyx_kp_s_l_d;
  static PyObject *__pyx_kp_s_l_l;
  static PyObject *__pyx_kp_s_l_l_2;
  static PyObject *__pyx_kp_s_l_q;
  static PyObject *__pyx_n_s_laxis;
  static PyObject *__pyx_n_s_left_shift;
  static PyObject *__pyx_kp_s_len_of_unsized_object;
  static PyObject *__pyx_kp_s_len_shape_len_strides;
  static PyObject *__pyx_n_s_less;
  static PyObject *__pyx_n_s_less_equal;
  static PyObject *__pyx_n_s_li;
  static PyObject *__pyx_n_s_linear_launch;
  static PyObject *__pyx_kp_s_ll;
  static PyObject *__pyx_kp_s_ll_d;
  static PyObject *__pyx_kp_s_ll_l;
  static PyObject *__pyx_kp_s_ll_ll;
  static PyObject *__pyx_kp_s_lll_l;
  static PyObject *__pyx_n_s_long;
  static PyObject *__pyx_kp_s_long_long;
  static PyObject *__pyx_n_s_loop_prep;
  static PyObject *__pyx_n_s_lower;
  static PyObject *__pyx_n_s_m;
  static PyObject *__pyx_n_s_main;
  static PyObject *__pyx_n_s_map;
  static PyObject *__pyx_n_s_map_expr;
  static PyObject *__pyx_n_s_mask;
  static PyObject *__pyx_n_s_max;
  static PyObject *__pyx_n_s_maximum;
  static PyObject *__pyx_n_s_maxsize;
  static PyObject *__pyx_n_s_mean;
  static PyObject *__pyx_n_s_memoize;
  static PyObject *__pyx_n_s_memptr;
  static PyObject *__pyx_n_s_memview;
  static PyObject *__pyx_n_s_merge_kernel;
  static PyObject *__pyx_n_s_metaclass;
  static PyObject *__pyx_n_s_min;
  static PyObject *__pyx_kp_s_min_max_st_type_in0_raw;
  static PyObject *__pyx_kp_s_min_max_st_type_in0_raw_in0;
  static PyObject *__pyx_kp_s_min_max_st_type_in0_raw_in0__J;
  static PyObject *__pyx_n_s_mode;
  static PyObject *__pyx_n_s_module;
  static PyObject *__pyx_n_s_module_2;
  static PyObject *__pyx_n_s_moves;
  static PyObject *__pyx_n_s_multiply;
  static PyObject *__pyx_kp_s_my_argmax_a_b;
  static PyObject *__pyx_kp_s_my_argmax_float_a_b;
  static PyObject *__pyx_kp_s_my_argmin_a_b;
  static PyObject *__pyx_kp_s_my_argmin_float_a_b;
  static PyObject *__pyx_kp_s_my_max_a_b;
  static PyObject *__pyx_kp_s_my_max_float_a_b;
  static PyObject *__pyx_kp_s_my_min_a_b;
  static PyObject *__pyx_kp_s_my_min_float_a_b;
  static PyObject *__pyx_n_s_n;
  static PyObject *__pyx_n_s_n_args;
  static PyObject *__pyx_n_s_name;
  static PyObject *__pyx_n_s_name_2;
  static PyObject *__pyx_n_s_nanmax;
  static PyObject *__pyx_n_s_nanmin;
  static PyObject *__pyx_n_s_nargs;
  static PyObject *__pyx_n_s_nbytes;
  static PyObject *__pyx_n_s_ndarray;
  static PyObject *__pyx_kp_u_ndarray___getitem___line_1507;
  static PyObject *__pyx_kp_u_ndarray___setitem___line_1553;
  static PyObject *__pyx_n_s_ndim;
  static PyObject *__pyx_n_s_ndmin;
  static PyObject *__pyx_n_s_negative;
  static PyObject *__pyx_n_s_new;
  static PyObject *__pyx_n_s_newshape;
  static PyObject *__pyx_n_s_nin;
  static PyObject *__pyx_n_s_no_bool;
  static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
  static PyObject *__pyx_kp_s_non_scalar_numpy_ndarray_cannot;
  static PyObject *__pyx_n_s_nonzero_1d_kernel;
  static PyObject *__pyx_n_s_nonzero_1d_kernel_2;
  static PyObject *__pyx_n_s_nonzero_kernel;
  static PyObject *__pyx_n_s_nonzero_kernel_2;
  static PyObject *__pyx_n_s_not_equal;
  static PyObject *__pyx_n_s_nout;
  static PyObject *__pyx_n_s_numpy;
  static PyObject *__pyx_n_s_obj;
  static PyObject *__pyx_n_s_object;
  static PyObject *__pyx_n_s_oct;
  static PyObject *__pyx_n_s_offset;
  static PyObject *__pyx_kp_s_only_integers_slices_ellipsis_nu;
  static PyObject *__pyx_n_s_op;
  static PyObject *__pyx_n_s_open;
  static PyObject *__pyx_kp_s_operands_could_not_be_broadcast;
  static PyObject *__pyx_n_s_operation;
  static PyObject *__pyx_n_s_ops;
  static PyObject *__pyx_n_s_ops_2;
  static PyObject *__pyx_n_s_options;
  static PyObject *__pyx_n_s_order;
  static PyObject *__pyx_kp_s_order_not_understood;
  static PyObject *__pyx_kp_s_order_not_understood_order;
  static PyObject *__pyx_n_s_os;
  static PyObject *__pyx_n_s_out;
  static PyObject *__pyx_kp_s_out0_0;
  static PyObject *__pyx_kp_s_out0__floor_divide_in0_in1;
  static PyObject *__pyx_kp_s_out0_a;
  static PyObject *__pyx_kp_s_out0_a__type_reduce__in_ind_size;
  static PyObject *__pyx_kp_s_out0_a_index;
  static PyObject *__pyx_kp_s_out0_a_value;
  static PyObject *__pyx_kp_s_out0_abs_in0;
  static PyObject *__pyx_kp_s_out0_arg_in0;
  static PyObject *__pyx_kp_s_out0_conj_in0;
  static PyObject *__pyx_kp_s_out0_fabs_in0;
  static PyObject *__pyx_kp_s_out0_fabsf_in0;
  static PyObject *__pyx_kp_s_out0_imag_in0;
  static PyObject *__pyx_kp_s_out0_in0;
  static PyObject *__pyx_kp_s_out0_in0_0_0_M_PI;
  static PyObject *__pyx_kp_s_out0_in0_0_in0_in0;
  static PyObject *__pyx_kp_s_out0_in0_2;
  static PyObject *__pyx_kp_s_out0_in0_3;
  static PyObject *__pyx_kp_s_out0_in0_4;
  static PyObject *__pyx_kp_s_out0_in0__floor_divide_in0_in1_i;
  static PyObject *__pyx_kp_s_out0_in0__floor_divide_in0_in1_i_2;
  static PyObject *__pyx_kp_s_out0_in0_imag;
  static PyObject *__pyx_kp_s_out0_in0_in1;
  static PyObject *__pyx_kp_s_out0_in0_in1_in1_in0_in2_in2_in0;
  static PyObject *__pyx_kp_s_out0_in0_real;
  static PyObject *__pyx_kp_s_out0_in0_s_in1;
  static PyObject *__pyx_kp_s_out0_in1_0_0_floor_double_in0_do;
  static PyObject *__pyx_kp_s_out0_out0_type_in0;
  static PyObject *__pyx_kp_s_out0_out0_type_in0_out0_type_in1;
  static PyObject *__pyx_kp_s_out0_pow_in0_in1;
  static PyObject *__pyx_kp_s_out0_powf_in0_in1;
  static PyObject *__pyx_kp_s_out0_real_in0;
  static PyObject *__pyx_kp_s_out0_rint_pow_double_in0_double;
  static PyObject *__pyx_kp_s_out0_sqrt_in0;
  static PyObject *__pyx_kp_s_out0_type_a__floor_divide_in0_i;
  static PyObject *__pyx_kp_s_out0_type_out0_raw_a;
  static PyObject *__pyx_kp_s_out_0__type_out_0__raw_out_0__in;
  static PyObject *__pyx_kp_s_out_a;
  static PyObject *__pyx_kp_s_out_alpha_a;
  static PyObject *__pyx_n_s_out_arg_dtype;
  static PyObject *__pyx_n_s_out_args;
  static PyObject *__pyx_n_s_out_args_dtype;
  static PyObject *__pyx_n_s_out_clp2_size;
  static PyObject *__pyx_n_s_out_indexer;
  static PyObject *__pyx_n_s_out_ndarray_types;
  static PyObject *__pyx_n_s_out_params;
  static PyObject *__pyx_n_s_out_params_2;
  static PyObject *__pyx_n_s_out_shape;
  static PyObject *__pyx_n_s_out_str;
  static PyObject *__pyx_n_s_out_types;
  static PyObject *__pyx_n_s_output_expr;
  static PyObject *__pyx_n_s_output_expr_2;
  static PyObject *__pyx_kp_s_output_typecode_could_not_be_coe;
  static PyObject *__pyx_n_s_p;
  static PyObject *__pyx_n_s_pack;
  static PyObject *__pyx_n_s_param;
  static PyObject *__pyx_n_s_params;
  static PyObject *__pyx_n_s_params_2;
  static PyObject *__pyx_n_s_partition_kernel;
  static PyObject *__pyx_n_s_partition_kernel_2;
  static PyObject *__pyx_n_s_partition_merge_kernel;
  static PyObject *__pyx_n_s_path;
  static PyObject *__pyx_n_s_pickle;
  static PyObject *__pyx_n_s_pop;
  static PyObject *__pyx_n_s_post_map_expr;
  static PyObject *__pyx_n_s_power;
  static PyObject *__pyx_n_s_pre_map_expr;
  static PyObject *__pyx_n_s_preamble;
  static PyObject *__pyx_n_s_preamble_2;
  static PyObject *__pyx_kp_s_preamble_extern_C___global___vo;
  static PyObject *__pyx_n_s_prepare;
  static PyObject *__pyx_n_s_prev;
  static PyObject *__pyx_n_s_prod;
  static PyObject *__pyx_n_s_prod_auto_dtype;
  static PyObject *__pyx_n_s_prod_keep_dtype;
  static PyObject *__pyx_n_s_property;
  static PyObject *__pyx_kp_s_provided_op_is_not_supported;
  static PyObject *__pyx_n_s_ptr;
  static PyObject *__pyx_kp_s_ptrdiff_t_axis_ind__ind_get_axi;
  static PyObject *__pyx_kp_s_ptrdiff_t_middle_i_base_ptrdiff;
  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_ElementwiseKernel;
  static PyObject *__pyx_n_s_pyx_unpickle_Enum;
  static PyObject *__pyx_n_s_pyx_unpickle_Indexer;
  static PyObject *__pyx_n_s_pyx_unpickle_ParameterInfo;
  static PyObject *__pyx_n_s_pyx_unpickle_broadcast;
  static PyObject *__pyx_n_s_pyx_vtable;
  static PyObject *__pyx_kp_s_q;
  static PyObject *__pyx_kp_s_q_2;
  static PyObject *__pyx_kp_s_q_d;
  static PyObject *__pyx_kp_s_q_q;
  static PyObject *__pyx_kp_s_q_q_2;
  static PyObject *__pyx_kp_s_qq;
  static PyObject *__pyx_kp_s_qq_d;
  static PyObject *__pyx_kp_s_qq_q;
  static PyObject *__pyx_kp_s_qq_qq;
  static PyObject *__pyx_kp_s_qqq_q;
  static PyObject *__pyx_n_s_qualname;
  static PyObject *__pyx_n_s_radd;
  static PyObject *__pyx_n_s_raise;
  static PyObject *__pyx_n_s_rand;
  static PyObject *__pyx_n_s_range;
  static PyObject *__pyx_n_s_ravel;
  static PyObject *__pyx_n_s_raw;
  static PyObject *__pyx_n_s_raw_2;
  static PyObject *__pyx_kp_s_raw_P_x_int32_axis_raw_int64_cum;
  static PyObject *__pyx_kp_s_raw_P_x_int64_base;
  static PyObject *__pyx_kp_s_raw_T_a;
  static PyObject *__pyx_kp_s_raw_T_a_S_indices_int32_cdim_int;
  static PyObject *__pyx_kp_s_raw_T_a_S_indices_int32_rdim_S_i;
  static PyObject *__pyx_kp_s_raw_T_out;
  static PyObject *__pyx_kp_s_raw_T_v_S_indices_int32_cdim_int;
  static PyObject *__pyx_kp_s_raw_T_v_bool_mask_S_mask_scanned;
  static PyObject *__pyx_n_s_raxis;
  static PyObject *__pyx_n_s_rdiv;
  static PyObject *__pyx_n_s_rdivmod;
  static PyObject *__pyx_n_s_read;
  static PyObject *__pyx_n_s_real;
  static PyObject *__pyx_n_s_real_setter;
  static PyObject *__pyx_n_s_record;
  static PyObject *__pyx_n_s_reduce;
  static PyObject *__pyx_n_s_reduce_cython;
  static PyObject *__pyx_n_s_reduce_dims;
  static PyObject *__pyx_n_s_reduce_ex;
  static PyObject *__pyx_n_s_reduce_expr;
  static PyObject *__pyx_n_s_reduce_kernel;
  static PyObject *__pyx_n_s_reduce_type;
  static PyObject *__pyx_n_s_reduced_view;
  static PyObject *__pyx_n_s_remainder;
  static PyObject *__pyx_n_s_repeat;
  static PyObject *__pyx_kp_s_repeated_axis;
  static PyObject *__pyx_n_s_repeats;
  static PyObject *__pyx_kp_s_repeats_and_axis_of_a_should_be;
  static PyObject *__pyx_kp_s_repeats_should_be_int_or_sequen;
  static PyObject *__pyx_kp_s_repeats_should_not_be_negative;
  static PyObject *__pyx_n_s_repr;
  static PyObject *__pyx_n_s_require_sortable_dtype;
  static PyObject *__pyx_kp_s_requires_a_ndim_1;
  static PyObject *__pyx_n_s_reshape;
  static PyObject *__pyx_n_s_reshape_2;
  static PyObject *__pyx_n_s_result_type;
  static PyObject *__pyx_n_s_ret;
  static PyObject *__pyx_n_s_ret_shape;
  static PyObject *__pyx_n_s_rfloordiv;
  static PyObject *__pyx_n_s_ri;
  static PyObject *__pyx_n_s_right_shift;
  static PyObject *__pyx_n_s_rlshift;
  static PyObject *__pyx_n_s_rmatmul;
  static PyObject *__pyx_n_s_rmod;
  static PyObject *__pyx_n_s_rmul;
  static PyObject *__pyx_n_s_rollaxis;
  static PyObject *__pyx_n_s_ror;
  static PyObject *__pyx_n_s_routine;
  static PyObject *__pyx_n_s_routine_cache;
  static PyObject *__pyx_n_s_rpow;
  static PyObject *__pyx_n_s_rrshift;
  static PyObject *__pyx_n_s_rsub;
  static PyObject *__pyx_n_s_rtruediv;
  static PyObject *__pyx_n_s_rundim;
  static PyObject *__pyx_n_s_rxor;
  static PyObject *__pyx_kp_s_s;
  static PyObject *__pyx_n_s_s_2;
  static PyObject *__pyx_kp_s_s_s;
  static PyObject *__pyx_kp_s_s_s_s;
  static PyObject *__pyx_n_s_same_kind;
  static PyObject *__pyx_n_s_same_shape_and_contiguous;
  static PyObject *__pyx_kp_s_scatter_add_only_supports_int32;
  static PyObject *__pyx_n_s_self;
  static PyObject *__pyx_kp_s_self_ptr_cannot_be_converted_to;
  static PyObject *__pyx_kp_s_self_ptr_self_val_cannot_be_conv;
  static PyObject *__pyx_n_s_send;
  static PyObject *__pyx_n_s_sep;
  static PyObject *__pyx_n_s_set;
  static PyObject *__pyx_n_s_set_shape_and_strides;
  static PyObject *__pyx_n_s_setstate;
  static PyObject *__pyx_n_s_setstate_cython;
  static PyObject *__pyx_n_s_sgeam;
  static PyObject *__pyx_n_s_sgemmBatched;
  static PyObject *__pyx_n_s_sgemmStridedBatched;
  static PyObject *__pyx_n_s_shape;
  static PyObject *__pyx_n_s_shape_2;
  static PyObject *__pyx_kp_s_shape_mismatch_objects_cannot_be;
  static PyObject *__pyx_kp_s_shapes_and_not_aligned;
  static PyObject *__pyx_n_s_shared_mem;
  static PyObject *__pyx_n_s_short;
  static PyObject *__pyx_kp_s_signed_char;
  static PyObject *__pyx_n_s_simple_reduction_function;
  static PyObject *__pyx_n_s_simple_reduction_function___call;
  static PyObject *__pyx_n_s_simple_reduction_function___init;
  static PyObject *__pyx_n_s_six;
  static PyObject *__pyx_n_s_size;
  static PyObject *__pyx_n_s_slices;
  static PyObject *__pyx_n_s_sort;
  static PyObject *__pyx_n_s_source;
  static PyObject *__pyx_kp_s_source_and_destination_argument;
  static PyObject *__pyx_n_s_split;
  static PyObject *__pyx_n_s_sqrt;
  static PyObject *__pyx_n_s_squeeze;
  static PyObject *__pyx_n_s_src_dtype;
  static PyObject *__pyx_n_s_src_ndim;
  static PyObject *__pyx_n_s_start;
  static PyObject *__pyx_n_s_start_adr;
  static PyObject *__pyx_kp_s_static_cast_U_x_static_cast_U_y;
  static PyObject *__pyx_n_s_std;
  static PyObject *__pyx_n_s_step;
  static PyObject *__pyx_n_s_stop;
  static PyObject *__pyx_n_s_stream;
  static PyObject *__pyx_n_s_stride;
  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_strides;
  static PyObject *__pyx_n_s_string;
  static PyObject *__pyx_kp_s_stringsource;
  static PyObject *__pyx_n_s_strip;
  static PyObject *__pyx_n_s_struct;
  static PyObject *__pyx_n_s_subok;
  static PyObject *__pyx_kp_s_subok_is_not_supported_yet;
  static PyObject *__pyx_n_s_substitute;
  static PyObject *__pyx_n_s_subtract;
  static PyObject *__pyx_n_s_sum;
  static PyObject *__pyx_n_s_sum_auto_dtype;
  static PyObject *__pyx_n_s_sum_keep_dtype;
  static PyObject *__pyx_n_s_super;
  static PyObject *__pyx_n_s_swapaxes;
  static PyObject *__pyx_n_s_sys;
  static PyObject *__pyx_n_s_t;
  static PyObject *__pyx_kp_s_t_n__raw__n__ind_get;
  static PyObject *__pyx_n_s_take;
  static PyObject *__pyx_kp_s_template_typename_T___device;
  static PyObject *__pyx_kp_s_template_typename_T_struct_min;
  static PyObject *__pyx_n_s_tensordot_core_mul_sum;
  static PyObject *__pyx_n_s_test;
  static PyObject *__pyx_kp_s_this_op_is_not_supported;
  static PyObject *__pyx_n_s_throw;
  static PyObject *__pyx_n_s_thrust;
  static PyObject *__pyx_n_s_thrust_enabled;
  static PyObject *__pyx_kp_s_to_environment_variable_CUDA_PAT;
  static PyObject *__pyx_n_s_tofile;
  static PyObject *__pyx_n_s_tolist;
  static PyObject *__pyx_kp_s_too_many_indices_for_array;
  static PyObject *__pyx_kp_s_total_size_of_new_array_must_be;
  static PyObject *__pyx_n_s_trace;
  static PyObject *__pyx_n_s_trans;
  static PyObject *__pyx_n_s_transpose;
  static PyObject *__pyx_n_s_transpose_2;
  static PyObject *__pyx_n_s_true;
  static PyObject *__pyx_n_s_true_divide;
  static PyObject *__pyx_n_s_tup;
  static PyObject *__pyx_n_s_type;
  static PyObject *__pyx_n_s_type_dict;
  static PyObject *__pyx_kp_s_type_out0_raw_out0__raw_out0__ou;
  static PyObject *__pyx_n_s_type_preamble;
  static PyObject *__pyx_kp_s_type_preamble_preamble_define_R;
  static PyObject *__pyx_kp_s_typedef_s_in_d_type;
  static PyObject *__pyx_kp_s_typedef_s_out_d_type;
  static PyObject *__pyx_kp_s_typedef_s_s;
  static PyObject *__pyx_kp_s_typedef_s_type_in0_raw_typedef_s;
  static PyObject *__pyx_n_s_types;
  static PyObject *__pyx_n_s_types_preamble;
  static PyObject *__pyx_n_s_u;
  static PyObject *__pyx_n_s_ufunc;
  static PyObject *__pyx_n_s_ufunc___call;
  static PyObject *__pyx_n_s_ufunc___init;
  static PyObject *__pyx_n_s_ufunc___init___locals_genexpr;
  static PyObject *__pyx_n_s_ufunc___repr;
  static PyObject *__pyx_kp_s_ufunc_s;
  static PyObject *__pyx_n_s_ufunc_types;
  static PyObject *__pyx_n_s_uint16;
  static PyObject *__pyx_n_s_uint32;
  static PyObject *__pyx_n_s_uint64;
  static PyObject *__pyx_n_s_uint8;
  static PyObject *__pyx_n_s_uintp;
  static PyObject *__pyx_n_s_ulonglong;
  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_unknown_ctype;
  static PyObject *__pyx_n_s_unpack;
  static PyObject *__pyx_n_s_unsafe;
  static PyObject *__pyx_kp_s_unsigned_char;
  static PyObject *__pyx_kp_s_unsigned_int;
  static PyObject *__pyx_kp_s_unsigned_long_long;
  static PyObject *__pyx_kp_s_unsigned_short;
  static PyObject *__pyx_n_s_update;
  static PyObject *__pyx_n_s_update_c_contiguity;
  static PyObject *__pyx_n_s_update_c_contiguity_2;
  static PyObject *__pyx_n_s_update_contiguity;
  static PyObject *__pyx_n_s_update_f_contiguity;
  static PyObject *__pyx_n_s_util;
  static PyObject *__pyx_n_s_v;
  static PyObject *__pyx_n_s_value;
  static PyObject *__pyx_n_s_var;
  static PyObject *__pyx_n_s_var_2;
  static PyObject *__pyx_n_s_var_core;
  static PyObject *__pyx_n_s_version_info;
  static PyObject *__pyx_n_s_view;
  static PyObject *__pyx_n_s_warn;
  static PyObject *__pyx_n_s_warnings;
  static PyObject *__pyx_n_s_wrap;
  static PyObject *__pyx_n_s_x;
  static PyObject *__pyx_kp_u_x___getitem___y_x_y_Supports_bot;
  static PyObject *__pyx_kp_u_x___setitem___slices_y_x_slices;
  static PyObject *__pyx_kp_s_x_mean_x_mean;
  static PyObject *__pyx_kp_s_y_choices_i_n_channel_a;
  static PyObject *__pyx_kp_s_zero_dimensional_arrays_cannot_b;
  static PyObject *__pyx_kp_s_zero_size_array_to_reduction_ope;
  static PyObject *__pyx_n_s_zeros;
  static PyObject *__pyx_n_s_zgemmBatched;
  static PyObject *__pyx_n_s_zgemmStridedBatched;
  static PyObject *__pyx_n_s_zip;
static PyObject *__pyx_pf_4cupy_4core_4core_17IndexOrValueError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static int __pyx_pf_4cupy_4core_4core_7ndarray___init__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_shape, PyObject *__pyx_v_dtype, PyObject *__pyx_v_memptr, PyObject *__pyx_v_order); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_5flags___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_5shape___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static int __pyx_pf_4cupy_4core_4core_7ndarray_5shape_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_newshape); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_7strides___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4ndim___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_8itemsize___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_6nbytes___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_1T___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_7cstruct___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_2tolist(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4tofile(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_fid, PyObject *__pyx_v_sep, PyObject *__pyx_v_format); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_6dump(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_file); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_8dumps(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_10astype(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype, PyObject *__pyx_v_order, PyObject *__pyx_v_casting, PyObject *__pyx_v_subok, PyObject *__pyx_v_copy); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_12copy(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_order); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_14view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_16fill(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_18_reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_shape); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_20reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_shape); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_22_transpose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_axes); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_24transpose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axes); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_26swapaxes(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, Py_ssize_t __pyx_v_axis1, Py_ssize_t __pyx_v_axis2); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_28flatten(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_30ravel(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_32squeeze(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_34take(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_indices, PyObject *__pyx_v_axis, PyObject *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_36repeat(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_repeats, PyObject *__pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_38choose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_choices, PyObject *__pyx_v_out, PyObject *__pyx_v_mode); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_40sort(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_42argsort(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_44partition(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_kth, PyObject *__pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_46argpartition(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_kth, PyObject *__pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_48nonzero(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_50diagonal(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_offset, PyObject *__pyx_v_axis1, PyObject *__pyx_v_axis2); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_52max(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_dtype, PyObject *__pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_54argmax(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_dtype, PyObject *__pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_56min(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_dtype, PyObject *__pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_58argmin(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_dtype, PyObject *__pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_60clip(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_a_min, PyObject *__pyx_v_a_max, PyObject *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_62trace(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_offset, PyObject *__pyx_v_axis1, PyObject *__pyx_v_axis2, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_64sum(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_66mean(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_68var(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_ddof, PyObject *__pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_70std(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_ddof, PyObject *__pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_72prod(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_74all(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_76any(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_78__richcmp__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /* proto */
static int __pyx_pf_4cupy_4core_4core_7ndarray_80__nonzero__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_82__neg__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_84__pos__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_86__abs__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_88__invert__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_90__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_92__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_94__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
#if PY_VERSION_HEX >= 0x03050000
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_96__matmul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
#endif
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_98__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
#endif
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_100__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_102__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_104__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_106__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_108__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, CYTHON_UNUSED PyObject *__pyx_v_modulo); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_110__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_112__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_114__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_116__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_118__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_120__iadd__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_122__isub__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_124__imul__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_126__idiv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
#endif
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_128__itruediv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_130__ifloordiv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_132__imod__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_134__ipow__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_136__ilshift__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_138__irshift__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_140__iand__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_142__ior__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_144__ixor__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_146conj(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4real___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static int __pyx_pf_4cupy_4core_4core_7ndarray_4real_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4imag___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static int __pyx_pf_4cupy_4core_4core_7ndarray_4imag_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_148__copy__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_150__deepcopy__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_memo); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_152__reduce__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_154__array__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype); /* proto */
static Py_ssize_t __pyx_pf_4cupy_4core_4core_7ndarray_156__len__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_158__getitem__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices); /* proto */
static int __pyx_pf_4cupy_4core_4core_7ndarray_160__setitem__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_162scatter_add(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_164__int__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_166__long__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
#endif
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_168__float__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_170__complex__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_172__oct__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
#endif
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_174__hex__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
#endif
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_176__repr__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_178__str__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_180dot(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_6device___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_182get(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_stream); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_184set(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_stream); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_186reduced_view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_188_update_c_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_190_update_f_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_192_update_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_194_set_shape_and_strides(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_shape, std::vector<Py_ssize_t>  __pyx_v_strides, int __pyx_v_update_c_contiguity); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4size___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_6_shape___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static int __pyx_pf_4cupy_4core_4core_7ndarray_6_shape_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_8_strides___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static int __pyx_pf_4cupy_4core_4core_7ndarray_8_strides_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_13_c_contiguous___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_13_f_contiguous___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_5dtype___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4data___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4base___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core__get_strides_for_nocopy_reshape(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, std::vector<Py_ssize_t>  __pyx_v_newshape); /* proto */
static int __pyx_pf_4cupy_4core_4core_6CArray___init__(struct __pyx_obj_4cupy_4core_4core_CArray *__pyx_v_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_6CArray_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_CArray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_6CArray_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_CArray *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4cupy_4core_4core_8CIndexer___init__(struct __pyx_obj_4cupy_4core_4core_CIndexer *__pyx_v_self, Py_ssize_t __pyx_v_size, PyObject *__pyx_v_shape); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_8CIndexer_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_CIndexer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_8CIndexer_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_CIndexer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4cupy_4core_4core_7Indexer___init__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self, PyObject *__pyx_v_shape); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_4ndim___get__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_4size___get__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_5shape___get__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_2__reduce_cython__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_4__setstate_cython__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_2_get_header_dir_path(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_4_get_header_source(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_6compile_with_cache(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_source, PyObject *__pyx_v_options, PyObject *__pyx_v_arch, PyObject *__pyx_v_cachd_dir); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_8_get_simple_elementwise_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_params, PyObject *__pyx_v_operation, PyObject *__pyx_v_name, PyObject *__pyx_v_preamble, PyObject *__pyx_v_loop_prep, PyObject *__pyx_v_after_loop, PyObject *__pyx_v_options); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_10_python_scalar_to_numpy_scalar(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_12_get_typename(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_14_preprocess_args(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_16_get_args_info(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_18_get_kernel_params(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_params, PyObject *__pyx_v_args_info); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_20_reduce_dims(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args, PyObject *__pyx_v_params, PyObject *__pyx_v_shape); /* proto */
static int __pyx_pf_4cupy_4core_4core_13ParameterInfo___init__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self, PyObject *__pyx_v_param, int __pyx_v_is_const); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_4name___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_5dtype___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_5ctype___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_3raw___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_8is_const___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_2__reduce_cython__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_4__setstate_cython__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_22_get_param_info(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_s, PyObject *__pyx_v_is_const); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_24_decide_params_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_params, PyObject *__pyx_v_out_params, PyObject *__pyx_v_in_args_dtype, PyObject *__pyx_v_out_args_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_23_get_elementwise_kernel_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_26_get_elementwise_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args_info, PyObject *__pyx_v_types, PyObject *__pyx_v_params, PyObject *__pyx_v_operation, PyObject *__pyx_v_name, PyObject *__pyx_v_preamble, PyObject *__pyx_v_kwargs); /* proto */
static int __pyx_pf_4cupy_4core_4core_17ElementwiseKernel___init__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self, PyObject *__pyx_v_in_params, PyObject *__pyx_v_out_params, PyObject *__pyx_v_operation, PyObject *__pyx_v_name, PyObject *__pyx_v_reduce_dims, PyObject *__pyx_v_preamble, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_2__call__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_9in_params___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_10out_params___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_3nin___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_4nout___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_5nargs___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_6params___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_9operation___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_4name___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_11reduce_dims___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_8preamble___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_6kwargs___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_4__reduce_cython__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_6__setstate_cython__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_28_get_ufunc_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_types, PyObject *__pyx_v_out_types, PyObject *__pyx_v_routine, PyObject *__pyx_v_args_info, PyObject *__pyx_v_params, PyObject *__pyx_v_name, PyObject *__pyx_v_preamble); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_8__init___genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_8__init___3genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_nin, PyObject *__pyx_v_nout, PyObject *__pyx_v_ops, PyObject *__pyx_v_preamble, PyObject *__pyx_v_doc, PyObject *__pyx_v_default_casting); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_2__repr__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_4types(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_6__call__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_30create_ufunc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_ops, PyObject *__pyx_v_routine, PyObject *__pyx_v_preamble, PyObject *__pyx_v_doc, PyObject *__pyx_v_default_casting); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_32_get_simple_reduction_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_block_size, PyObject *__pyx_v_reduce_type, PyObject *__pyx_v_params, PyObject *__pyx_v_identity, PyObject *__pyx_v_pre_map_expr, PyObject *__pyx_v_reduce_expr, PyObject *__pyx_v_post_map_expr, PyObject *__pyx_v_type_preamble, PyObject *__pyx_v_input_expr, PyObject *__pyx_v_output_expr, PyObject *__pyx_v_preamble, PyObject *__pyx_v_options); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_34_get_axis(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_axis, Py_ssize_t __pyx_v_ndim); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_36_get_out_shape(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_shape, PyObject *__pyx_v_axis, PyObject *__pyx_v_raxis, int __pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_38_get_trans_args(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args, PyObject *__pyx_v_trans, PyObject *__pyx_v_shape, PyObject *__pyx_v_params); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_40_get_inout_args(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_args, PyObject *__pyx_v_out_args, struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_in_indexer, struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_out_indexer, PyObject *__pyx_v_out_clp2_size, PyObject *__pyx_v_params, int __pyx_v_reduce_dims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_42_get_simple_reduction_function(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_routine, PyObject *__pyx_v_params, PyObject *__pyx_v_args_info, PyObject *__pyx_v_in_arg_dtype, PyObject *__pyx_v_out_arg_dtype, PyObject *__pyx_v_out_types, PyObject *__pyx_v_name, PyObject *__pyx_v_block_size, PyObject *__pyx_v_identity, PyObject *__pyx_v_input_expr, PyObject *__pyx_v_output_expr, PyObject *__pyx_v__preamble, PyObject *__pyx_v_options); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_25simple_reduction_function___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_ops, PyObject *__pyx_v_identity, PyObject *__pyx_v_preamble); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_25simple_reduction_function_2__call__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out, int __pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_21_get_reduction_kernel_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_44_get_reduction_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_params, PyObject *__pyx_v_args_info, PyObject *__pyx_v_types, PyObject *__pyx_v_name, PyObject *__pyx_v_block_size, PyObject *__pyx_v_reduce_type, PyObject *__pyx_v_identity, PyObject *__pyx_v_map_expr, PyObject *__pyx_v_reduce_expr, PyObject *__pyx_v_post_map_expr, PyObject *__pyx_v_preamble, PyObject *__pyx_v_options); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_15ReductionKernel___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_in_params, PyObject *__pyx_v_out_params, PyObject *__pyx_v_map_expr, PyObject *__pyx_v_reduce_expr, PyObject *__pyx_v_post_map_expr, PyObject *__pyx_v_identity, PyObject *__pyx_v_name, PyObject *__pyx_v_reduce_type, PyObject *__pyx_v_reduce_dims, PyObject *__pyx_v_preamble, PyObject *__pyx_v_options); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_15ReductionKernel_2__call__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_46create_reduction_func(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_ops, PyObject *__pyx_v_routine, PyObject *__pyx_v_identity, PyObject *__pyx_v_preamble); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_48array(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj, PyObject *__pyx_v_dtype, int __pyx_v_copy, PyObject *__pyx_v_order, int __pyx_v_subok, Py_ssize_t __pyx_v_ndmin); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_50ascontiguousarray(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_52asfortranarray(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_54_has_element(CYTHON_UNUSED PyObject *__pyx_self, std::vector<Py_ssize_t>  __pyx_v_source, Py_ssize_t __pyx_v_n); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_56normalize_axis_tuple(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_axis, Py_ssize_t __pyx_v_ndim); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_58moveaxis(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_source, PyObject *__pyx_v_destination); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_60rollaxis(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, Py_ssize_t __pyx_v_axis, Py_ssize_t __pyx_v_start); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_62array_split(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ary, PyObject *__pyx_v_indices_or_sections, Py_ssize_t __pyx_v_axis); /* proto */
static int __pyx_pf_4cupy_4core_4core_9broadcast___init__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self, PyObject *__pyx_v_arrays); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_6values___get__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_5shape___get__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_4size___get__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_2nd___get__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_2__reduce_cython__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_4__setstate_cython__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_64broadcast_to(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_array, PyObject *__pyx_v_shape); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_66_repeat(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_repeats, PyObject *__pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_68concatenate_method(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tup, int __pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_70_concatenate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arrays, Py_ssize_t __pyx_v_axis, PyObject *__pyx_v_shape, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_72_concatenate_single_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arrays, Py_ssize_t __pyx_v_axis, PyObject *__pyx_v_shape, PyObject *__pyx_v_dtype, int __pyx_v_same_shape_and_contiguous); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_74size(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_76_create_bit_op(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_op, PyObject *__pyx_v_no_bool, PyObject *__pyx_v_doc); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_78_prepare_slice_list(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_slices, Py_ssize_t __pyx_v_ndim); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_80_prepare_mask_indexing_single(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, Py_ssize_t __pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_82_getitem_mask_single(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, int __pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_84_take(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_indices, PyObject *__pyx_v_li, PyObject *__pyx_v_ri, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_86_scatter_op_single(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_indices, PyObject *__pyx_v_v, Py_ssize_t __pyx_v_li, Py_ssize_t __pyx_v_ri, PyObject *__pyx_v_op); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_88_scatter_op_mask_single(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, PyObject *__pyx_v_v, Py_ssize_t __pyx_v_axis, PyObject *__pyx_v_op); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_90_scatter_op(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices, PyObject *__pyx_v_value, PyObject *__pyx_v_op); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_92_diagonal(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, Py_ssize_t __pyx_v_offset, Py_ssize_t __pyx_v_axis1, Py_ssize_t __pyx_v_axis2); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_94_prepare_multiple_array_indexing(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_96_getitem_multiple(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_98dot(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_100_get_all_addresses(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_start_adr, std::vector<size_t>  __pyx_v_shape, std::vector<size_t>  __pyx_v_strides); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_102_get_stride_for_strided_batched_gemm(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_104matmul(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_106tensordot_core(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out, Py_ssize_t __pyx_v_n, Py_ssize_t __pyx_v_m, Py_ssize_t __pyx_v_k, std::vector<Py_ssize_t>  __pyx_v_ret_shape); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_108_mat_to_cublas_contiguous(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, Py_ssize_t __pyx_v_trans); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_110_to_cublas_vector(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, Py_ssize_t __pyx_v_rundim); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_112create_comparison(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_op, PyObject *__pyx_v_doc, PyObject *__pyx_v_require_sortable_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_114_var(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_ddof, PyObject *__pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_116_std(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_ddof, PyObject *__pyx_v_keepdims); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_118_inclusive_scan_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype, PyObject *__pyx_v_block_size); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_120_add_scan_blocked_sum_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_122_nonzero_1d_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_src_dtype, PyObject *__pyx_v_index_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_124_nonzero_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_src_dtype, PyObject *__pyx_v_src_ndim, PyObject *__pyx_v_index_dtype, PyObject *__pyx_v_dst_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_126scan(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_128_partition_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_130__pyx_unpickle_Indexer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_132__pyx_unpickle_ParameterInfo(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_134__pyx_unpickle_ElementwiseKernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_136__pyx_unpickle_broadcast(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* 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_4cupy_4core_4core_ndarray(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_4core_4core_Indexer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_4core_4core_CArray(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_4core_4core_CIndexer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_4core_4core_ParameterInfo(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_4core_4core_ElementwiseKernel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_4core_4core_broadcast(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_1_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_2___init__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_3_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_4_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_6_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*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 __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_get = {0, &__pyx_n_s_get, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items = {0, &__pyx_n_s_items, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop = {0, &__pyx_n_s_pop, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyList_Type_index = {0, &__pyx_n_s_index, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyString_Type_split = {0, &__pyx_n_s_split, 0, 0, 0};
static PyObject *__pyx_float_0_;
static PyObject *__pyx_float_1_;
static PyObject *__pyx_float_0_0;
static PyObject *__pyx_float_1_0;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_32;
static PyObject *__pyx_int_70;
static PyObject *__pyx_int_100;
static PyObject *__pyx_int_256;
static PyObject *__pyx_int_512;
static PyObject *__pyx_int_1024;
static PyObject *__pyx_int_7500;
static PyObject *__pyx_int_8000;
static PyObject *__pyx_int_9000;
static PyObject *__pyx_int_5472103;
static PyObject *__pyx_int_114586425;
static PyObject *__pyx_int_121017544;
static PyObject *__pyx_int_131642003;
static PyObject *__pyx_int_184977713;
static PyObject *__pyx_int_2147483647;
static PyObject *__pyx_int_2147483648;
static PyObject *__pyx_int_4294967296;
static PyObject *__pyx_int_9223372036854775808;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_int_neg_2;
static PyObject *__pyx_k__3;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_slice__19;
static PyObject *__pyx_slice__21;
static PyObject *__pyx_slice__90;
static PyObject *__pyx_slice__97;
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__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__27;
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_tuple__34;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__37;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__44;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__46;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__48;
static PyObject *__pyx_tuple__49;
static PyObject *__pyx_tuple__50;
static PyObject *__pyx_tuple__51;
static PyObject *__pyx_tuple__52;
static PyObject *__pyx_tuple__54;
static PyObject *__pyx_tuple__55;
static PyObject *__pyx_tuple__58;
static PyObject *__pyx_tuple__59;
static PyObject *__pyx_tuple__60;
static PyObject *__pyx_tuple__61;
static PyObject *__pyx_tuple__62;
static PyObject *__pyx_tuple__63;
static PyObject *__pyx_tuple__64;
static PyObject *__pyx_tuple__65;
static PyObject *__pyx_tuple__66;
static PyObject *__pyx_tuple__67;
static PyObject *__pyx_tuple__68;
static PyObject *__pyx_tuple__69;
static PyObject *__pyx_tuple__70;
static PyObject *__pyx_tuple__72;
static PyObject *__pyx_tuple__73;
static PyObject *__pyx_tuple__74;
static PyObject *__pyx_tuple__75;
static PyObject *__pyx_tuple__76;
static PyObject *__pyx_tuple__77;
static PyObject *__pyx_tuple__78;
static PyObject *__pyx_tuple__79;
static PyObject *__pyx_tuple__80;
static PyObject *__pyx_tuple__81;
static PyObject *__pyx_tuple__82;
static PyObject *__pyx_tuple__83;
static PyObject *__pyx_tuple__84;
static PyObject *__pyx_tuple__85;
static PyObject *__pyx_tuple__86;
static PyObject *__pyx_tuple__87;
static PyObject *__pyx_tuple__88;
static PyObject *__pyx_tuple__89;
static PyObject *__pyx_tuple__91;
static PyObject *__pyx_tuple__92;
static PyObject *__pyx_tuple__93;
static PyObject *__pyx_tuple__94;
static PyObject *__pyx_tuple__95;
static PyObject *__pyx_tuple__96;
static PyObject *__pyx_tuple__98;
static PyObject *__pyx_tuple__99;
static PyObject *__pyx_slice__103;
static PyObject *__pyx_slice__109;
static PyObject *__pyx_slice__111;
static PyObject *__pyx_slice__120;
static PyObject *__pyx_slice__134;
static PyObject *__pyx_slice__135;
static PyObject *__pyx_slice__136;
static PyObject *__pyx_slice__142;
static PyObject *__pyx_slice__144;
static PyObject *__pyx_slice__148;
static PyObject *__pyx_slice__149;
static PyObject *__pyx_slice__152;
static PyObject *__pyx_slice__157;
static PyObject *__pyx_slice__158;
static PyObject *__pyx_slice__189;
static PyObject *__pyx_slice__190;
static PyObject *__pyx_slice__191;
static PyObject *__pyx_tuple__100;
static PyObject *__pyx_tuple__101;
static PyObject *__pyx_tuple__102;
static PyObject *__pyx_tuple__104;
static PyObject *__pyx_tuple__106;
static PyObject *__pyx_tuple__107;
static PyObject *__pyx_tuple__108;
static PyObject *__pyx_tuple__110;
static PyObject *__pyx_tuple__112;
static PyObject *__pyx_tuple__113;
static PyObject *__pyx_tuple__114;
static PyObject *__pyx_tuple__115;
static PyObject *__pyx_tuple__116;
static PyObject *__pyx_tuple__117;
static PyObject *__pyx_tuple__118;
static PyObject *__pyx_tuple__119;
static PyObject *__pyx_tuple__121;
static PyObject *__pyx_tuple__122;
static PyObject *__pyx_tuple__123;
static PyObject *__pyx_tuple__124;
static PyObject *__pyx_tuple__125;
static PyObject *__pyx_tuple__126;
static PyObject *__pyx_tuple__127;
static PyObject *__pyx_tuple__128;
static PyObject *__pyx_tuple__129;
static PyObject *__pyx_tuple__130;
static PyObject *__pyx_tuple__131;
static PyObject *__pyx_tuple__132;
static PyObject *__pyx_tuple__133;
static PyObject *__pyx_tuple__137;
static PyObject *__pyx_tuple__138;
static PyObject *__pyx_tuple__139;
static PyObject *__pyx_tuple__140;
static PyObject *__pyx_tuple__141;
static PyObject *__pyx_tuple__143;
static PyObject *__pyx_tuple__145;
static PyObject *__pyx_tuple__146;
static PyObject *__pyx_tuple__147;
static PyObject *__pyx_tuple__150;
static PyObject *__pyx_tuple__151;
static PyObject *__pyx_tuple__153;
static PyObject *__pyx_tuple__154;
static PyObject *__pyx_tuple__155;
static PyObject *__pyx_tuple__156;
static PyObject *__pyx_tuple__159;
static PyObject *__pyx_tuple__160;
static PyObject *__pyx_tuple__161;
static PyObject *__pyx_tuple__162;
static PyObject *__pyx_tuple__163;
static PyObject *__pyx_tuple__164;
static PyObject *__pyx_tuple__165;
static PyObject *__pyx_tuple__166;
static PyObject *__pyx_tuple__167;
static PyObject *__pyx_tuple__168;
static PyObject *__pyx_tuple__169;
static PyObject *__pyx_tuple__170;
static PyObject *__pyx_tuple__171;
static PyObject *__pyx_tuple__172;
static PyObject *__pyx_tuple__173;
static PyObject *__pyx_tuple__174;
static PyObject *__pyx_tuple__175;
static PyObject *__pyx_tuple__176;
static PyObject *__pyx_tuple__177;
static PyObject *__pyx_tuple__178;
static PyObject *__pyx_tuple__179;
static PyObject *__pyx_tuple__180;
static PyObject *__pyx_tuple__181;
static PyObject *__pyx_tuple__182;
static PyObject *__pyx_tuple__183;
static PyObject *__pyx_tuple__184;
static PyObject *__pyx_tuple__185;
static PyObject *__pyx_tuple__186;
static PyObject *__pyx_tuple__187;
static PyObject *__pyx_tuple__188;
static PyObject *__pyx_tuple__192;
static PyObject *__pyx_tuple__193;
static PyObject *__pyx_tuple__194;
static PyObject *__pyx_tuple__195;
static PyObject *__pyx_tuple__196;
static PyObject *__pyx_tuple__198;
static PyObject *__pyx_tuple__199;
static PyObject *__pyx_tuple__200;
static PyObject *__pyx_tuple__201;
static PyObject *__pyx_tuple__202;
static PyObject *__pyx_tuple__203;
static PyObject *__pyx_tuple__204;
static PyObject *__pyx_tuple__205;
static PyObject *__pyx_tuple__206;
static PyObject *__pyx_tuple__207;
static PyObject *__pyx_tuple__208;
static PyObject *__pyx_tuple__209;
static PyObject *__pyx_tuple__210;
static PyObject *__pyx_tuple__211;
static PyObject *__pyx_tuple__212;
static PyObject *__pyx_tuple__213;
static PyObject *__pyx_tuple__215;
static PyObject *__pyx_tuple__217;
static PyObject *__pyx_tuple__219;
static PyObject *__pyx_tuple__221;
static PyObject *__pyx_tuple__222;
static PyObject *__pyx_tuple__224;
static PyObject *__pyx_tuple__225;
static PyObject *__pyx_tuple__228;
static PyObject *__pyx_tuple__230;
static PyObject *__pyx_tuple__232;
static PyObject *__pyx_tuple__234;
static PyObject *__pyx_tuple__235;
static PyObject *__pyx_tuple__237;
static PyObject *__pyx_tuple__239;
static PyObject *__pyx_tuple__241;
static PyObject *__pyx_tuple__242;
static PyObject *__pyx_tuple__244;
static PyObject *__pyx_tuple__245;
static PyObject *__pyx_tuple__248;
static PyObject *__pyx_tuple__249;
static PyObject *__pyx_tuple__250;
static PyObject *__pyx_tuple__251;
static PyObject *__pyx_tuple__252;
static PyObject *__pyx_tuple__253;
static PyObject *__pyx_tuple__254;
static PyObject *__pyx_tuple__255;
static PyObject *__pyx_tuple__256;
static PyObject *__pyx_tuple__257;
static PyObject *__pyx_tuple__258;
static PyObject *__pyx_tuple__259;
static PyObject *__pyx_tuple__260;
static PyObject *__pyx_tuple__261;
static PyObject *__pyx_tuple__262;
static PyObject *__pyx_tuple__263;
static PyObject *__pyx_tuple__264;
static PyObject *__pyx_tuple__265;
static PyObject *__pyx_tuple__266;
static PyObject *__pyx_tuple__267;
static PyObject *__pyx_tuple__268;
static PyObject *__pyx_tuple__269;
static PyObject *__pyx_tuple__270;
static PyObject *__pyx_tuple__271;
static PyObject *__pyx_tuple__272;
static PyObject *__pyx_tuple__273;
static PyObject *__pyx_tuple__274;
static PyObject *__pyx_tuple__275;
static PyObject *__pyx_tuple__276;
static PyObject *__pyx_tuple__277;
static PyObject *__pyx_tuple__278;
static PyObject *__pyx_tuple__279;
static PyObject *__pyx_tuple__280;
static PyObject *__pyx_tuple__281;
static PyObject *__pyx_tuple__282;
static PyObject *__pyx_tuple__283;
static PyObject *__pyx_tuple__284;
static PyObject *__pyx_tuple__285;
static PyObject *__pyx_tuple__286;
static PyObject *__pyx_tuple__287;
static PyObject *__pyx_tuple__288;
static PyObject *__pyx_tuple__290;
static PyObject *__pyx_tuple__292;
static PyObject *__pyx_tuple__293;
static PyObject *__pyx_tuple__297;
static PyObject *__pyx_tuple__298;
static PyObject *__pyx_tuple__299;
static PyObject *__pyx_tuple__302;
static PyObject *__pyx_tuple__303;
static PyObject *__pyx_tuple__304;
static PyObject *__pyx_tuple__305;
static PyObject *__pyx_tuple__306;
static PyObject *__pyx_tuple__307;
static PyObject *__pyx_tuple__308;
static PyObject *__pyx_tuple__309;
static PyObject *__pyx_tuple__310;
static PyObject *__pyx_tuple__311;
static PyObject *__pyx_tuple__318;
static PyObject *__pyx_tuple__319;
static PyObject *__pyx_tuple__320;
static PyObject *__pyx_tuple__321;
static PyObject *__pyx_tuple__322;
static PyObject *__pyx_tuple__323;
static PyObject *__pyx_tuple__324;
static PyObject *__pyx_tuple__325;
static PyObject *__pyx_tuple__326;
static PyObject *__pyx_tuple__327;
static PyObject *__pyx_tuple__328;
static PyObject *__pyx_tuple__329;
static PyObject *__pyx_tuple__330;
static PyObject *__pyx_tuple__331;
static PyObject *__pyx_tuple__332;
static PyObject *__pyx_tuple__333;
static PyObject *__pyx_tuple__334;
static PyObject *__pyx_tuple__335;
static PyObject *__pyx_tuple__336;
static PyObject *__pyx_tuple__337;
static PyObject *__pyx_tuple__339;
static PyObject *__pyx_tuple__340;
static PyObject *__pyx_tuple__341;
static PyObject *__pyx_tuple__342;
static PyObject *__pyx_tuple__343;
static PyObject *__pyx_tuple__344;
static PyObject *__pyx_tuple__345;
static PyObject *__pyx_tuple__346;
static PyObject *__pyx_tuple__347;
static PyObject *__pyx_tuple__348;
static PyObject *__pyx_tuple__349;
static PyObject *__pyx_tuple__350;
static PyObject *__pyx_tuple__351;
static PyObject *__pyx_tuple__352;
static PyObject *__pyx_tuple__353;
static PyObject *__pyx_tuple__354;
static PyObject *__pyx_tuple__355;
static PyObject *__pyx_tuple__356;
static PyObject *__pyx_tuple__357;
static PyObject *__pyx_tuple__358;
static PyObject *__pyx_tuple__359;
static PyObject *__pyx_tuple__360;
static PyObject *__pyx_tuple__361;
static PyObject *__pyx_tuple__363;
static PyObject *__pyx_tuple__364;
static PyObject *__pyx_tuple__365;
static PyObject *__pyx_tuple__366;
static PyObject *__pyx_tuple__367;
static PyObject *__pyx_tuple__368;
static PyObject *__pyx_tuple__369;
static PyObject *__pyx_tuple__370;
static PyObject *__pyx_tuple__371;
static PyObject *__pyx_tuple__372;
static PyObject *__pyx_tuple__373;
static PyObject *__pyx_tuple__374;
static PyObject *__pyx_tuple__375;
static PyObject *__pyx_tuple__376;
static PyObject *__pyx_tuple__378;
static PyObject *__pyx_tuple__379;
static PyObject *__pyx_tuple__380;
static PyObject *__pyx_tuple__381;
static PyObject *__pyx_tuple__382;
static PyObject *__pyx_tuple__383;
static PyObject *__pyx_tuple__384;
static PyObject *__pyx_tuple__385;
static PyObject *__pyx_tuple__386;
static PyObject *__pyx_tuple__387;
static PyObject *__pyx_tuple__388;
static PyObject *__pyx_tuple__389;
static PyObject *__pyx_tuple__390;
static PyObject *__pyx_tuple__391;
static PyObject *__pyx_tuple__392;
static PyObject *__pyx_tuple__393;
static PyObject *__pyx_tuple__394;
static PyObject *__pyx_tuple__395;
static PyObject *__pyx_tuple__396;
static PyObject *__pyx_tuple__397;
static PyObject *__pyx_tuple__398;
static PyObject *__pyx_tuple__399;
static PyObject *__pyx_tuple__400;
static PyObject *__pyx_tuple__402;
static PyObject *__pyx_tuple__403;
static PyObject *__pyx_tuple__404;
static PyObject *__pyx_tuple__405;
static PyObject *__pyx_tuple__406;
static PyObject *__pyx_tuple__407;
static PyObject *__pyx_tuple__408;
static PyObject *__pyx_tuple__409;
static PyObject *__pyx_tuple__411;
static PyObject *__pyx_tuple__413;
static PyObject *__pyx_tuple__415;
static PyObject *__pyx_tuple__417;
static PyObject *__pyx_tuple__419;
static PyObject *__pyx_tuple__421;
static PyObject *__pyx_tuple__423;
static PyObject *__pyx_tuple__425;
static PyObject *__pyx_tuple__427;
static PyObject *__pyx_tuple__428;
static PyObject *__pyx_tuple__429;
static PyObject *__pyx_tuple__430;
static PyObject *__pyx_tuple__431;
static PyObject *__pyx_tuple__432;
static PyObject *__pyx_codeobj__197;
static PyObject *__pyx_codeobj__214;
static PyObject *__pyx_codeobj__216;
static PyObject *__pyx_codeobj__218;
static PyObject *__pyx_codeobj__220;
static PyObject *__pyx_codeobj__223;
static PyObject *__pyx_codeobj__226;
static PyObject *__pyx_codeobj__229;
static PyObject *__pyx_codeobj__231;
static PyObject *__pyx_codeobj__233;
static PyObject *__pyx_codeobj__236;
static PyObject *__pyx_codeobj__238;
static PyObject *__pyx_codeobj__240;
static PyObject *__pyx_codeobj__243;
static PyObject *__pyx_codeobj__246;
static PyObject *__pyx_codeobj__289;
static PyObject *__pyx_codeobj__291;
static PyObject *__pyx_codeobj__410;
static PyObject *__pyx_codeobj__412;
static PyObject *__pyx_codeobj__414;
static PyObject *__pyx_codeobj__416;
static PyObject *__pyx_codeobj__418;
static PyObject *__pyx_codeobj__420;
static PyObject *__pyx_codeobj__422;
static PyObject *__pyx_codeobj__424;
static PyObject *__pyx_codeobj__426;
static PyObject *__pyx_codeobj__433;
/* Late includes */

/* "cupy/core/core.pyx":37
 * 
 * @cython.profile(False)
 * cdef inline _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *     xp = getattr(x, '__array_priority__', 0)
 *     yp = getattr(y, '__array_priority__', 0)
 */

static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__should_use_rop(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_v_xp = NULL;
  PyObject *__pyx_v_yp = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("_should_use_rop", 0);

  /* "cupy/core/core.pyx":38
 * @cython.profile(False)
 * cdef inline _should_use_rop(x, y):
 *     xp = getattr(x, '__array_priority__', 0)             # <<<<<<<<<<<<<<
 *     yp = getattr(y, '__array_priority__', 0)
 *     return xp < yp and not isinstance(y, ndarray)
 */
  __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_x, __pyx_n_s_array_priority, __pyx_int_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_xp = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":39
 * cdef inline _should_use_rop(x, y):
 *     xp = getattr(x, '__array_priority__', 0)
 *     yp = getattr(y, '__array_priority__', 0)             # <<<<<<<<<<<<<<
 *     return xp < yp and not isinstance(y, ndarray)
 * 
 */
  __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_y, __pyx_n_s_array_priority, __pyx_int_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_yp = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":40
 *     xp = getattr(x, '__array_priority__', 0)
 *     yp = getattr(y, '__array_priority__', 0)
 *     return xp < yp and not isinstance(y, ndarray)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_xp, __pyx_v_yp, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 40, __pyx_L1_error)
  if (__pyx_t_3) {
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_1 = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_y, __pyx_ptype_4cupy_4core_4core_ndarray); 
  __pyx_t_4 = (!(__pyx_t_3 != 0));
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_L3_bool_binop_done:;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":37
 * 
 * @cython.profile(False)
 * cdef inline _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *     xp = getattr(x, '__array_priority__', 0)
 *     yp = getattr(y, '__array_priority__', 0)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core._should_use_rop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_xp);
  __Pyx_XDECREF(__pyx_v_yp);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":48
 *     class IndexOrValueError(IndexError, ValueError):
 * 
 *         def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *             super(IndexOrValueError, self).__init__(*args, **kwargs)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17IndexOrValueError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_17IndexOrValueError___init__[] = "IndexOrValueError.__init__(self, *args, **kwargs)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_17IndexOrValueError_1__init__ = {"__init__", (PyCFunction)__pyx_pw_4cupy_4core_4core_17IndexOrValueError_1__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_17IndexOrValueError___init__};
static PyObject *__pyx_pw_4cupy_4core_4core_17IndexOrValueError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,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) {
        default:
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "__init__") < 0)) __PYX_ERR(0, 48, __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_self = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 48, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("cupy.core.core.IndexOrValueError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_17IndexOrValueError___init__(__pyx_self, __pyx_v_self, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17IndexOrValueError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/core.pyx":49
 * 
 *         def __init__(self, *args, **kwargs):
 *             super(IndexOrValueError, self).__init__(*args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     _AxisError = IndexOrValueError
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_IndexOrValueError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_init); 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;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":48
 *     class IndexOrValueError(IndexError, ValueError):
 * 
 *         def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *             super(IndexOrValueError, self).__init__(*args, **kwargs)
 * 
 */

  /* 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_2);
  __Pyx_AddTraceback("cupy.core.core.IndexOrValueError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":54
 * 
 * 
 * cdef int _normalize_order(str order) except? 0:             # <<<<<<<<<<<<<<
 *     if len(order) != 1:
 *         raise TypeError('order not understood')
 */

static int __pyx_f_4cupy_4core_4core__normalize_order(PyObject *__pyx_v_order) {
  int __pyx_v_order_char;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  __Pyx_RefNannySetupContext("_normalize_order", 0);

  /* "cupy/core/core.pyx":55
 * 
 * cdef int _normalize_order(str order) except? 0:
 *     if len(order) != 1:             # <<<<<<<<<<<<<<
 *         raise TypeError('order not understood')
 *     cdef int order_char = ord(order)
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_order); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 55, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 != 1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "cupy/core/core.pyx":56
 * cdef int _normalize_order(str order) except? 0:
 *     if len(order) != 1:
 *         raise TypeError('order not understood')             # <<<<<<<<<<<<<<
 *     cdef int order_char = ord(order)
 *     if order_char == 'K' or order_char == 'k':
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 56, __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(0, 56, __pyx_L1_error)

    /* "cupy/core/core.pyx":55
 * 
 * cdef int _normalize_order(str order) except? 0:
 *     if len(order) != 1:             # <<<<<<<<<<<<<<
 *         raise TypeError('order not understood')
 *     cdef int order_char = ord(order)
 */
  }

  /* "cupy/core/core.pyx":57
 *     if len(order) != 1:
 *         raise TypeError('order not understood')
 *     cdef int order_char = ord(order)             # <<<<<<<<<<<<<<
 *     if order_char == 'K' or order_char == 'k':
 *         order_char = 'K'
 */
  __pyx_t_4 = __Pyx_PyObject_Ord(__pyx_v_order); if (unlikely(__pyx_t_4 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 57, __pyx_L1_error)
  __pyx_v_order_char = __pyx_t_4;

  /* "cupy/core/core.pyx":58
 *         raise TypeError('order not understood')
 *     cdef int order_char = ord(order)
 *     if order_char == 'K' or order_char == 'k':             # <<<<<<<<<<<<<<
 *         order_char = 'K'
 *     elif order_char == 'A' or order_char == 'a':
 */
  switch (__pyx_v_order_char) {
    case 'K':
    case 'k':

    /* "cupy/core/core.pyx":59
 *     cdef int order_char = ord(order)
 *     if order_char == 'K' or order_char == 'k':
 *         order_char = 'K'             # <<<<<<<<<<<<<<
 *     elif order_char == 'A' or order_char == 'a':
 *         order_char = 'A'
 */
    __pyx_v_order_char = 'K';

    /* "cupy/core/core.pyx":58
 *         raise TypeError('order not understood')
 *     cdef int order_char = ord(order)
 *     if order_char == 'K' or order_char == 'k':             # <<<<<<<<<<<<<<
 *         order_char = 'K'
 *     elif order_char == 'A' or order_char == 'a':
 */
    break;

    /* "cupy/core/core.pyx":60
 *     if order_char == 'K' or order_char == 'k':
 *         order_char = 'K'
 *     elif order_char == 'A' or order_char == 'a':             # <<<<<<<<<<<<<<
 *         order_char = 'A'
 *     elif order_char == 'C' or order_char == 'c':
 */
    case 'A':
    case 'a':

    /* "cupy/core/core.pyx":61
 *         order_char = 'K'
 *     elif order_char == 'A' or order_char == 'a':
 *         order_char = 'A'             # <<<<<<<<<<<<<<
 *     elif order_char == 'C' or order_char == 'c':
 *         order_char = 'C'
 */
    __pyx_v_order_char = 'A';

    /* "cupy/core/core.pyx":60
 *     if order_char == 'K' or order_char == 'k':
 *         order_char = 'K'
 *     elif order_char == 'A' or order_char == 'a':             # <<<<<<<<<<<<<<
 *         order_char = 'A'
 *     elif order_char == 'C' or order_char == 'c':
 */
    break;

    /* "cupy/core/core.pyx":62
 *     elif order_char == 'A' or order_char == 'a':
 *         order_char = 'A'
 *     elif order_char == 'C' or order_char == 'c':             # <<<<<<<<<<<<<<
 *         order_char = 'C'
 *     elif order_char == 'F' or order_char == 'f':
 */
    case 'C':
    case 'c':

    /* "cupy/core/core.pyx":63
 *         order_char = 'A'
 *     elif order_char == 'C' or order_char == 'c':
 *         order_char = 'C'             # <<<<<<<<<<<<<<
 *     elif order_char == 'F' or order_char == 'f':
 *         order_char = 'F'
 */
    __pyx_v_order_char = 'C';

    /* "cupy/core/core.pyx":62
 *     elif order_char == 'A' or order_char == 'a':
 *         order_char = 'A'
 *     elif order_char == 'C' or order_char == 'c':             # <<<<<<<<<<<<<<
 *         order_char = 'C'
 *     elif order_char == 'F' or order_char == 'f':
 */
    break;

    /* "cupy/core/core.pyx":64
 *     elif order_char == 'C' or order_char == 'c':
 *         order_char = 'C'
 *     elif order_char == 'F' or order_char == 'f':             # <<<<<<<<<<<<<<
 *         order_char = 'F'
 *     else:
 */
    case 'F':
    case 'f':

    /* "cupy/core/core.pyx":65
 *         order_char = 'C'
 *     elif order_char == 'F' or order_char == 'f':
 *         order_char = 'F'             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError('order not understood')
 */
    __pyx_v_order_char = 'F';

    /* "cupy/core/core.pyx":64
 *     elif order_char == 'C' or order_char == 'c':
 *         order_char = 'C'
 *     elif order_char == 'F' or order_char == 'f':             # <<<<<<<<<<<<<<
 *         order_char = 'F'
 *     else:
 */
    break;
    default:

    /* "cupy/core/core.pyx":67
 *         order_char = 'F'
 *     else:
 *         raise TypeError('order not understood')             # <<<<<<<<<<<<<<
 *     return order_char
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 67, __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(0, 67, __pyx_L1_error)
    break;
  }

  /* "cupy/core/core.pyx":68
 *     else:
 *         raise TypeError('order not understood')
 *     return order_char             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_order_char;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":54
 * 
 * 
 * cdef int _normalize_order(str order) except? 0:             # <<<<<<<<<<<<<<
 *     if len(order) != 1:
 *         raise TypeError('order not understood')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core._normalize_order", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":104
 *     """
 * 
 *     def __init__(self, shape, dtype=float, memptr=None, order='C'):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t x, itemsize
 *         self._shape = internal.get_size(shape)
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_memptr = 0;
  PyObject *__pyx_v_order = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_dtype,&__pyx_n_s_memptr,&__pyx_n_s_order,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = __pyx_k__3;
    values[2] = ((PyObject *)Py_None);
    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  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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_memptr);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_order);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 104, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_shape = values[0];
    __pyx_v_dtype = values[1];
    __pyx_v_memptr = values[2];
    __pyx_v_order = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 104, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray___init__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_shape, __pyx_v_dtype, __pyx_v_memptr, __pyx_v_order);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_7ndarray___init__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_shape, PyObject *__pyx_v_dtype, PyObject *__pyx_v_memptr, PyObject *__pyx_v_order) {
  Py_ssize_t __pyx_v_x;
  Py_ssize_t __pyx_v_itemsize;
  int __pyx_v_order_char;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  std::vector<Py_ssize_t>  __pyx_t_2;
  std::vector<Py_ssize_t> ::iterator __pyx_t_3;
  std::vector<Py_ssize_t>  *__pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_INCREF(__pyx_v_order);

  /* "cupy/core/core.pyx":106
 *     def __init__(self, shape, dtype=float, memptr=None, order='C'):
 *         cdef Py_ssize_t x, itemsize
 *         self._shape = internal.get_size(shape)             # <<<<<<<<<<<<<<
 *         for x in self._shape:
 *             if x < 0:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_8internal_get_size(__pyx_v_shape, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 106, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->_shape = __pyx_t_2;

  /* "cupy/core/core.pyx":107
 *         cdef Py_ssize_t x, itemsize
 *         self._shape = internal.get_size(shape)
 *         for x in self._shape:             # <<<<<<<<<<<<<<
 *             if x < 0:
 *                 raise ValueError('Negative dimensions are not allowed')
 */
  __pyx_t_4 = &__pyx_v_self->_shape;
  __pyx_t_3 = __pyx_t_4->begin();
  for (;;) {
    if (!(__pyx_t_3 != __pyx_t_4->end())) break;
    __pyx_t_5 = *__pyx_t_3;
    ++__pyx_t_3;
    __pyx_v_x = __pyx_t_5;

    /* "cupy/core/core.pyx":108
 *         self._shape = internal.get_size(shape)
 *         for x in self._shape:
 *             if x < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Negative dimensions are not allowed')
 *         self.dtype = get_dtype(dtype)
 */
    __pyx_t_6 = ((__pyx_v_x < 0) != 0);
    if (unlikely(__pyx_t_6)) {

      /* "cupy/core/core.pyx":109
 *         for x in self._shape:
 *             if x < 0:
 *                 raise ValueError('Negative dimensions are not allowed')             # <<<<<<<<<<<<<<
 *         self.dtype = get_dtype(dtype)
 *         self.size = internal.prod_ssize_t(self._shape)
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __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(0, 109, __pyx_L1_error)

      /* "cupy/core/core.pyx":108
 *         self._shape = internal.get_size(shape)
 *         for x in self._shape:
 *             if x < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Negative dimensions are not allowed')
 *         self.dtype = get_dtype(dtype)
 */
    }

    /* "cupy/core/core.pyx":107
 *         cdef Py_ssize_t x, itemsize
 *         self._shape = internal.get_size(shape)
 *         for x in self._shape:             # <<<<<<<<<<<<<<
 *             if x < 0:
 *                 raise ValueError('Negative dimensions are not allowed')
 */
  }

  /* "cupy/core/core.pyx":110
 *             if x < 0:
 *                 raise ValueError('Negative dimensions are not allowed')
 *         self.dtype = get_dtype(dtype)             # <<<<<<<<<<<<<<
 *         self.size = internal.prod_ssize_t(self._shape)
 *         itemsize = self.dtype.itemsize
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->dtype);
  __Pyx_DECREF(__pyx_v_self->dtype);
  __pyx_v_self->dtype = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":111
 *                 raise ValueError('Negative dimensions are not allowed')
 *         self.dtype = get_dtype(dtype)
 *         self.size = internal.prod_ssize_t(self._shape)             # <<<<<<<<<<<<<<
 *         itemsize = self.dtype.itemsize
 * 
 */
  __pyx_v_self->size = __pyx_f_4cupy_4core_8internal_prod_ssize_t(__pyx_v_self->_shape, 0, NULL);

  /* "cupy/core/core.pyx":112
 *         self.dtype = get_dtype(dtype)
 *         self.size = internal.prod_ssize_t(self._shape)
 *         itemsize = self.dtype.itemsize             # <<<<<<<<<<<<<<
 * 
 *         if memptr is None:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 112, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_itemsize = __pyx_t_5;

  /* "cupy/core/core.pyx":114
 *         itemsize = self.dtype.itemsize
 * 
 *         if memptr is None:             # <<<<<<<<<<<<<<
 *             self.data = memory.alloc(self.size * itemsize)
 *         else:
 */
  __pyx_t_6 = (__pyx_v_memptr == Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":115
 * 
 *         if memptr is None:
 *             self.data = memory.alloc(self.size * itemsize)             # <<<<<<<<<<<<<<
 *         else:
 *             self.data = memptr
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc((__pyx_v_self->size * __pyx_v_itemsize), 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->data);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->data));
    __pyx_v_self->data = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":114
 *         itemsize = self.dtype.itemsize
 * 
 *         if memptr is None:             # <<<<<<<<<<<<<<
 *             self.data = memory.alloc(self.size * itemsize)
 *         else:
 */
    goto __pyx_L6;
  }

  /* "cupy/core/core.pyx":117
 *             self.data = memory.alloc(self.size * itemsize)
 *         else:
 *             self.data = memptr             # <<<<<<<<<<<<<<
 *         if order is None:
 *             order = 'C'
 */
  /*else*/ {
    if (!(likely(((__pyx_v_memptr) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_memptr, __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer))))) __PYX_ERR(0, 117, __pyx_L1_error)
    __pyx_t_1 = __pyx_v_memptr;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->data);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->data));
    __pyx_v_self->data = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_1);
    __pyx_t_1 = 0;
  }
  __pyx_L6:;

  /* "cupy/core/core.pyx":118
 *         else:
 *             self.data = memptr
 *         if order is None:             # <<<<<<<<<<<<<<
 *             order = 'C'
 * 
 */
  __pyx_t_7 = (__pyx_v_order == Py_None);
  __pyx_t_6 = (__pyx_t_7 != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":119
 *             self.data = memptr
 *         if order is None:
 *             order = 'C'             # <<<<<<<<<<<<<<
 * 
 *         cdef int order_char = _normalize_order(order)
 */
    __Pyx_INCREF(__pyx_n_s_C);
    __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_s_C);

    /* "cupy/core/core.pyx":118
 *         else:
 *             self.data = memptr
 *         if order is None:             # <<<<<<<<<<<<<<
 *             order = 'C'
 * 
 */
  }

  /* "cupy/core/core.pyx":121
 *             order = 'C'
 * 
 *         cdef int order_char = _normalize_order(order)             # <<<<<<<<<<<<<<
 *         if order_char == 'C':
 *             self._strides = internal.get_contiguous_strides(
 */
  if (!(likely(PyString_CheckExact(__pyx_v_order))||((__pyx_v_order) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_order)->tp_name), 0))) __PYX_ERR(0, 121, __pyx_L1_error)
  __pyx_t_8 = __pyx_f_4cupy_4core_4core__normalize_order(((PyObject*)__pyx_v_order)); if (unlikely(__pyx_t_8 == ((int)0) && PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error)
  __pyx_v_order_char = __pyx_t_8;

  /* "cupy/core/core.pyx":122
 * 
 *         cdef int order_char = _normalize_order(order)
 *         if order_char == 'C':             # <<<<<<<<<<<<<<
 *             self._strides = internal.get_contiguous_strides(
 *                 self._shape, itemsize, is_c_contiguous=True)
 */
  switch (__pyx_v_order_char) {
    case 'C':

    /* "cupy/core/core.pyx":123
 *         cdef int order_char = _normalize_order(order)
 *         if order_char == 'C':
 *             self._strides = internal.get_contiguous_strides(             # <<<<<<<<<<<<<<
 *                 self._shape, itemsize, is_c_contiguous=True)
 *             self._c_contiguous = True
 */
    __pyx_t_2 = __pyx_f_4cupy_4core_8internal_get_contiguous_strides(__pyx_v_self->_shape, __pyx_v_itemsize, 1, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 123, __pyx_L1_error)
    __pyx_v_self->_strides = __pyx_t_2;

    /* "cupy/core/core.pyx":125
 *             self._strides = internal.get_contiguous_strides(
 *                 self._shape, itemsize, is_c_contiguous=True)
 *             self._c_contiguous = True             # <<<<<<<<<<<<<<
 *             self._update_f_contiguity()
 *         elif order_char == 'F':
 */
    __pyx_v_self->_c_contiguous = 1;

    /* "cupy/core/core.pyx":126
 *                 self._shape, itemsize, is_c_contiguous=True)
 *             self._c_contiguous = True
 *             self._update_f_contiguity()             # <<<<<<<<<<<<<<
 *         elif order_char == 'F':
 *             self._strides = internal.get_contiguous_strides(
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_update_f_contiguity(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":122
 * 
 *         cdef int order_char = _normalize_order(order)
 *         if order_char == 'C':             # <<<<<<<<<<<<<<
 *             self._strides = internal.get_contiguous_strides(
 *                 self._shape, itemsize, is_c_contiguous=True)
 */
    break;

    /* "cupy/core/core.pyx":127
 *             self._c_contiguous = True
 *             self._update_f_contiguity()
 *         elif order_char == 'F':             # <<<<<<<<<<<<<<
 *             self._strides = internal.get_contiguous_strides(
 *                 self._shape, itemsize, is_c_contiguous=False)
 */
    case 'F':

    /* "cupy/core/core.pyx":128
 *             self._update_f_contiguity()
 *         elif order_char == 'F':
 *             self._strides = internal.get_contiguous_strides(             # <<<<<<<<<<<<<<
 *                 self._shape, itemsize, is_c_contiguous=False)
 *             self._f_contiguous = True
 */
    __pyx_t_2 = __pyx_f_4cupy_4core_8internal_get_contiguous_strides(__pyx_v_self->_shape, __pyx_v_itemsize, 0, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 128, __pyx_L1_error)
    __pyx_v_self->_strides = __pyx_t_2;

    /* "cupy/core/core.pyx":130
 *             self._strides = internal.get_contiguous_strides(
 *                 self._shape, itemsize, is_c_contiguous=False)
 *             self._f_contiguous = True             # <<<<<<<<<<<<<<
 *             self._update_c_contiguity()
 *         else:
 */
    __pyx_v_self->_f_contiguous = 1;

    /* "cupy/core/core.pyx":131
 *                 self._shape, itemsize, is_c_contiguous=False)
 *             self._f_contiguous = True
 *             self._update_c_contiguity()             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError('order not understood. order={}'.format(order))
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_update_c_contiguity(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":127
 *             self._c_contiguous = True
 *             self._update_f_contiguity()
 *         elif order_char == 'F':             # <<<<<<<<<<<<<<
 *             self._strides = internal.get_contiguous_strides(
 *                 self._shape, itemsize, is_c_contiguous=False)
 */
    break;
    default:

    /* "cupy/core/core.pyx":133
 *             self._update_c_contiguity()
 *         else:
 *             raise TypeError('order not understood. order={}'.format(order))             # <<<<<<<<<<<<<<
 * 
 *     # The definition order of attributes and methods are borrowed from the
 */
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_order_not_understood_order, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_order); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_order};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_order};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 133, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_INCREF(__pyx_v_order);
        __Pyx_GIVEREF(__pyx_v_order);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_order);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 133, __pyx_L1_error)
    break;
  }

  /* "cupy/core/core.pyx":104
 *     """
 * 
 *     def __init__(self, shape, dtype=float, memptr=None, order='C'):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t x, itemsize
 *         self._shape = internal.get_size(shape)
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_order);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":143
 *     # -------------------------------------------------------------------------
 *     @property
 *     def flags(self):             # <<<<<<<<<<<<<<
 *         """Object containing memory-layout information.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_5flags_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_5flags_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_5flags___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_5flags___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":153
 * 
 *         """
 *         return flags.Flags(self._c_contiguous, self._f_contiguous,             # <<<<<<<<<<<<<<
 *                            self.base is None)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Flags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->_c_contiguous); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_self->_f_contiguous); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":154
 *         """
 *         return flags.Flags(self._c_contiguous, self._f_contiguous,
 *                            self.base is None)             # <<<<<<<<<<<<<<
 * 
 *     property shape:
 */
  __pyx_t_5 = (((PyObject *)__pyx_v_self->base) == Py_None);
  __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 154, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_2, __pyx_t_4, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_2, __pyx_t_4, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 153, __pyx_L1_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_2);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_6);
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":143
 *     # -------------------------------------------------------------------------
 *     @property
 *     def flags(self):             # <<<<<<<<<<<<<<
 *         """Object containing memory-layout information.
 * 
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core.ndarray.flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":166
 *         """
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return tuple(self._shape)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_5shape_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_5shape___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_5shape___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":167
 * 
 *         def __get__(self):
 *             return tuple(self._shape)             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, newshape):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 167, __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;

  /* "cupy/core/core.pyx":166
 *         """
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return tuple(self._shape)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.ndarray.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":169
 *             return tuple(self._shape)
 * 
 *         def __set__(self, newshape):             # <<<<<<<<<<<<<<
 *             cdef vector.vector[Py_ssize_t] shape, strides
 *             if not cpython.PySequence_Check(newshape):
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_5shape_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_newshape); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_5shape_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_newshape) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_5shape_2__set__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_newshape));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_7ndarray_5shape_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_newshape) {
  std::vector<Py_ssize_t>  __pyx_v_shape;
  std::vector<Py_ssize_t>  __pyx_v_strides;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  std::vector<Py_ssize_t>  __pyx_t_3;
  std::vector<Py_ssize_t>  __pyx_t_4;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_newshape);

  /* "cupy/core/core.pyx":171
 *         def __set__(self, newshape):
 *             cdef vector.vector[Py_ssize_t] shape, strides
 *             if not cpython.PySequence_Check(newshape):             # <<<<<<<<<<<<<<
 *                 newshape = (newshape,)
 *             shape = internal.infer_unknown_dimension(newshape, self.size)
 */
  __pyx_t_1 = ((!(PySequence_Check(__pyx_v_newshape) != 0)) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":172
 *             cdef vector.vector[Py_ssize_t] shape, strides
 *             if not cpython.PySequence_Check(newshape):
 *                 newshape = (newshape,)             # <<<<<<<<<<<<<<
 *             shape = internal.infer_unknown_dimension(newshape, self.size)
 *             strides = _get_strides_for_nocopy_reshape(self, shape)
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_newshape);
    __Pyx_GIVEREF(__pyx_v_newshape);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_newshape);
    __Pyx_DECREF_SET(__pyx_v_newshape, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":171
 *         def __set__(self, newshape):
 *             cdef vector.vector[Py_ssize_t] shape, strides
 *             if not cpython.PySequence_Check(newshape):             # <<<<<<<<<<<<<<
 *                 newshape = (newshape,)
 *             shape = internal.infer_unknown_dimension(newshape, self.size)
 */
  }

  /* "cupy/core/core.pyx":173
 *             if not cpython.PySequence_Check(newshape):
 *                 newshape = (newshape,)
 *             shape = internal.infer_unknown_dimension(newshape, self.size)             # <<<<<<<<<<<<<<
 *             strides = _get_strides_for_nocopy_reshape(self, shape)
 *             if strides.size() != shape.size():
 */
  __pyx_t_3 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_newshape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 173, __pyx_L1_error)
  __pyx_t_4 = __pyx_f_4cupy_4core_8internal_infer_unknown_dimension(__pyx_t_3, __pyx_v_self->size, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 173, __pyx_L1_error)
  __pyx_v_shape = __pyx_t_4;

  /* "cupy/core/core.pyx":174
 *                 newshape = (newshape,)
 *             shape = internal.infer_unknown_dimension(newshape, self.size)
 *             strides = _get_strides_for_nocopy_reshape(self, shape)             # <<<<<<<<<<<<<<
 *             if strides.size() != shape.size():
 *                 raise AttributeError('incompatible shape')
 */
  __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_strides_for_nocopy_reshape(__pyx_v_self, __pyx_v_shape, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 174, __pyx_L1_error)
  __pyx_v_strides = __pyx_t_4;

  /* "cupy/core/core.pyx":175
 *             shape = internal.infer_unknown_dimension(newshape, self.size)
 *             strides = _get_strides_for_nocopy_reshape(self, shape)
 *             if strides.size() != shape.size():             # <<<<<<<<<<<<<<
 *                 raise AttributeError('incompatible shape')
 *             self._shape = shape
 */
  __pyx_t_1 = ((__pyx_v_strides.size() != __pyx_v_shape.size()) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cupy/core/core.pyx":176
 *             strides = _get_strides_for_nocopy_reshape(self, shape)
 *             if strides.size() != shape.size():
 *                 raise AttributeError('incompatible shape')             # <<<<<<<<<<<<<<
 *             self._shape = shape
 *             self._strides = strides
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __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(0, 176, __pyx_L1_error)

    /* "cupy/core/core.pyx":175
 *             shape = internal.infer_unknown_dimension(newshape, self.size)
 *             strides = _get_strides_for_nocopy_reshape(self, shape)
 *             if strides.size() != shape.size():             # <<<<<<<<<<<<<<
 *                 raise AttributeError('incompatible shape')
 *             self._shape = shape
 */
  }

  /* "cupy/core/core.pyx":177
 *             if strides.size() != shape.size():
 *                 raise AttributeError('incompatible shape')
 *             self._shape = shape             # <<<<<<<<<<<<<<
 *             self._strides = strides
 *             self._update_f_contiguity()
 */
  __pyx_v_self->_shape = __pyx_v_shape;

  /* "cupy/core/core.pyx":178
 *                 raise AttributeError('incompatible shape')
 *             self._shape = shape
 *             self._strides = strides             # <<<<<<<<<<<<<<
 *             self._update_f_contiguity()
 * 
 */
  __pyx_v_self->_strides = __pyx_v_strides;

  /* "cupy/core/core.pyx":179
 *             self._shape = shape
 *             self._strides = strides
 *             self._update_f_contiguity()             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_update_f_contiguity(__pyx_v_self, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":169
 *             return tuple(self._shape)
 * 
 *         def __set__(self, newshape):             # <<<<<<<<<<<<<<
 *             cdef vector.vector[Py_ssize_t] shape, strides
 *             if not cpython.PySequence_Check(newshape):
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.ndarray.shape.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_newshape);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":182
 * 
 *     @property
 *     def strides(self):             # <<<<<<<<<<<<<<
 *         """Strides of axes in bytes.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_7strides_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_7strides_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_7strides___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_7strides___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":188
 * 
 *         """
 *         return tuple(self._strides)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __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;

  /* "cupy/core/core.pyx":182
 * 
 *     @property
 *     def strides(self):             # <<<<<<<<<<<<<<
 *         """Strides of axes in bytes.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.ndarray.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":191
 * 
 *     @property
 *     def ndim(self):             # <<<<<<<<<<<<<<
 *         """Number of dimensions.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_4ndim_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_4ndim_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_4ndim___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4ndim___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":199
 * 
 *         """
 *         return self._shape.size()             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_self->_shape.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":191
 * 
 *     @property
 *     def ndim(self):             # <<<<<<<<<<<<<<
 *         """Number of dimensions.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":202
 * 
 *     @property
 *     def itemsize(self):             # <<<<<<<<<<<<<<
 *         """Size of each element in bytes.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_8itemsize_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_8itemsize_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_8itemsize___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_8itemsize___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":208
 * 
 *         """
 *         return self.dtype.itemsize             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 208, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":202
 * 
 *     @property
 *     def itemsize(self):             # <<<<<<<<<<<<<<
 *         """Size of each element in bytes.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":211
 * 
 *     @property
 *     def nbytes(self):             # <<<<<<<<<<<<<<
 *         """Size of whole elements in bytes.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_6nbytes_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_6nbytes_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_6nbytes___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_6nbytes___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":219
 * 
 *         """
 *         return self.size * self.dtype.itemsize             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 219, __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(0, 219, __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;

  /* "cupy/core/core.pyx":211
 * 
 *     @property
 *     def nbytes(self):             # <<<<<<<<<<<<<<
 *         """Size of whole elements in bytes.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.ndarray.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":225
 *     # -------------------------------------------------------------------------
 *     @property
 *     def T(self):             # <<<<<<<<<<<<<<
 *         """Shape-reversed view of the array.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_1T_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_1T_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_1T___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_1T___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  std::vector<Py_ssize_t>  __pyx_t_4;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":231
 * 
 *         """
 *         if self.ndim < 2:             # <<<<<<<<<<<<<<
 *             return self
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_2, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 231, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 231, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":232
 *         """
 *         if self.ndim < 2:
 *             return self             # <<<<<<<<<<<<<<
 *         else:
 *             return self._transpose(vector.vector[Py_ssize_t]())
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = ((PyObject *)__pyx_v_self);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":231
 * 
 *         """
 *         if self.ndim < 2:             # <<<<<<<<<<<<<<
 *             return self
 *         else:
 */
  }

  /* "cupy/core/core.pyx":234
 *             return self
 *         else:
 *             return self._transpose(vector.vector[Py_ssize_t]())             # <<<<<<<<<<<<<<
 * 
 *     __array_priority__ = 100
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    try {
      __pyx_t_4 = std::vector<Py_ssize_t> ();
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 234, __pyx_L1_error)
    }
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_transpose(__pyx_v_self, __pyx_t_4, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":225
 *     # -------------------------------------------------------------------------
 *     @property
 *     def T(self):             # <<<<<<<<<<<<<<
 *         """Shape-reversed view of the array.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.ndarray.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":247
 *     # -------------------------------------------------------------------------
 *     @property
 *     def cstruct(self):             # <<<<<<<<<<<<<<
 *         """C representation of the array.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_7cstruct_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_7cstruct_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_7cstruct___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_7cstruct___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":255
 * 
 *         """
 *         return CArray(self)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4cupy_4core_4core_CArray), ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":247
 *     # -------------------------------------------------------------------------
 *     @property
 *     def cstruct(self):             # <<<<<<<<<<<<<<
 *         """C representation of the array.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.cstruct.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":262
 *     # TODO(okuta): Implement item
 * 
 *     cpdef tolist(self):             # <<<<<<<<<<<<<<
 *         """Converts the array to a (possibly nested) Python list.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_3tolist(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_tolist(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  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;
  __Pyx_RefNannySetupContext("tolist", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tolist); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_3tolist)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 262, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 262, __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;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":271
 * 
 *         """
 *         return self.get().tolist()             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement itemset
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tolist); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":262
 *     # TODO(okuta): Implement item
 * 
 *     cpdef tolist(self):             # <<<<<<<<<<<<<<
 *         """Converts the array to a (possibly nested) Python list.
 * 
 */

  /* 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("cupy.core.core.ndarray.tolist", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_3tolist(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_2tolist[] = "ndarray.tolist(self)\nConverts the array to a (possibly nested) Python list.\n\n        Returns:\n            list: The possibly nested Python list of array elements.\n\n        .. seealso:: :meth:`numpy.ndarray.tolist`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_3tolist(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tolist (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_2tolist(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_2tolist(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("tolist", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray_tolist(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.tolist", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":277
 *     # TODO(okuta): Implement tobytes
 * 
 *     cpdef tofile(self, fid, sep='', format='%s'):             # <<<<<<<<<<<<<<
 *         """Writes the array to a file.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_5tofile(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_tofile(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_fid, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tofile *__pyx_optional_args) {
  PyObject *__pyx_v_sep = ((PyObject *)__pyx_kp_s__6);
  PyObject *__pyx_v_format = ((PyObject *)__pyx_kp_s_s);
  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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("tofile", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_sep = __pyx_optional_args->sep;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_format = __pyx_optional_args->format;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tofile); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 277, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_5tofile)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_fid, __pyx_v_sep, __pyx_v_format};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 277, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_fid, __pyx_v_sep, __pyx_v_format};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 277, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 277, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_fid);
        __Pyx_GIVEREF(__pyx_v_fid);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_fid);
        __Pyx_INCREF(__pyx_v_sep);
        __Pyx_GIVEREF(__pyx_v_sep);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_sep);
        __Pyx_INCREF(__pyx_v_format);
        __Pyx_GIVEREF(__pyx_v_format);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_format);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 277, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":283
 * 
 *         """
 *         self.get().tofile(fid, sep, format)             # <<<<<<<<<<<<<<
 * 
 *     cpdef dump(self, file):
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tofile); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(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_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_fid, __pyx_v_sep, __pyx_v_format};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_fid, __pyx_v_sep, __pyx_v_format};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_fid);
    __Pyx_GIVEREF(__pyx_v_fid);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_fid);
    __Pyx_INCREF(__pyx_v_sep);
    __Pyx_GIVEREF(__pyx_v_sep);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_sep);
    __Pyx_INCREF(__pyx_v_format);
    __Pyx_GIVEREF(__pyx_v_format);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_format);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":277
 *     # TODO(okuta): Implement tobytes
 * 
 *     cpdef tofile(self, fid, sep='', format='%s'):             # <<<<<<<<<<<<<<
 *         """Writes the array to a file.
 * 
 */

  /* 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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_5tofile(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_4tofile[] = "ndarray.tofile(self, fid, sep='', format='%s')\nWrites the array to a file.\n\n        .. seealso:: :meth:`numpy.ndarray.tolist`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_5tofile(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_fid = 0;
  PyObject *__pyx_v_sep = 0;
  PyObject *__pyx_v_format = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tofile (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fid,&__pyx_n_s_sep,&__pyx_n_s_format,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)__pyx_kp_s__6);
    values[2] = ((PyObject *)__pyx_kp_s_s);
    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_fid)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sep);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tofile") < 0)) __PYX_ERR(0, 277, __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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_fid = values[0];
    __pyx_v_sep = values[1];
    __pyx_v_format = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("tofile", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 277, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_4tofile(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_fid, __pyx_v_sep, __pyx_v_format);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4tofile(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_fid, PyObject *__pyx_v_sep, PyObject *__pyx_v_format) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tofile __pyx_t_2;
  __Pyx_RefNannySetupContext("tofile", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.sep = __pyx_v_sep;
  __pyx_t_2.format = __pyx_v_format;
  __pyx_t_1 = __pyx_vtabptr_4cupy_4core_4core_ndarray->tofile(__pyx_v_self, __pyx_v_fid, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.tofile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":285
 *         self.get().tofile(fid, sep, format)
 * 
 *     cpdef dump(self, file):             # <<<<<<<<<<<<<<
 *         """Dumps a pickle of the array to a file.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_7dump(PyObject *__pyx_v_self, PyObject *__pyx_v_file); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_dump(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_file, int __pyx_skip_dispatch) {
  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;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("dump", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dump); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_7dump)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_file); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_file};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_file};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 285, __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 = NULL;
          __Pyx_INCREF(__pyx_v_file);
          __Pyx_GIVEREF(__pyx_v_file);
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_file);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":292
 * 
 *         """
 *         six.moves.cPickle.dump(self, file, -1)             # <<<<<<<<<<<<<<
 * 
 *     cpdef dumps(self):
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_moves); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_cPickle); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dump); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && likely(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_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_2, ((PyObject *)__pyx_v_self), __pyx_v_file, __pyx_int_neg_1};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_2, ((PyObject *)__pyx_v_self), __pyx_v_file, __pyx_int_neg_1};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 292, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_file);
    __Pyx_GIVEREF(__pyx_v_file);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_file);
    __Pyx_INCREF(__pyx_int_neg_1);
    __Pyx_GIVEREF(__pyx_int_neg_1);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_6, __pyx_int_neg_1);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":285
 *         self.get().tofile(fid, sep, format)
 * 
 *     cpdef dump(self, file):             # <<<<<<<<<<<<<<
 *         """Dumps a pickle of the array to a file.
 * 
 */

  /* 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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.dump", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_7dump(PyObject *__pyx_v_self, PyObject *__pyx_v_file); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_6dump[] = "ndarray.dump(self, file)\nDumps a pickle of the array to a file.\n\n        Dumped file can be read back to :class:`cupy.ndarray` by\n        :func:`cupy.load`.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_7dump(PyObject *__pyx_v_self, PyObject *__pyx_v_file) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dump (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_6dump(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_file));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_6dump(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_file) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("dump", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray_dump(__pyx_v_self, __pyx_v_file, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.dump", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":294
 *         six.moves.cPickle.dump(self, file, -1)
 * 
 *     cpdef dumps(self):             # <<<<<<<<<<<<<<
 *         """Dumps a pickle of the array to a string."""
 *         return six.moves.cPickle.dumps(self, -1)
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_9dumps(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_dumps(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  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;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("dumps", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dumps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_9dumps)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 294, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 294, __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;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":296
 *     cpdef dumps(self):
 *         """Dumps a pickle of the array to a string."""
 *         return six.moves.cPickle.dumps(self, -1)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray astype(
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_moves); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_cPickle); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dumps); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(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_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, ((PyObject *)__pyx_v_self), __pyx_int_neg_1};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, ((PyObject *)__pyx_v_self), __pyx_int_neg_1};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_int_neg_1);
    __Pyx_GIVEREF(__pyx_int_neg_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_int_neg_1);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":294
 *         six.moves.cPickle.dump(self, file, -1)
 * 
 *     cpdef dumps(self):             # <<<<<<<<<<<<<<
 *         """Dumps a pickle of the array to a string."""
 *         return six.moves.cPickle.dumps(self, -1)
 */

  /* 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("cupy.core.core.ndarray.dumps", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_9dumps(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_8dumps[] = "ndarray.dumps(self)\nDumps a pickle of the array to a string.";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_9dumps(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dumps (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_8dumps(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_8dumps(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("dumps", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray_dumps(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.dumps", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":298
 *         return six.moves.cPickle.dumps(self, -1)
 * 
 *     cpdef ndarray astype(             # <<<<<<<<<<<<<<
 *             self, dtype, order='K', casting=None, subok=None, copy=True):
 *         """Casts the array to given data type.
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_11astype(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_astype(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype *__pyx_optional_args) {
  PyObject *__pyx_v_order = ((PyObject *)__pyx_n_s_K);

  /* "cupy/core/core.pyx":299
 * 
 *     cpdef ndarray astype(
 *             self, dtype, order='K', casting=None, subok=None, copy=True):             # <<<<<<<<<<<<<<
 *         """Casts the array to given data type.
 * 
 */
  PyObject *__pyx_v_casting = ((PyObject *)Py_None);
  PyObject *__pyx_v_subok = ((PyObject *)Py_None);
  PyObject *__pyx_v_copy = ((PyObject *)Py_True);
  std::vector<Py_ssize_t>  __pyx_v_strides;
  Py_ssize_t __pyx_v_stride;
  int __pyx_v_order_char;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_newarray = NULL;
  PyObject *__pyx_v_stride_and_index = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_i = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  std::vector<Py_ssize_t> ::size_type __pyx_t_14;
  PyObject *(*__pyx_t_15)(PyObject *);
  std::vector<Py_ssize_t> ::size_type __pyx_t_16;
  __Pyx_RefNannySetupContext("astype", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_order = __pyx_optional_args->order;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_casting = __pyx_optional_args->casting;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_subok = __pyx_optional_args->subok;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_copy = __pyx_optional_args->copy;
          }
        }
      }
    }
  }
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_INCREF(__pyx_v_order);

  /* "cupy/core/core.pyx":298
 *         return six.moves.cPickle.dumps(self, -1)
 * 
 *     cpdef ndarray astype(             # <<<<<<<<<<<<<<
 *             self, dtype, order='K', casting=None, subok=None, copy=True):
 *         """Casts the array to given data type.
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_11astype)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_dtype, __pyx_v_order, __pyx_v_casting, __pyx_v_subok, __pyx_v_copy};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_dtype, __pyx_v_order, __pyx_v_casting, __pyx_v_subok, __pyx_v_copy};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 298, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_dtype);
        __Pyx_INCREF(__pyx_v_order);
        __Pyx_GIVEREF(__pyx_v_order);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_order);
        __Pyx_INCREF(__pyx_v_casting);
        __Pyx_GIVEREF(__pyx_v_casting);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_casting);
        __Pyx_INCREF(__pyx_v_subok);
        __Pyx_GIVEREF(__pyx_v_subok);
        PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_subok);
        __Pyx_INCREF(__pyx_v_copy);
        __Pyx_GIVEREF(__pyx_v_copy);
        PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_v_copy);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 298, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":329
 * 
 *         # TODO(beam2d): Support casting and subok option
 *         if casting is not None:             # <<<<<<<<<<<<<<
 *             raise TypeError('casting is not supported yet')
 *         if subok is not None:
 */
  __pyx_t_7 = (__pyx_v_casting != Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (unlikely(__pyx_t_8)) {

    /* "cupy/core/core.pyx":330
 *         # TODO(beam2d): Support casting and subok option
 *         if casting is not None:
 *             raise TypeError('casting is not supported yet')             # <<<<<<<<<<<<<<
 *         if subok is not None:
 *             raise TypeError('subok is not supported yet')
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __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(0, 330, __pyx_L1_error)

    /* "cupy/core/core.pyx":329
 * 
 *         # TODO(beam2d): Support casting and subok option
 *         if casting is not None:             # <<<<<<<<<<<<<<
 *             raise TypeError('casting is not supported yet')
 *         if subok is not None:
 */
  }

  /* "cupy/core/core.pyx":331
 *         if casting is not None:
 *             raise TypeError('casting is not supported yet')
 *         if subok is not None:             # <<<<<<<<<<<<<<
 *             raise TypeError('subok is not supported yet')
 * 
 */
  __pyx_t_8 = (__pyx_v_subok != Py_None);
  __pyx_t_7 = (__pyx_t_8 != 0);
  if (unlikely(__pyx_t_7)) {

    /* "cupy/core/core.pyx":332
 *             raise TypeError('casting is not supported yet')
 *         if subok is not None:
 *             raise TypeError('subok is not supported yet')             # <<<<<<<<<<<<<<
 * 
 *         if order is None:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __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(0, 332, __pyx_L1_error)

    /* "cupy/core/core.pyx":331
 *         if casting is not None:
 *             raise TypeError('casting is not supported yet')
 *         if subok is not None:             # <<<<<<<<<<<<<<
 *             raise TypeError('subok is not supported yet')
 * 
 */
  }

  /* "cupy/core/core.pyx":334
 *             raise TypeError('subok is not supported yet')
 * 
 *         if order is None:             # <<<<<<<<<<<<<<
 *             order = 'K'
 *         cdef int order_char = _normalize_order(order)
 */
  __pyx_t_7 = (__pyx_v_order == Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":335
 * 
 *         if order is None:
 *             order = 'K'             # <<<<<<<<<<<<<<
 *         cdef int order_char = _normalize_order(order)
 * 
 */
    __Pyx_INCREF(__pyx_n_s_K);
    __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_s_K);

    /* "cupy/core/core.pyx":334
 *             raise TypeError('subok is not supported yet')
 * 
 *         if order is None:             # <<<<<<<<<<<<<<
 *             order = 'K'
 *         cdef int order_char = _normalize_order(order)
 */
  }

  /* "cupy/core/core.pyx":336
 *         if order is None:
 *             order = 'K'
 *         cdef int order_char = _normalize_order(order)             # <<<<<<<<<<<<<<
 * 
 *         dtype = get_dtype(dtype)
 */
  if (!(likely(PyString_CheckExact(__pyx_v_order))||((__pyx_v_order) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_order)->tp_name), 0))) __PYX_ERR(0, 336, __pyx_L1_error)
  __pyx_t_5 = __pyx_f_4cupy_4core_4core__normalize_order(((PyObject*)__pyx_v_order)); if (unlikely(__pyx_t_5 == ((int)0) && PyErr_Occurred())) __PYX_ERR(0, 336, __pyx_L1_error)
  __pyx_v_order_char = __pyx_t_5;

  /* "cupy/core/core.pyx":338
 *         cdef int order_char = _normalize_order(order)
 * 
 *         dtype = get_dtype(dtype)             # <<<<<<<<<<<<<<
 *         if dtype == self.dtype:
 *             if not copy and (
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":339
 * 
 *         dtype = get_dtype(dtype)
 *         if dtype == self.dtype:             # <<<<<<<<<<<<<<
 *             if not copy and (
 *                     order_char == 'K' or
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_dtype, __pyx_v_self->dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 339, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":340
 *         dtype = get_dtype(dtype)
 *         if dtype == self.dtype:
 *             if not copy and (             # <<<<<<<<<<<<<<
 *                     order_char == 'K' or
 *                     order_char == 'A' and (self._c_contiguous or
 */
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_copy); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 340, __pyx_L1_error)
    __pyx_t_9 = ((!__pyx_t_7) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L8_bool_binop_done;
    }

    /* "cupy/core/core.pyx":341
 *         if dtype == self.dtype:
 *             if not copy and (
 *                     order_char == 'K' or             # <<<<<<<<<<<<<<
 *                     order_char == 'A' and (self._c_contiguous or
 *                                            self._f_contiguous) or
 */
    __pyx_t_9 = ((__pyx_v_order_char == 'K') != 0);
    if (!__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L8_bool_binop_done;
    }

    /* "cupy/core/core.pyx":342
 *             if not copy and (
 *                     order_char == 'K' or
 *                     order_char == 'A' and (self._c_contiguous or             # <<<<<<<<<<<<<<
 *                                            self._f_contiguous) or
 *                     order_char == 'C' and self._c_contiguous or
 */
    __pyx_t_9 = ((__pyx_v_order_char == 'A') != 0);
    if (!__pyx_t_9) {
      goto __pyx_L11_next_or;
    } else {
    }
    __pyx_t_9 = (__pyx_v_self->_c_contiguous != 0);
    if (!__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L8_bool_binop_done;
    }

    /* "cupy/core/core.pyx":343
 *                     order_char == 'K' or
 *                     order_char == 'A' and (self._c_contiguous or
 *                                            self._f_contiguous) or             # <<<<<<<<<<<<<<
 *                     order_char == 'C' and self._c_contiguous or
 *                     order_char == 'F' and self._f_contiguous):
 */
    __pyx_t_9 = (__pyx_v_self->_f_contiguous != 0);
    if (!__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_L11_next_or:;

    /* "cupy/core/core.pyx":344
 *                     order_char == 'A' and (self._c_contiguous or
 *                                            self._f_contiguous) or
 *                     order_char == 'C' and self._c_contiguous or             # <<<<<<<<<<<<<<
 *                     order_char == 'F' and self._f_contiguous):
 *                 return self
 */
    __pyx_t_9 = ((__pyx_v_order_char == 'C') != 0);
    if (!__pyx_t_9) {
      goto __pyx_L14_next_or;
    } else {
    }
    __pyx_t_9 = (__pyx_v_self->_c_contiguous != 0);
    if (!__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_L14_next_or:;

    /* "cupy/core/core.pyx":345
 *                                            self._f_contiguous) or
 *                     order_char == 'C' and self._c_contiguous or
 *                     order_char == 'F' and self._f_contiguous):             # <<<<<<<<<<<<<<
 *                 return self
 * 
 */
    __pyx_t_9 = ((__pyx_v_order_char == 'F') != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_9 = (__pyx_v_self->_f_contiguous != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L8_bool_binop_done:;

    /* "cupy/core/core.pyx":340
 *         dtype = get_dtype(dtype)
 *         if dtype == self.dtype:
 *             if not copy and (             # <<<<<<<<<<<<<<
 *                     order_char == 'K' or
 *                     order_char == 'A' and (self._c_contiguous or
 */
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":346
 *                     order_char == 'C' and self._c_contiguous or
 *                     order_char == 'F' and self._f_contiguous):
 *                 return self             # <<<<<<<<<<<<<<
 * 
 *         if order_char == 'A':
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __pyx_r = __pyx_v_self;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":340
 *         dtype = get_dtype(dtype)
 *         if dtype == self.dtype:
 *             if not copy and (             # <<<<<<<<<<<<<<
 *                     order_char == 'K' or
 *                     order_char == 'A' and (self._c_contiguous or
 */
    }

    /* "cupy/core/core.pyx":339
 * 
 *         dtype = get_dtype(dtype)
 *         if dtype == self.dtype:             # <<<<<<<<<<<<<<
 *             if not copy and (
 *                     order_char == 'K' or
 */
  }

  /* "cupy/core/core.pyx":348
 *                 return self
 * 
 *         if order_char == 'A':             # <<<<<<<<<<<<<<
 *             if self._f_contiguous:
 *                 order_char = 'F'
 */
  switch (__pyx_v_order_char) {
    case 'A':

    /* "cupy/core/core.pyx":349
 * 
 *         if order_char == 'A':
 *             if self._f_contiguous:             # <<<<<<<<<<<<<<
 *                 order_char = 'F'
 *             else:
 */
    __pyx_t_8 = (__pyx_v_self->_f_contiguous != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":350
 *         if order_char == 'A':
 *             if self._f_contiguous:
 *                 order_char = 'F'             # <<<<<<<<<<<<<<
 *             else:
 *                 order_char = 'C'
 */
      __pyx_v_order_char = 'F';

      /* "cupy/core/core.pyx":349
 * 
 *         if order_char == 'A':
 *             if self._f_contiguous:             # <<<<<<<<<<<<<<
 *                 order_char = 'F'
 *             else:
 */
      goto __pyx_L17;
    }

    /* "cupy/core/core.pyx":352
 *                 order_char = 'F'
 *             else:
 *                 order_char = 'C'             # <<<<<<<<<<<<<<
 *         elif order_char == 'K':
 *             if self._f_contiguous:
 */
    /*else*/ {
      __pyx_v_order_char = 'C';
    }
    __pyx_L17:;

    /* "cupy/core/core.pyx":348
 *                 return self
 * 
 *         if order_char == 'A':             # <<<<<<<<<<<<<<
 *             if self._f_contiguous:
 *                 order_char = 'F'
 */
    break;

    /* "cupy/core/core.pyx":353
 *             else:
 *                 order_char = 'C'
 *         elif order_char == 'K':             # <<<<<<<<<<<<<<
 *             if self._f_contiguous:
 *                 order_char = 'F'
 */
    case 'K':

    /* "cupy/core/core.pyx":354
 *                 order_char = 'C'
 *         elif order_char == 'K':
 *             if self._f_contiguous:             # <<<<<<<<<<<<<<
 *                 order_char = 'F'
 *             elif self._c_contiguous:
 */
    __pyx_t_8 = (__pyx_v_self->_f_contiguous != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":355
 *         elif order_char == 'K':
 *             if self._f_contiguous:
 *                 order_char = 'F'             # <<<<<<<<<<<<<<
 *             elif self._c_contiguous:
 *                 order_char = 'C'
 */
      __pyx_v_order_char = 'F';

      /* "cupy/core/core.pyx":354
 *                 order_char = 'C'
 *         elif order_char == 'K':
 *             if self._f_contiguous:             # <<<<<<<<<<<<<<
 *                 order_char = 'F'
 *             elif self._c_contiguous:
 */
      goto __pyx_L18;
    }

    /* "cupy/core/core.pyx":356
 *             if self._f_contiguous:
 *                 order_char = 'F'
 *             elif self._c_contiguous:             # <<<<<<<<<<<<<<
 *                 order_char = 'C'
 * 
 */
    __pyx_t_8 = (__pyx_v_self->_c_contiguous != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":357
 *                 order_char = 'F'
 *             elif self._c_contiguous:
 *                 order_char = 'C'             # <<<<<<<<<<<<<<
 * 
 *         if order_char == 'K':
 */
      __pyx_v_order_char = 'C';

      /* "cupy/core/core.pyx":356
 *             if self._f_contiguous:
 *                 order_char = 'F'
 *             elif self._c_contiguous:             # <<<<<<<<<<<<<<
 *                 order_char = 'C'
 * 
 */
    }
    __pyx_L18:;

    /* "cupy/core/core.pyx":353
 *             else:
 *                 order_char = 'C'
 *         elif order_char == 'K':             # <<<<<<<<<<<<<<
 *             if self._f_contiguous:
 *                 order_char = 'F'
 */
    break;
    default: break;
  }

  /* "cupy/core/core.pyx":359
 *                 order_char = 'C'
 * 
 *         if order_char == 'K':             # <<<<<<<<<<<<<<
 *             newarray = ndarray(self.shape, dtype=dtype)
 *             stride_and_index = [
 */
  __pyx_t_8 = ((__pyx_v_order_char == 'K') != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":360
 * 
 *         if order_char == 'K':
 *             newarray = ndarray(self.shape, dtype=dtype)             # <<<<<<<<<<<<<<
 *             stride_and_index = [
 *                 (abs(s), -i) for i, s in enumerate(self._strides)]
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 360, __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_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 360, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":361
 *         if order_char == 'K':
 *             newarray = ndarray(self.shape, dtype=dtype)
 *             stride_and_index = [             # <<<<<<<<<<<<<<
 *                 (abs(s), -i) for i, s in enumerate(self._strides)]
 *             stride_and_index.sort()
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_1 = __pyx_int_0;

    /* "cupy/core/core.pyx":362
 *             newarray = ndarray(self.shape, dtype=dtype)
 *             stride_and_index = [
 *                 (abs(s), -i) for i, s in enumerate(self._strides)]             # <<<<<<<<<<<<<<
 *             stride_and_index.sort()
 *             strides.resize(self.ndim)
 */
    __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_strides); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_6 = __pyx_t_2; __Pyx_INCREF(__pyx_t_6); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 362, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 362, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_11)) {
        if (likely(PyList_CheckExact(__pyx_t_6))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 362, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 362, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_11(__pyx_t_6);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 362, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
      __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1);
      __pyx_t_1 = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":361
 *         if order_char == 'K':
 *             newarray = ndarray(self.shape, dtype=dtype)
 *             stride_and_index = [             # <<<<<<<<<<<<<<
 *                 (abs(s), -i) for i, s in enumerate(self._strides)]
 *             stride_and_index.sort()
 */
      __pyx_t_2 = __Pyx_PyNumber_Absolute(__pyx_v_s); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);

      /* "cupy/core/core.pyx":362
 *             newarray = ndarray(self.shape, dtype=dtype)
 *             stride_and_index = [
 *                 (abs(s), -i) for i, s in enumerate(self._strides)]             # <<<<<<<<<<<<<<
 *             stride_and_index.sort()
 *             strides.resize(self.ndim)
 */
      __pyx_t_4 = PyNumber_Negative(__pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 362, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 362, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_4);
      __pyx_t_2 = 0;
      __pyx_t_4 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_12))) __PYX_ERR(0, 361, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_stride_and_index = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":363
 *             stride_and_index = [
 *                 (abs(s), -i) for i, s in enumerate(self._strides)]
 *             stride_and_index.sort()             # <<<<<<<<<<<<<<
 *             strides.resize(self.ndim)
 *             stride = dtype.itemsize
 */
    __pyx_t_13 = PyList_Sort(__pyx_v_stride_and_index); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 363, __pyx_L1_error)

    /* "cupy/core/core.pyx":364
 *                 (abs(s), -i) for i, s in enumerate(self._strides)]
 *             stride_and_index.sort()
 *             strides.resize(self.ndim)             # <<<<<<<<<<<<<<
 *             stride = dtype.itemsize
 *             for s, i in stride_and_index:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_14 = __Pyx_PyInt_As_size_t(__pyx_t_3); if (unlikely((__pyx_t_14 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 364, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    try {
      __pyx_v_strides.resize(__pyx_t_14);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 364, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":365
 *             stride_and_index.sort()
 *             strides.resize(self.ndim)
 *             stride = dtype.itemsize             # <<<<<<<<<<<<<<
 *             for s, i in stride_and_index:
 *                 strides[-i] = stride
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 365, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_stride = __pyx_t_10;

    /* "cupy/core/core.pyx":366
 *             strides.resize(self.ndim)
 *             stride = dtype.itemsize
 *             for s, i in stride_and_index:             # <<<<<<<<<<<<<<
 *                 strides[-i] = stride
 *                 stride *= self._shape[-i]
 */
    __pyx_t_3 = __pyx_v_stride_and_index; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0;
    for (;;) {
      if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 366, __pyx_L1_error)
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        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(0, 366, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_12 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_12);
        #else
        __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 366, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 366, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 366, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_15 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_15(__pyx_t_4); if (unlikely(!__pyx_t_6)) goto __pyx_L24_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_12 = __pyx_t_15(__pyx_t_4); if (unlikely(!__pyx_t_12)) goto __pyx_L24_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_12);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_4), 2) < 0) __PYX_ERR(0, 366, __pyx_L1_error)
        __pyx_t_15 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L25_unpacking_done;
        __pyx_L24_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_15 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 366, __pyx_L1_error)
        __pyx_L25_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "cupy/core/core.pyx":367
 *             stride = dtype.itemsize
 *             for s, i in stride_and_index:
 *                 strides[-i] = stride             # <<<<<<<<<<<<<<
 *                 stride *= self._shape[-i]
 *             newarray._set_shape_and_strides(self._shape, strides)
 */
      __pyx_t_1 = PyNumber_Negative(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_16 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_16 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 367, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      (__pyx_v_strides[__pyx_t_16]) = __pyx_v_stride;

      /* "cupy/core/core.pyx":368
 *             for s, i in stride_and_index:
 *                 strides[-i] = stride
 *                 stride *= self._shape[-i]             # <<<<<<<<<<<<<<
 *             newarray._set_shape_and_strides(self._shape, strides)
 *         else:
 */
      __pyx_t_1 = PyNumber_Negative(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 368, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_16 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_16 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 368, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_stride = (__pyx_v_stride * (__pyx_v_self->_shape[__pyx_t_16]));

      /* "cupy/core/core.pyx":366
 *             strides.resize(self.ndim)
 *             stride = dtype.itemsize
 *             for s, i in stride_and_index:             # <<<<<<<<<<<<<<
 *                 strides[-i] = stride
 *                 stride *= self._shape[-i]
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":369
 *                 strides[-i] = stride
 *                 stride *= self._shape[-i]
 *             newarray._set_shape_and_strides(self._shape, strides)             # <<<<<<<<<<<<<<
 *         else:
 *             newarray = ndarray(self.shape, dtype=dtype, order=chr(order_char))
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_newarray->__pyx_vtab)->_set_shape_and_strides(__pyx_v_newarray, __pyx_v_self->_shape, __pyx_v_strides, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 369, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":359
 *                 order_char = 'C'
 * 
 *         if order_char == 'K':             # <<<<<<<<<<<<<<
 *             newarray = ndarray(self.shape, dtype=dtype)
 *             stride_and_index = [
 */
    goto __pyx_L19;
  }

  /* "cupy/core/core.pyx":371
 *             newarray._set_shape_and_strides(self._shape, strides)
 *         else:
 *             newarray = ndarray(self.shape, dtype=dtype, order=chr(order_char))             # <<<<<<<<<<<<<<
 * 
 *         if self.dtype.kind == 'c' and newarray.dtype.kind == 'b':
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
    __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_order_char); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_chr, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_order, __pyx_t_6) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
    __pyx_t_6 = 0;
  }
  __pyx_L19:;

  /* "cupy/core/core.pyx":373
 *             newarray = ndarray(self.shape, dtype=dtype, order=chr(order_char))
 * 
 *         if self.dtype.kind == 'c' and newarray.dtype.kind == 'b':             # <<<<<<<<<<<<<<
 *             cupy.not_equal(self, 0j, out=newarray)
 *         elif self.dtype.kind == 'c' and newarray.dtype.kind != 'c':
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_t_6, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_9) {
  } else {
    __pyx_t_8 = __pyx_t_9;
    goto __pyx_L27_bool_binop_done;
  }
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_newarray->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_t_6, __pyx_n_s_b, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_8 = __pyx_t_9;
  __pyx_L27_bool_binop_done:;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":374
 * 
 *         if self.dtype.kind == 'c' and newarray.dtype.kind == 'b':
 *             cupy.not_equal(self, 0j, out=newarray)             # <<<<<<<<<<<<<<
 *         elif self.dtype.kind == 'c' and newarray.dtype.kind != 'c':
 *             warnings.warn(
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 374, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_not_equal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 374, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyComplex_FromDoubles(0.0, 0.0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 374, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 374, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_out, ((PyObject *)__pyx_v_newarray)) < 0) __PYX_ERR(0, 374, __pyx_L1_error)
    __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 374, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":373
 *             newarray = ndarray(self.shape, dtype=dtype, order=chr(order_char))
 * 
 *         if self.dtype.kind == 'c' and newarray.dtype.kind == 'b':             # <<<<<<<<<<<<<<
 *             cupy.not_equal(self, 0j, out=newarray)
 *         elif self.dtype.kind == 'c' and newarray.dtype.kind != 'c':
 */
    goto __pyx_L26;
  }

  /* "cupy/core/core.pyx":375
 *         if self.dtype.kind == 'c' and newarray.dtype.kind == 'b':
 *             cupy.not_equal(self, 0j, out=newarray)
 *         elif self.dtype.kind == 'c' and newarray.dtype.kind != 'c':             # <<<<<<<<<<<<<<
 *             warnings.warn(
 *                 'Casting complex values to real discards the imaginary part',
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_t_12, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (__pyx_t_9) {
  } else {
    __pyx_t_8 = __pyx_t_9;
    goto __pyx_L29_bool_binop_done;
  }
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_newarray->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_t_12, __pyx_n_s_c, Py_NE)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_8 = __pyx_t_9;
  __pyx_L29_bool_binop_done:;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":376
 *             cupy.not_equal(self, 0j, out=newarray)
 *         elif self.dtype.kind == 'c' and newarray.dtype.kind != 'c':
 *             warnings.warn(             # <<<<<<<<<<<<<<
 *                 'Casting complex values to real discards the imaginary part',
 *                 numpy.ComplexWarning)
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_warnings); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 376, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_warn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 376, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":378
 *             warnings.warn(
 *                 'Casting complex values to real discards the imaginary part',
 *                 numpy.ComplexWarning)             # <<<<<<<<<<<<<<
 *             elementwise_copy(self.real, newarray)
 *         else:
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 378, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ComplexWarning); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 378, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    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_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_Casting_complex_values_to_real_d, __pyx_t_3};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 376, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_Casting_complex_values_to_real_d, __pyx_t_3};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 376, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 376, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_s_Casting_complex_values_to_real_d);
      __Pyx_GIVEREF(__pyx_kp_s_Casting_complex_values_to_real_d);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_kp_s_Casting_complex_values_to_real_d);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 376, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":379
 *                 'Casting complex values to real discards the imaginary part',
 *                 numpy.ComplexWarning)
 *             elementwise_copy(self.real, newarray)             # <<<<<<<<<<<<<<
 *         else:
 *             elementwise_copy(self, newarray)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 379, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_real); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 379, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(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_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_v_newarray)};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 379, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_v_newarray)};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 379, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 379, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_newarray));
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, ((PyObject *)__pyx_v_newarray));
      __pyx_t_4 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 379, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":375
 *         if self.dtype.kind == 'c' and newarray.dtype.kind == 'b':
 *             cupy.not_equal(self, 0j, out=newarray)
 *         elif self.dtype.kind == 'c' and newarray.dtype.kind != 'c':             # <<<<<<<<<<<<<<
 *             warnings.warn(
 *                 'Casting complex values to real discards the imaginary part',
 */
    goto __pyx_L26;
  }

  /* "cupy/core/core.pyx":381
 *             elementwise_copy(self.real, newarray)
 *         else:
 *             elementwise_copy(self, newarray)             # <<<<<<<<<<<<<<
 *         return newarray
 * 
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 381, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    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_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_newarray)};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 381, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_12);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_newarray)};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 381, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_12);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_newarray));
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, ((PyObject *)__pyx_v_newarray));
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 381, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __pyx_L26:;

  /* "cupy/core/core.pyx":382
 *         else:
 *             elementwise_copy(self, newarray)
 *         return newarray             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement byteswap
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
  __pyx_r = __pyx_v_newarray;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":298
 *         return six.moves.cPickle.dumps(self, -1)
 * 
 *     cpdef ndarray astype(             # <<<<<<<<<<<<<<
 *             self, dtype, order='K', casting=None, subok=None, copy=True):
 *         """Casts the array to given data type.
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core.ndarray.astype", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_newarray);
  __Pyx_XDECREF(__pyx_v_stride_and_index);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_order);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_11astype(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_10astype[] = "ndarray.astype(self, dtype, order='K', casting=None, subok=None, copy=True) -> ndarray\nCasts the array to given data type.\n\n        Args:\n            dtype: Type specifier.\n            order ({'C', 'F', 'A', 'K'}): Row-major (C-style) or column-major\n                (Fortran-style) order.\n                When ``order`` is 'A', it uses 'F' if ``a`` is column-major and\n                uses 'C' otherwise.\n                And when ``order`` is 'K', it keeps strides as closely as\n                possible.\n            copy (bool): If it is False and no cast happens, then this method\n                returns the array itself. Otherwise, a copy is returned.\n\n        Returns:\n            If ``copy`` is False and no cast is required, then the array itself\n            is returned. Otherwise, it returns a (possibly casted) copy of the\n            array.\n\n        .. note::\n           This method currently does not support ``casting``, and ``subok``\n           arguments.\n\n        .. seealso:: :meth:`numpy.ndarray.astype`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_11astype(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_order = 0;
  PyObject *__pyx_v_casting = 0;
  PyObject *__pyx_v_subok = 0;
  PyObject *__pyx_v_copy = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("astype (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dtype,&__pyx_n_s_order,&__pyx_n_s_casting,&__pyx_n_s_subok,&__pyx_n_s_copy,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[1] = ((PyObject *)__pyx_n_s_K);

    /* "cupy/core/core.pyx":299
 * 
 *     cpdef ndarray astype(
 *             self, dtype, order='K', casting=None, subok=None, copy=True):             # <<<<<<<<<<<<<<
 *         """Casts the array to given data type.
 * 
 */
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)Py_True);
    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_dtype)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_order);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_casting);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_subok);
          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_copy);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "astype") < 0)) __PYX_ERR(0, 298, __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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_dtype = values[0];
    __pyx_v_order = values[1];
    __pyx_v_casting = values[2];
    __pyx_v_subok = values[3];
    __pyx_v_copy = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("astype", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 298, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.astype", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_10astype(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_dtype, __pyx_v_order, __pyx_v_casting, __pyx_v_subok, __pyx_v_copy);

  /* "cupy/core/core.pyx":298
 *         return six.moves.cPickle.dumps(self, -1)
 * 
 *     cpdef ndarray astype(             # <<<<<<<<<<<<<<
 *             self, dtype, order='K', casting=None, subok=None, copy=True):
 *         """Casts the array to given data type.
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_10astype(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype, PyObject *__pyx_v_order, PyObject *__pyx_v_casting, PyObject *__pyx_v_subok, PyObject *__pyx_v_copy) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype __pyx_t_2;
  __Pyx_RefNannySetupContext("astype", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.order = __pyx_v_order;
  __pyx_t_2.casting = __pyx_v_casting;
  __pyx_t_2.subok = __pyx_v_subok;
  __pyx_t_2.copy = __pyx_v_copy;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->astype(__pyx_v_self, __pyx_v_dtype, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.astype", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":386
 *     # TODO(okuta): Implement byteswap
 * 
 *     cpdef ndarray copy(self, order='C'):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_13copy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_copy(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy *__pyx_optional_args) {
  PyObject *__pyx_v_order = ((PyObject *)__pyx_n_s_C);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_newarray = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  Py_ssize_t __pyx_t_15;
  __Pyx_RefNannySetupContext("copy", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_order = __pyx_optional_args->order;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 386, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_13copy)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_order); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 386, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_order};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 386, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_order};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 386, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 386, __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 = NULL;
          __Pyx_INCREF(__pyx_v_order);
          __Pyx_GIVEREF(__pyx_v_order);
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_order);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 386, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 386, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":406
 * 
 *         """
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return self.astype(self.dtype, copy=True, order=order)
 * 
 */
  __pyx_t_6 = ((__pyx_v_self->size == 0) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":407
 *         """
 *         if self.size == 0:
 *             return self.astype(self.dtype, copy=True, order=order)             # <<<<<<<<<<<<<<
 * 
 *         if (self.data.device is None or
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_self->dtype);
    __Pyx_GIVEREF(__pyx_v_self->dtype);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->dtype);
    __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_copy, Py_True) < 0) __PYX_ERR(0, 407, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 407, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 407, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":406
 * 
 *         """
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return self.astype(self.dtype, copy=True, order=order)
 * 
 */
  }

  /* "cupy/core/core.pyx":409
 *             return self.astype(self.dtype, copy=True, order=order)
 * 
 *         if (self.data.device is None or             # <<<<<<<<<<<<<<
 *                 self.data.device.id == device.get_device_id()):
 *             return self.astype(self.dtype, copy=True, order=order)
 */
  __pyx_t_7 = (((PyObject *)__pyx_v_self->data->device) == Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_6 = __pyx_t_8;
    goto __pyx_L5_bool_binop_done;
  }

  /* "cupy/core/core.pyx":410
 * 
 *         if (self.data.device is None or
 *                 self.data.device.id == device.get_device_id()):             # <<<<<<<<<<<<<<
 *             return self.astype(self.dtype, copy=True, order=order)
 *         else:
 */
  __pyx_t_9 = __pyx_f_4cupy_4cuda_6device_get_device_id(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 410, __pyx_L1_error)
  __pyx_t_8 = ((__pyx_v_self->data->device->id == __pyx_t_9) != 0);
  __pyx_t_6 = __pyx_t_8;
  __pyx_L5_bool_binop_done:;

  /* "cupy/core/core.pyx":409
 *             return self.astype(self.dtype, copy=True, order=order)
 * 
 *         if (self.data.device is None or             # <<<<<<<<<<<<<<
 *                 self.data.device.id == device.get_device_id()):
 *             return self.astype(self.dtype, copy=True, order=order)
 */
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":411
 *         if (self.data.device is None or
 *                 self.data.device.id == device.get_device_id()):
 *             return self.astype(self.dtype, copy=True, order=order)             # <<<<<<<<<<<<<<
 *         else:
 *             # It need to make a contiguous copy for copying from another device
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_astype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_self->dtype);
    __Pyx_GIVEREF(__pyx_v_self->dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->dtype);
    __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_copy, Py_True) < 0) __PYX_ERR(0, 411, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 411, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 411, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":409
 *             return self.astype(self.dtype, copy=True, order=order)
 * 
 *         if (self.data.device is None or             # <<<<<<<<<<<<<<
 *                 self.data.device.id == device.get_device_id()):
 *             return self.astype(self.dtype, copy=True, order=order)
 */
  }

  /* "cupy/core/core.pyx":414
 *         else:
 *             # It need to make a contiguous copy for copying from another device
 *             with self.device:             # <<<<<<<<<<<<<<
 *                 x = self.astype(self.dtype, copy=False, order=order)
 *             newarray = ndarray(x.shape, dtype=x.dtype)
 */
  /*else*/ {
    /*with:*/ {
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 414, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 414, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 414, __pyx_L7_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 414, __pyx_L7_error)
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      /*try:*/ {
        {
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          /*try:*/ {

            /* "cupy/core/core.pyx":415
 *             # It need to make a contiguous copy for copying from another device
 *             with self.device:
 *                 x = self.astype(self.dtype, copy=False, order=order)             # <<<<<<<<<<<<<<
 *             newarray = ndarray(x.shape, dtype=x.dtype)
 *             newarray._set_shape_and_strides(x._shape, x._strides)
 */
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 415, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 415, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_INCREF(__pyx_v_self->dtype);
            __Pyx_GIVEREF(__pyx_v_self->dtype);
            PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->dtype);
            __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 415, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_3);
            if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 415, __pyx_L11_error)
            if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 415, __pyx_L11_error)
            __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 415, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 415, __pyx_L11_error)
            __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
            __pyx_t_5 = 0;

            /* "cupy/core/core.pyx":414
 *         else:
 *             # It need to make a contiguous copy for copying from another device
 *             with self.device:             # <<<<<<<<<<<<<<
 *                 x = self.astype(self.dtype, copy=False, order=order)
 *             newarray = ndarray(x.shape, dtype=x.dtype)
 */
          }
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          goto __pyx_L16_try_end;
          __pyx_L11_error:;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          /*except:*/ {
            __Pyx_AddTraceback("cupy.core.core.ndarray.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 414, __pyx_L13_except_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_1 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L13_except_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_1, NULL);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 414, __pyx_L13_except_error)
            __Pyx_GOTREF(__pyx_t_14);
            __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            if (__pyx_t_6 < 0) __PYX_ERR(0, 414, __pyx_L13_except_error)
            __pyx_t_8 = ((!(__pyx_t_6 != 0)) != 0);
            if (__pyx_t_8) {
              __Pyx_GIVEREF(__pyx_t_5);
              __Pyx_GIVEREF(__pyx_t_3);
              __Pyx_XGIVEREF(__pyx_t_2);
              __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_3, __pyx_t_2);
              __pyx_t_5 = 0; __pyx_t_3 = 0; __pyx_t_2 = 0; 
              __PYX_ERR(0, 414, __pyx_L13_except_error)
            }
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            goto __pyx_L12_exception_handled;
          }
          __pyx_L13_except_error:;
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          goto __pyx_L1_error;
          __pyx_L12_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          __pyx_L16_try_end:;
        }
      }
      /*finally:*/ {
        /*normal exit:*/{
          if (__pyx_t_10) {
            __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__9, NULL);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 414, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          }
          goto __pyx_L10;
        }
        __pyx_L10:;
      }
      goto __pyx_L20;
      __pyx_L7_error:;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L1_error;
      __pyx_L20:;
    }

    /* "cupy/core/core.pyx":416
 *             with self.device:
 *                 x = self.astype(self.dtype, copy=False, order=order)
 *             newarray = ndarray(x.shape, dtype=x.dtype)             # <<<<<<<<<<<<<<
 *             newarray._set_shape_and_strides(x._shape, x._strides)
 *             newarray.data.copy_from_device(x.data, x.nbytes)
 */
    if (unlikely(!__pyx_v_x)) { __Pyx_RaiseUnboundLocalError("x"); __PYX_ERR(0, 416, __pyx_L1_error) }
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(!__pyx_v_x)) { __Pyx_RaiseUnboundLocalError("x"); __PYX_ERR(0, 416, __pyx_L1_error) }
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_x->dtype) < 0) __PYX_ERR(0, 416, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":417
 *                 x = self.astype(self.dtype, copy=False, order=order)
 *             newarray = ndarray(x.shape, dtype=x.dtype)
 *             newarray._set_shape_and_strides(x._shape, x._strides)             # <<<<<<<<<<<<<<
 *             newarray.data.copy_from_device(x.data, x.nbytes)
 *             return newarray
 */
    if (unlikely(!__pyx_v_x)) { __Pyx_RaiseUnboundLocalError("x"); __PYX_ERR(0, 417, __pyx_L1_error) }
    if (unlikely(!__pyx_v_x)) { __Pyx_RaiseUnboundLocalError("x"); __PYX_ERR(0, 417, __pyx_L1_error) }
    __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_newarray->__pyx_vtab)->_set_shape_and_strides(__pyx_v_newarray, __pyx_v_x->_shape, __pyx_v_x->_strides, 0, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":418
 *             newarray = ndarray(x.shape, dtype=x.dtype)
 *             newarray._set_shape_and_strides(x._shape, x._strides)
 *             newarray.data.copy_from_device(x.data, x.nbytes)             # <<<<<<<<<<<<<<
 *             return newarray
 * 
 */
    if (unlikely(!__pyx_v_x)) { __Pyx_RaiseUnboundLocalError("x"); __PYX_ERR(0, 418, __pyx_L1_error) }
    __pyx_t_5 = ((PyObject *)__pyx_v_x->data);
    __Pyx_INCREF(__pyx_t_5);
    if (unlikely(!__pyx_v_x)) { __Pyx_RaiseUnboundLocalError("x"); __PYX_ERR(0, 418, __pyx_L1_error) }
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 418, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 418, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_newarray->data->__pyx_vtab)->copy_from_device(__pyx_v_newarray->data, ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_5), __pyx_t_15, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 418, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":419
 *             newarray._set_shape_and_strides(x._shape, x._strides)
 *             newarray.data.copy_from_device(x.data, x.nbytes)
 *             return newarray             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray view(self, dtype=None):
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
    __pyx_r = __pyx_v_newarray;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":386
 *     # TODO(okuta): Implement byteswap
 * 
 *     cpdef ndarray copy(self, order='C'):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array.
 * 
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_newarray);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_13copy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_12copy[] = "ndarray.copy(self, order='C') -> ndarray\nReturns a copy of the array.\n\n        This method makes a copy of a given array in the current device.\n        Even when a given array is located in another device, you can copy it\n        to the current device.\n\n        Args:\n            order ({'C', 'F', 'A', 'K'}): Row-major (C-style) or column-major\n                (Fortran-style) order.\n                When ``order`` is 'A', it uses 'F' if ``a`` is column-major and\n                uses 'C' otherwise.\n                And when `order` is 'K', it keeps strides as closely as\n                possible.\n\n        .. seealso::\n           :func:`cupy.copy` for full documentation,\n           :meth:`numpy.ndarray.copy`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_13copy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_order = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_order,0};
    PyObject* values[1] = {0};
    values[0] = ((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  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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_order);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "copy") < 0)) __PYX_ERR(0, 386, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_order = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("copy", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 386, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_12copy(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_order);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_12copy(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_order) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy __pyx_t_2;
  __Pyx_RefNannySetupContext("copy", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.order = __pyx_v_order;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->copy(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":421
 *             return newarray
 * 
 *     cpdef ndarray view(self, dtype=None):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_15view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view *__pyx_optional_args) {
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_v = 0;
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_strides = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  std::vector<Py_ssize_t>  __pyx_t_8;
  __Pyx_RefNannySetupContext("view", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_dtype = __pyx_optional_args->dtype;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_view); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_15view)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 421, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_dtype};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 421, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_dtype};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 421, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 421, __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 = NULL;
          __Pyx_INCREF(__pyx_v_dtype);
          __Pyx_GIVEREF(__pyx_v_dtype);
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_dtype);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 421, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 421, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":438
 *         # Use __new__ instead of __init__ to skip recomputation of contiguity
 *         cdef ndarray v
 *         v = ndarray.__new__(ndarray)             # <<<<<<<<<<<<<<
 *         v.dtype = self.dtype if dtype is None else get_dtype(dtype)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_4cupy_4core_4core_ndarray(((PyTypeObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":439
 *         cdef ndarray v
 *         v = ndarray.__new__(ndarray)
 *         v.dtype = self.dtype if dtype is None else get_dtype(dtype)             # <<<<<<<<<<<<<<
 * 
 *         if v.dtype.itemsize == self.dtype.itemsize:
 */
  __pyx_t_6 = (__pyx_v_dtype == Py_None);
  if ((__pyx_t_6 != 0)) {
    __Pyx_INCREF(__pyx_v_self->dtype);
    __pyx_t_1 = __pyx_v_self->dtype;
  } else {
    __pyx_t_2 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 439, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_v->dtype);
  __Pyx_DECREF(__pyx_v_v->dtype);
  __pyx_v_v->dtype = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":441
 *         v.dtype = self.dtype if dtype is None else get_dtype(dtype)
 * 
 *         if v.dtype.itemsize == self.dtype.itemsize:             # <<<<<<<<<<<<<<
 *             v.size = self.size
 *             v._shape = self._shape
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_v->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":442
 * 
 *         if v.dtype.itemsize == self.dtype.itemsize:
 *             v.size = self.size             # <<<<<<<<<<<<<<
 *             v._shape = self._shape
 *             v._strides = self._strides
 */
    __pyx_t_7 = __pyx_v_self->size;
    __pyx_v_v->size = __pyx_t_7;

    /* "cupy/core/core.pyx":443
 *         if v.dtype.itemsize == self.dtype.itemsize:
 *             v.size = self.size
 *             v._shape = self._shape             # <<<<<<<<<<<<<<
 *             v._strides = self._strides
 *         else:
 */
    __pyx_t_8 = __pyx_v_self->_shape;
    __pyx_v_v->_shape = __pyx_t_8;

    /* "cupy/core/core.pyx":444
 *             v.size = self.size
 *             v._shape = self._shape
 *             v._strides = self._strides             # <<<<<<<<<<<<<<
 *         else:
 *             if self.ndim == 0:
 */
    __pyx_t_8 = __pyx_v_self->_strides;
    __pyx_v_v->_strides = __pyx_t_8;

    /* "cupy/core/core.pyx":441
 *         v.dtype = self.dtype if dtype is None else get_dtype(dtype)
 * 
 *         if v.dtype.itemsize == self.dtype.itemsize:             # <<<<<<<<<<<<<<
 *             v.size = self.size
 *             v._shape = self._shape
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":446
 *             v._strides = self._strides
 *         else:
 *             if self.ndim == 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     "Changing the dtype of a 0d array is only supported if "
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 446, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 446, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 446, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(__pyx_t_6)) {

      /* "cupy/core/core.pyx":447
 *         else:
 *             if self.ndim == 0:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     "Changing the dtype of a 0d array is only supported if "
 *                     "the itemsize is unchanged")
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 447, __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(0, 447, __pyx_L1_error)

      /* "cupy/core/core.pyx":446
 *             v._strides = self._strides
 *         else:
 *             if self.ndim == 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     "Changing the dtype of a 0d array is only supported if "
 */
    }

    /* "cupy/core/core.pyx":450
 *                     "Changing the dtype of a 0d array is only supported if "
 *                     "the itemsize is unchanged")
 *             if not self._c_contiguous:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     "To change to a dtype of a different size, the array must "
 */
    __pyx_t_6 = ((!(__pyx_v_self->_c_contiguous != 0)) != 0);
    if (unlikely(__pyx_t_6)) {

      /* "cupy/core/core.pyx":451
 *                     "the itemsize is unchanged")
 *             if not self._c_contiguous:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     "To change to a dtype of a different size, the array must "
 *                     "be C-contiguous")
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 451, __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(0, 451, __pyx_L1_error)

      /* "cupy/core/core.pyx":450
 *                     "Changing the dtype of a 0d array is only supported if "
 *                     "the itemsize is unchanged")
 *             if not self._c_contiguous:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     "To change to a dtype of a different size, the array must "
 */
    }

    /* "cupy/core/core.pyx":454
 *                     "To change to a dtype of a different size, the array must "
 *                     "be C-contiguous")
 *             shape = list(self._shape)             # <<<<<<<<<<<<<<
 *             strides = list(self._strides)
 *             shape[-1] = shape[-1] * self.dtype.itemsize // v.dtype.itemsize
 */
    __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 454, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_List(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 454, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_shape = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":455
 *                     "be C-contiguous")
 *             shape = list(self._shape)
 *             strides = list(self._strides)             # <<<<<<<<<<<<<<
 *             shape[-1] = shape[-1] * self.dtype.itemsize // v.dtype.itemsize
 *             strides[-1] = strides[-1] * v.dtype.itemsize // self.dtype.itemsize
 */
    __pyx_t_3 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_strides); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 455, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 455, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_strides = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":456
 *             shape = list(self._shape)
 *             strides = list(self._strides)
 *             shape[-1] = shape[-1] * self.dtype.itemsize // v.dtype.itemsize             # <<<<<<<<<<<<<<
 *             strides[-1] = strides[-1] * v.dtype.itemsize // self.dtype.itemsize
 *             v._shape = shape
 */
    __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_shape, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyNumber_Multiply(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_v->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyNumber_FloorDivide(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(__Pyx_SetItemInt(__pyx_v_shape, -1L, __pyx_t_2, long, 1, __Pyx_PyInt_From_long, 1, 1, 1) < 0)) __PYX_ERR(0, 456, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":457
 *             strides = list(self._strides)
 *             shape[-1] = shape[-1] * self.dtype.itemsize // v.dtype.itemsize
 *             strides[-1] = strides[-1] * v.dtype.itemsize // self.dtype.itemsize             # <<<<<<<<<<<<<<
 *             v._shape = shape
 *             v._strides = strides
 */
    __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_strides, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_v->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyNumber_Multiply(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyNumber_FloorDivide(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(__Pyx_SetItemInt(__pyx_v_strides, -1L, __pyx_t_2, long, 1, __Pyx_PyInt_From_long, 1, 1, 1) < 0)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":458
 *             shape[-1] = shape[-1] * self.dtype.itemsize // v.dtype.itemsize
 *             strides[-1] = strides[-1] * v.dtype.itemsize // self.dtype.itemsize
 *             v._shape = shape             # <<<<<<<<<<<<<<
 *             v._strides = strides
 *             v.size = self.size * self.dtype.itemsize // v.dtype.itemsize
 */
    __pyx_t_8 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 458, __pyx_L1_error)
    __pyx_v_v->_shape = __pyx_t_8;

    /* "cupy/core/core.pyx":459
 *             strides[-1] = strides[-1] * v.dtype.itemsize // self.dtype.itemsize
 *             v._shape = shape
 *             v._strides = strides             # <<<<<<<<<<<<<<
 *             v.size = self.size * self.dtype.itemsize // v.dtype.itemsize
 * 
 */
    __pyx_t_8 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_strides); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 459, __pyx_L1_error)
    __pyx_v_v->_strides = __pyx_t_8;

    /* "cupy/core/core.pyx":460
 *             v._shape = shape
 *             v._strides = strides
 *             v.size = self.size * self.dtype.itemsize // v.dtype.itemsize             # <<<<<<<<<<<<<<
 * 
 *         v._c_contiguous = self._c_contiguous
 */
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 460, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 460, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyNumber_Multiply(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 460, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_v->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 460, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyNumber_FloorDivide(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 460, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 460, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_v->size = __pyx_t_7;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":462
 *             v.size = self.size * self.dtype.itemsize // v.dtype.itemsize
 * 
 *         v._c_contiguous = self._c_contiguous             # <<<<<<<<<<<<<<
 *         v._f_contiguous = self._f_contiguous
 *         v.data = self.data
 */
  __pyx_t_6 = __pyx_v_self->_c_contiguous;
  __pyx_v_v->_c_contiguous = __pyx_t_6;

  /* "cupy/core/core.pyx":463
 * 
 *         v._c_contiguous = self._c_contiguous
 *         v._f_contiguous = self._f_contiguous             # <<<<<<<<<<<<<<
 *         v.data = self.data
 *         v.base = self.base if self.base is not None else self
 */
  __pyx_t_6 = __pyx_v_self->_f_contiguous;
  __pyx_v_v->_f_contiguous = __pyx_t_6;

  /* "cupy/core/core.pyx":464
 *         v._c_contiguous = self._c_contiguous
 *         v._f_contiguous = self._f_contiguous
 *         v.data = self.data             # <<<<<<<<<<<<<<
 *         v.base = self.base if self.base is not None else self
 *         return v
 */
  __pyx_t_2 = ((PyObject *)__pyx_v_self->data);
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_v->data);
  __Pyx_DECREF(((PyObject *)__pyx_v_v->data));
  __pyx_v_v->data = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":465
 *         v._f_contiguous = self._f_contiguous
 *         v.data = self.data
 *         v.base = self.base if self.base is not None else self             # <<<<<<<<<<<<<<
 *         return v
 * 
 */
  __pyx_t_6 = (((PyObject *)__pyx_v_self->base) != Py_None);
  if ((__pyx_t_6 != 0)) {
    __Pyx_INCREF(((PyObject *)__pyx_v_self->base));
    __pyx_t_2 = ((PyObject *)__pyx_v_self->base);
  } else {
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_t_2 = ((PyObject *)__pyx_v_self);
  }
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_v->base);
  __Pyx_DECREF(((PyObject *)__pyx_v_v->base));
  __pyx_v_v->base = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":466
 *         v.data = self.data
 *         v.base = self.base if self.base is not None else self
 *         return v             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement getfield
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_v));
  __pyx_r = __pyx_v_v;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":421
 *             return newarray
 * 
 *     cpdef ndarray view(self, dtype=None):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array.
 * 
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.view", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_strides);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_15view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_14view[] = "ndarray.view(self, dtype=None) -> ndarray\nReturns a view of the array.\n\n        Args:\n            dtype: If this is different from the data type of the array, the\n                returned view reinterpret the memory sequence as an array of\n                this type.\n\n        Returns:\n            cupy.ndarray: A view of the array. A reference to the original\n            array is stored at the :attr:`~ndarray.base` attribute.\n\n        .. seealso:: :meth:`numpy.ndarray.view`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_15view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("view (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dtype,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "view") < 0)) __PYX_ERR(0, 421, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_dtype = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("view", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 421, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.view", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_14view(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_dtype);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_14view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view __pyx_t_2;
  __Pyx_RefNannySetupContext("view", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->view(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.view", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":471
 *     # TODO(okuta): Implement setflags
 * 
 *     cpdef fill(self, value):             # <<<<<<<<<<<<<<
 *         """Fills the array with a scalar value.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_17fill(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_fill(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value, int __pyx_skip_dispatch) {
  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;
  int __pyx_t_6;
  int __pyx_t_7;
  size_t __pyx_t_8;
  __Pyx_RefNannySetupContext("fill", 0);
  __Pyx_INCREF(__pyx_v_value);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_fill); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 471, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_17fill)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_value};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_value};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 471, __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 = NULL;
          __Pyx_INCREF(__pyx_v_value);
          __Pyx_GIVEREF(__pyx_v_value);
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_value);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":480
 * 
 *         """
 *         if isinstance(value, numpy.ndarray):             # <<<<<<<<<<<<<<
 *             if value.shape != ():
 *                 raise ValueError(
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = PyObject_IsInstance(__pyx_v_value, __pyx_t_2); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 480, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":481
 *         """
 *         if isinstance(value, numpy.ndarray):
 *             if value.shape != ():             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'non-scalar numpy.ndarray cannot be used for fill')
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 481, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_empty_tuple, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 481, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 481, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(__pyx_t_7)) {

      /* "cupy/core/core.pyx":482
 *         if isinstance(value, numpy.ndarray):
 *             if value.shape != ():
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'non-scalar numpy.ndarray cannot be used for fill')
 *             value = value.item()
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 482, __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(0, 482, __pyx_L1_error)

      /* "cupy/core/core.pyx":481
 *         """
 *         if isinstance(value, numpy.ndarray):
 *             if value.shape != ():             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'non-scalar numpy.ndarray cannot be used for fill')
 */
    }

    /* "cupy/core/core.pyx":484
 *                 raise ValueError(
 *                     'non-scalar numpy.ndarray cannot be used for fill')
 *             value = value.item()             # <<<<<<<<<<<<<<
 * 
 *         if value == 0 and self._c_contiguous:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 484, __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);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 484, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 484, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":480
 * 
 *         """
 *         if isinstance(value, numpy.ndarray):             # <<<<<<<<<<<<<<
 *             if value.shape != ():
 *                 raise ValueError(
 */
  }

  /* "cupy/core/core.pyx":486
 *             value = value.item()
 * 
 *         if value == 0 and self._c_contiguous:             # <<<<<<<<<<<<<<
 *             self.data.memset_async(0, self.nbytes)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_v_value, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 486, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_6) {
  } else {
    __pyx_t_7 = __pyx_t_6;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_6 = (__pyx_v_self->_c_contiguous != 0);
  __pyx_t_7 = __pyx_t_6;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":487
 * 
 *         if value == 0 and self._c_contiguous:
 *             self.data.memset_async(0, self.nbytes)             # <<<<<<<<<<<<<<
 *         else:
 *             elementwise_copy(value, self, dtype=self.dtype)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 487, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_8 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 487, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_self->data->__pyx_vtab)->memset_async(__pyx_v_self->data, 0, __pyx_t_8, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 487, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":486
 *             value = value.item()
 * 
 *         if value == 0 and self._c_contiguous:             # <<<<<<<<<<<<<<
 *             self.data.memset_async(0, self.nbytes)
 *         else:
 */
    goto __pyx_L5;
  }

  /* "cupy/core/core.pyx":489
 *             self.data.memset_async(0, self.nbytes)
 *         else:
 *             elementwise_copy(value, self, dtype=self.dtype)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 489, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 489, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_value);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
    __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 489, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_self->dtype) < 0) __PYX_ERR(0, 489, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 489, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_L5:;

  /* "cupy/core/core.pyx":471
 *     # TODO(okuta): Implement setflags
 * 
 *     cpdef fill(self, value):             # <<<<<<<<<<<<<<
 *         """Fills the array with a scalar value.
 * 
 */

  /* 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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.fill", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_17fill(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_16fill[] = "ndarray.fill(self, value)\nFills the array with a scalar value.\n\n        Args:\n            value: A scalar value to fill the array content.\n\n        .. seealso:: :meth:`numpy.ndarray.fill`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_17fill(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fill (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_16fill(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_16fill(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("fill", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray_fill(__pyx_v_self, __pyx_v_value, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.fill", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":494
 *     # Shape manipulation
 *     # -------------------------------------------------------------------------
 *     cpdef ndarray _reshape(self, vector.vector[Py_ssize_t] shape):             # <<<<<<<<<<<<<<
 *         cdef vector.vector[Py_ssize_t] strides
 *         cdef ndarray newarray
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_19_reshape(PyObject *__pyx_v_self, PyObject *__pyx_arg_shape); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray__reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_shape, int __pyx_skip_dispatch) {
  std::vector<Py_ssize_t>  __pyx_v_strides;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_newarray = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  std::vector<Py_ssize_t>  __pyx_t_7;
  int __pyx_t_8;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides __pyx_t_9;
  __Pyx_RefNannySetupContext("_reshape", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reshape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 494, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_19_reshape)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 494, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __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);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 494, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 494, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 494, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 494, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 494, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 494, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":497
 *         cdef vector.vector[Py_ssize_t] strides
 *         cdef ndarray newarray
 *         shape = internal.infer_unknown_dimension(shape, self.size)             # <<<<<<<<<<<<<<
 *         if internal.vector_equal(shape, self._shape):
 *             return self.view()
 */
  __pyx_t_7 = __pyx_f_4cupy_4core_8internal_infer_unknown_dimension(__pyx_v_shape, __pyx_v_self->size, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 497, __pyx_L1_error)
  __pyx_v_shape = __pyx_t_7;

  /* "cupy/core/core.pyx":498
 *         cdef ndarray newarray
 *         shape = internal.infer_unknown_dimension(shape, self.size)
 *         if internal.vector_equal(shape, self._shape):             # <<<<<<<<<<<<<<
 *             return self.view()
 * 
 */
  __pyx_t_8 = (__pyx_f_4cupy_4core_8internal_vector_equal(__pyx_v_shape, __pyx_v_self->_shape, 0) != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":499
 *         shape = internal.infer_unknown_dimension(shape, self.size)
 *         if internal.vector_equal(shape, self._shape):
 *             return self.view()             # <<<<<<<<<<<<<<
 * 
 *         strides = _get_strides_for_nocopy_reshape(self, shape)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 499, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":498
 *         cdef ndarray newarray
 *         shape = internal.infer_unknown_dimension(shape, self.size)
 *         if internal.vector_equal(shape, self._shape):             # <<<<<<<<<<<<<<
 *             return self.view()
 * 
 */
  }

  /* "cupy/core/core.pyx":501
 *             return self.view()
 * 
 *         strides = _get_strides_for_nocopy_reshape(self, shape)             # <<<<<<<<<<<<<<
 *         if strides.size() == shape.size():
 *             newarray = self.view()
 */
  __pyx_t_7 = __pyx_f_4cupy_4core_4core__get_strides_for_nocopy_reshape(__pyx_v_self, __pyx_v_shape, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 501, __pyx_L1_error)
  __pyx_v_strides = __pyx_t_7;

  /* "cupy/core/core.pyx":502
 * 
 *         strides = _get_strides_for_nocopy_reshape(self, shape)
 *         if strides.size() == shape.size():             # <<<<<<<<<<<<<<
 *             newarray = self.view()
 *         else:
 */
  __pyx_t_8 = ((__pyx_v_strides.size() == __pyx_v_shape.size()) != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":503
 *         strides = _get_strides_for_nocopy_reshape(self, shape)
 *         if strides.size() == shape.size():
 *             newarray = self.view()             # <<<<<<<<<<<<<<
 *         else:
 *             newarray = self.copy()
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":502
 * 
 *         strides = _get_strides_for_nocopy_reshape(self, shape)
 *         if strides.size() == shape.size():             # <<<<<<<<<<<<<<
 *             newarray = self.view()
 *         else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":505
 *             newarray = self.view()
 *         else:
 *             newarray = self.copy()             # <<<<<<<<<<<<<<
 *             strides = _get_strides_for_nocopy_reshape(newarray, shape)
 * 
 */
  /*else*/ {
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->copy(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 505, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":506
 *         else:
 *             newarray = self.copy()
 *             strides = _get_strides_for_nocopy_reshape(newarray, shape)             # <<<<<<<<<<<<<<
 * 
 *         if shape.size() != strides.size():
 */
    __pyx_t_7 = __pyx_f_4cupy_4core_4core__get_strides_for_nocopy_reshape(__pyx_v_newarray, __pyx_v_shape, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 506, __pyx_L1_error)
    __pyx_v_strides = __pyx_t_7;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":508
 *             strides = _get_strides_for_nocopy_reshape(newarray, shape)
 * 
 *         if shape.size() != strides.size():             # <<<<<<<<<<<<<<
 *             raise ValueError('total size of new array must be unchanged')
 *         newarray._set_shape_and_strides(shape, strides, False)
 */
  __pyx_t_8 = ((__pyx_v_shape.size() != __pyx_v_strides.size()) != 0);
  if (unlikely(__pyx_t_8)) {

    /* "cupy/core/core.pyx":509
 * 
 *         if shape.size() != strides.size():
 *             raise ValueError('total size of new array must be unchanged')             # <<<<<<<<<<<<<<
 *         newarray._set_shape_and_strides(shape, strides, False)
 *         return newarray
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 509, __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(0, 509, __pyx_L1_error)

    /* "cupy/core/core.pyx":508
 *             strides = _get_strides_for_nocopy_reshape(newarray, shape)
 * 
 *         if shape.size() != strides.size():             # <<<<<<<<<<<<<<
 *             raise ValueError('total size of new array must be unchanged')
 *         newarray._set_shape_and_strides(shape, strides, False)
 */
  }

  /* "cupy/core/core.pyx":510
 *         if shape.size() != strides.size():
 *             raise ValueError('total size of new array must be unchanged')
 *         newarray._set_shape_and_strides(shape, strides, False)             # <<<<<<<<<<<<<<
 *         return newarray
 * 
 */
  __pyx_t_9.__pyx_n = 1;
  __pyx_t_9.update_c_contiguity = 0;
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_newarray->__pyx_vtab)->_set_shape_and_strides(__pyx_v_newarray, __pyx_v_shape, __pyx_v_strides, 0, &__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":511
 *             raise ValueError('total size of new array must be unchanged')
 *         newarray._set_shape_and_strides(shape, strides, False)
 *         return newarray             # <<<<<<<<<<<<<<
 * 
 *     def reshape(self, *shape):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
  __pyx_r = __pyx_v_newarray;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":494
 *     # Shape manipulation
 *     # -------------------------------------------------------------------------
 *     cpdef ndarray _reshape(self, vector.vector[Py_ssize_t] shape):             # <<<<<<<<<<<<<<
 *         cdef vector.vector[Py_ssize_t] strides
 *         cdef ndarray newarray
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray._reshape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_newarray);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_19_reshape(PyObject *__pyx_v_self, PyObject *__pyx_arg_shape); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_18_reshape[] = "ndarray._reshape(self, vector[Py_ssize_t] shape) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_19_reshape(PyObject *__pyx_v_self, PyObject *__pyx_arg_shape) {
  std::vector<Py_ssize_t>  __pyx_v_shape;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_reshape (wrapper)", 0);
  assert(__pyx_arg_shape); {
    __pyx_v_shape = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_arg_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 494, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray._reshape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_18_reshape(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((std::vector<Py_ssize_t> )__pyx_v_shape));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_18_reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_shape) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_reshape", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_7ndarray__reshape(__pyx_v_self, __pyx_v_shape, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 494, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray._reshape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":513
 *         return newarray
 * 
 *     def reshape(self, *shape):             # <<<<<<<<<<<<<<
 *         """Returns an array of a different shape and the same content.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_21reshape(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_20reshape[] = "ndarray.reshape(self, *shape)\nReturns an array of a different shape and the same content.\n\n        .. seealso::\n           :func:`cupy.reshape` for full documentation,\n           :meth:`numpy.ndarray.reshape`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_21reshape(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reshape (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "reshape", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_shape = __pyx_args;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_20reshape(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_shape);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_20reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_shape) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  std::vector<Py_ssize_t>  __pyx_t_5;
  __Pyx_RefNannySetupContext("reshape", 0);
  __Pyx_INCREF(__pyx_v_shape);

  /* "cupy/core/core.pyx":522
 *         """
 *         # TODO(beam2d): Support ordering option
 *         if len(shape) == 1 and cpython.PySequence_Check(shape[0]):             # <<<<<<<<<<<<<<
 *             shape = shape[0]
 *         return self._reshape(shape)
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_shape); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 522, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_t_2 == 1) != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_shape, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 522, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = (PySequence_Check(__pyx_t_4) != 0);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":523
 *         # TODO(beam2d): Support ordering option
 *         if len(shape) == 1 and cpython.PySequence_Check(shape[0]):
 *             shape = shape[0]             # <<<<<<<<<<<<<<
 *         return self._reshape(shape)
 * 
 */
    __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_shape, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 523, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_shape, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":522
 *         """
 *         # TODO(beam2d): Support ordering option
 *         if len(shape) == 1 and cpython.PySequence_Check(shape[0]):             # <<<<<<<<<<<<<<
 *             shape = shape[0]
 *         return self._reshape(shape)
 */
  }

  /* "cupy/core/core.pyx":524
 *         if len(shape) == 1 and cpython.PySequence_Check(shape[0]):
 *             shape = shape[0]
 *         return self._reshape(shape)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement resize
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 524, __pyx_L1_error)
  __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_reshape(__pyx_v_self, __pyx_t_5, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":513
 *         return newarray
 * 
 *     def reshape(self, *shape):             # <<<<<<<<<<<<<<
 *         """Returns an array of a different shape and the same content.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.ndarray.reshape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":527
 * 
 *     # TODO(okuta): Implement resize
 *     cpdef ndarray _transpose(self, vector.vector[Py_ssize_t] axes):             # <<<<<<<<<<<<<<
 *         cdef ndarray ret
 *         cdef vector.vector[Py_ssize_t] a_axes, rev_axes
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_23_transpose(PyObject *__pyx_v_self, PyObject *__pyx_arg_axes); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray__transpose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_axes, int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = 0;
  std::vector<Py_ssize_t>  __pyx_v_a_axes;
  std::vector<Py_ssize_t>  __pyx_v_rev_axes;
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_axis;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_7genexpr__pyx_v_i;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  int __pyx_t_11;
  std::vector<Py_ssize_t> ::iterator __pyx_t_12;
  __Pyx_RefNannySetupContext("_transpose", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transpose); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 527, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_23_transpose)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_axes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __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);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 527, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 527, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 527, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 527, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 527, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 527, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":532
 *         cdef Py_ssize_t ndim, axis
 * 
 *         ndim = self._shape.size()             # <<<<<<<<<<<<<<
 *         ret = self.view()
 *         if axes.size() == 0:
 */
  __pyx_v_ndim = __pyx_v_self->_shape.size();

  /* "cupy/core/core.pyx":533
 * 
 *         ndim = self._shape.size()
 *         ret = self.view()             # <<<<<<<<<<<<<<
 *         if axes.size() == 0:
 *             ret._shape.assign(self._shape.rbegin(), self._shape.rend())
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":534
 *         ndim = self._shape.size()
 *         ret = self.view()
 *         if axes.size() == 0:             # <<<<<<<<<<<<<<
 *             ret._shape.assign(self._shape.rbegin(), self._shape.rend())
 *             ret._strides.assign(self._strides.rbegin(), self._strides.rend())
 */
  __pyx_t_7 = ((__pyx_v_axes.size() == 0) != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":535
 *         ret = self.view()
 *         if axes.size() == 0:
 *             ret._shape.assign(self._shape.rbegin(), self._shape.rend())             # <<<<<<<<<<<<<<
 *             ret._strides.assign(self._strides.rbegin(), self._strides.rend())
 *             ret._c_contiguous = self._f_contiguous
 */
    try {
      __pyx_v_ret->_shape.assign(__pyx_v_self->_shape.rbegin(), __pyx_v_self->_shape.rend());
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 535, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":536
 *         if axes.size() == 0:
 *             ret._shape.assign(self._shape.rbegin(), self._shape.rend())
 *             ret._strides.assign(self._strides.rbegin(), self._strides.rend())             # <<<<<<<<<<<<<<
 *             ret._c_contiguous = self._f_contiguous
 *             ret._f_contiguous = self._c_contiguous
 */
    try {
      __pyx_v_ret->_strides.assign(__pyx_v_self->_strides.rbegin(), __pyx_v_self->_strides.rend());
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 536, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":537
 *             ret._shape.assign(self._shape.rbegin(), self._shape.rend())
 *             ret._strides.assign(self._strides.rbegin(), self._strides.rend())
 *             ret._c_contiguous = self._f_contiguous             # <<<<<<<<<<<<<<
 *             ret._f_contiguous = self._c_contiguous
 *             return ret
 */
    __pyx_t_7 = __pyx_v_self->_f_contiguous;
    __pyx_v_ret->_c_contiguous = __pyx_t_7;

    /* "cupy/core/core.pyx":538
 *             ret._strides.assign(self._strides.rbegin(), self._strides.rend())
 *             ret._c_contiguous = self._f_contiguous
 *             ret._f_contiguous = self._c_contiguous             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
    __pyx_t_7 = __pyx_v_self->_c_contiguous;
    __pyx_v_ret->_f_contiguous = __pyx_t_7;

    /* "cupy/core/core.pyx":539
 *             ret._c_contiguous = self._f_contiguous
 *             ret._f_contiguous = self._c_contiguous
 *             return ret             # <<<<<<<<<<<<<<
 * 
 *         if <Py_ssize_t>axes.size() != ndim:
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_ret));
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":534
 *         ndim = self._shape.size()
 *         ret = self.view()
 *         if axes.size() == 0:             # <<<<<<<<<<<<<<
 *             ret._shape.assign(self._shape.rbegin(), self._shape.rend())
 *             ret._strides.assign(self._strides.rbegin(), self._strides.rend())
 */
  }

  /* "cupy/core/core.pyx":541
 *             return ret
 * 
 *         if <Py_ssize_t>axes.size() != ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid axes value: %s' % str(axes))
 * 
 */
  __pyx_t_7 = ((((Py_ssize_t)__pyx_v_axes.size()) != __pyx_v_ndim) != 0);
  if (unlikely(__pyx_t_7)) {

    /* "cupy/core/core.pyx":542
 * 
 *         if <Py_ssize_t>axes.size() != ndim:
 *             raise ValueError('Invalid axes value: %s' % str(axes))             # <<<<<<<<<<<<<<
 * 
 *         for i in range(ndim):
 */
    __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_axes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_axes_value_s, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 542, __pyx_L1_error)

    /* "cupy/core/core.pyx":541
 *             return ret
 * 
 *         if <Py_ssize_t>axes.size() != ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid axes value: %s' % str(axes))
 * 
 */
  }

  /* "cupy/core/core.pyx":544
 *             raise ValueError('Invalid axes value: %s' % str(axes))
 * 
 *         for i in range(ndim):             # <<<<<<<<<<<<<<
 *             a_axes.push_back(i)
 *             axis = axes[i]
 */
  __pyx_t_8 = __pyx_v_ndim;
  __pyx_t_9 = __pyx_t_8;
  for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
    __pyx_v_i = __pyx_t_10;

    /* "cupy/core/core.pyx":545
 * 
 *         for i in range(ndim):
 *             a_axes.push_back(i)             # <<<<<<<<<<<<<<
 *             axis = axes[i]
 *             if axis < -ndim or axis >= ndim:
 */
    try {
      __pyx_v_a_axes.push_back(__pyx_v_i);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 545, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":546
 *         for i in range(ndim):
 *             a_axes.push_back(i)
 *             axis = axes[i]             # <<<<<<<<<<<<<<
 *             if axis < -ndim or axis >= ndim:
 *                 raise IndexError('Axes overrun')
 */
    __pyx_v_axis = (__pyx_v_axes[__pyx_v_i]);

    /* "cupy/core/core.pyx":547
 *             a_axes.push_back(i)
 *             axis = axes[i]
 *             if axis < -ndim or axis >= ndim:             # <<<<<<<<<<<<<<
 *                 raise IndexError('Axes overrun')
 *             axes[i] = axis % ndim
 */
    __pyx_t_11 = ((__pyx_v_axis < (-__pyx_v_ndim)) != 0);
    if (!__pyx_t_11) {
    } else {
      __pyx_t_7 = __pyx_t_11;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_11 = ((__pyx_v_axis >= __pyx_v_ndim) != 0);
    __pyx_t_7 = __pyx_t_11;
    __pyx_L8_bool_binop_done:;
    if (unlikely(__pyx_t_7)) {

      /* "cupy/core/core.pyx":548
 *             axis = axes[i]
 *             if axis < -ndim or axis >= ndim:
 *                 raise IndexError('Axes overrun')             # <<<<<<<<<<<<<<
 *             axes[i] = axis % ndim
 * 
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 548, __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(0, 548, __pyx_L1_error)

      /* "cupy/core/core.pyx":547
 *             a_axes.push_back(i)
 *             axis = axes[i]
 *             if axis < -ndim or axis >= ndim:             # <<<<<<<<<<<<<<
 *                 raise IndexError('Axes overrun')
 *             axes[i] = axis % ndim
 */
    }

    /* "cupy/core/core.pyx":549
 *             if axis < -ndim or axis >= ndim:
 *                 raise IndexError('Axes overrun')
 *             axes[i] = axis % ndim             # <<<<<<<<<<<<<<
 * 
 *         if internal.vector_equal(a_axes, axes):
 */
    if (unlikely(__pyx_v_ndim == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(0, 549, __pyx_L1_error)
    }
    (__pyx_v_axes[__pyx_v_i]) = __Pyx_mod_Py_ssize_t(__pyx_v_axis, __pyx_v_ndim);
  }

  /* "cupy/core/core.pyx":551
 *             axes[i] = axis % ndim
 * 
 *         if internal.vector_equal(a_axes, axes):             # <<<<<<<<<<<<<<
 *             return ret
 *         rev_axes.assign(axes.rbegin(), axes.rend())
 */
  __pyx_t_7 = (__pyx_f_4cupy_4core_8internal_vector_equal(__pyx_v_a_axes, __pyx_v_axes, 0) != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":552
 * 
 *         if internal.vector_equal(a_axes, axes):
 *             return ret             # <<<<<<<<<<<<<<
 *         rev_axes.assign(axes.rbegin(), axes.rend())
 *         if internal.vector_equal(a_axes, rev_axes):
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_ret));
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":551
 *             axes[i] = axis % ndim
 * 
 *         if internal.vector_equal(a_axes, axes):             # <<<<<<<<<<<<<<
 *             return ret
 *         rev_axes.assign(axes.rbegin(), axes.rend())
 */
  }

  /* "cupy/core/core.pyx":553
 *         if internal.vector_equal(a_axes, axes):
 *             return ret
 *         rev_axes.assign(axes.rbegin(), axes.rend())             # <<<<<<<<<<<<<<
 *         if internal.vector_equal(a_axes, rev_axes):
 *             ret._shape.assign(self._shape.rbegin(), self._shape.rend())
 */
  try {
    __pyx_v_rev_axes.assign(__pyx_v_axes.rbegin(), __pyx_v_axes.rend());
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 553, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":554
 *             return ret
 *         rev_axes.assign(axes.rbegin(), axes.rend())
 *         if internal.vector_equal(a_axes, rev_axes):             # <<<<<<<<<<<<<<
 *             ret._shape.assign(self._shape.rbegin(), self._shape.rend())
 *             ret._strides.assign(self._strides.rbegin(), self._strides.rend())
 */
  __pyx_t_7 = (__pyx_f_4cupy_4core_8internal_vector_equal(__pyx_v_a_axes, __pyx_v_rev_axes, 0) != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":555
 *         rev_axes.assign(axes.rbegin(), axes.rend())
 *         if internal.vector_equal(a_axes, rev_axes):
 *             ret._shape.assign(self._shape.rbegin(), self._shape.rend())             # <<<<<<<<<<<<<<
 *             ret._strides.assign(self._strides.rbegin(), self._strides.rend())
 *             ret._c_contiguous = self._f_contiguous
 */
    try {
      __pyx_v_ret->_shape.assign(__pyx_v_self->_shape.rbegin(), __pyx_v_self->_shape.rend());
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 555, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":556
 *         if internal.vector_equal(a_axes, rev_axes):
 *             ret._shape.assign(self._shape.rbegin(), self._shape.rend())
 *             ret._strides.assign(self._strides.rbegin(), self._strides.rend())             # <<<<<<<<<<<<<<
 *             ret._c_contiguous = self._f_contiguous
 *             ret._f_contiguous = self._c_contiguous
 */
    try {
      __pyx_v_ret->_strides.assign(__pyx_v_self->_strides.rbegin(), __pyx_v_self->_strides.rend());
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 556, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":557
 *             ret._shape.assign(self._shape.rbegin(), self._shape.rend())
 *             ret._strides.assign(self._strides.rbegin(), self._strides.rend())
 *             ret._c_contiguous = self._f_contiguous             # <<<<<<<<<<<<<<
 *             ret._f_contiguous = self._c_contiguous
 *             return ret
 */
    __pyx_t_7 = __pyx_v_self->_f_contiguous;
    __pyx_v_ret->_c_contiguous = __pyx_t_7;

    /* "cupy/core/core.pyx":558
 *             ret._strides.assign(self._strides.rbegin(), self._strides.rend())
 *             ret._c_contiguous = self._f_contiguous
 *             ret._f_contiguous = self._c_contiguous             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
    __pyx_t_7 = __pyx_v_self->_c_contiguous;
    __pyx_v_ret->_f_contiguous = __pyx_t_7;

    /* "cupy/core/core.pyx":559
 *             ret._c_contiguous = self._f_contiguous
 *             ret._f_contiguous = self._c_contiguous
 *             return ret             # <<<<<<<<<<<<<<
 * 
 *         if ndim != len({i for i in axes}):
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_ret));
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":554
 *             return ret
 *         rev_axes.assign(axes.rbegin(), axes.rend())
 *         if internal.vector_equal(a_axes, rev_axes):             # <<<<<<<<<<<<<<
 *             ret._shape.assign(self._shape.rbegin(), self._shape.rend())
 *             ret._strides.assign(self._strides.rbegin(), self._strides.rend())
 */
  }

  /* "cupy/core/core.pyx":561
 *             return ret
 * 
 *         if ndim != len({i for i in axes}):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid axes value: %s' % str(axes))
 * 
 */
  { /* enter inner scope */
    __pyx_t_2 = PySet_New(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 561, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_12 = __pyx_v_axes.begin();
    for (;;) {
      if (!(__pyx_t_12 != __pyx_v_axes.end())) break;
      __pyx_t_8 = *__pyx_t_12;
      ++__pyx_t_12;
      __pyx_7genexpr__pyx_v_i = __pyx_t_8;
      __pyx_t_1 = PyInt_FromSsize_t(__pyx_7genexpr__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 561, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(PySet_Add(__pyx_t_2, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 561, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  } /* exit inner scope */
  __pyx_t_8 = PySet_GET_SIZE(__pyx_t_2); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 561, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_7 = ((__pyx_v_ndim != __pyx_t_8) != 0);
  if (unlikely(__pyx_t_7)) {

    /* "cupy/core/core.pyx":562
 * 
 *         if ndim != len({i for i in axes}):
 *             raise ValueError('Invalid axes value: %s' % str(axes))             # <<<<<<<<<<<<<<
 * 
 *         ret._shape.clear()
 */
    __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_axes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_axes_value_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 562, __pyx_L1_error)

    /* "cupy/core/core.pyx":561
 *             return ret
 * 
 *         if ndim != len({i for i in axes}):             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid axes value: %s' % str(axes))
 * 
 */
  }

  /* "cupy/core/core.pyx":564
 *             raise ValueError('Invalid axes value: %s' % str(axes))
 * 
 *         ret._shape.clear()             # <<<<<<<<<<<<<<
 *         ret._strides.clear()
 *         for axis in axes:
 */
  __pyx_v_ret->_shape.clear();

  /* "cupy/core/core.pyx":565
 * 
 *         ret._shape.clear()
 *         ret._strides.clear()             # <<<<<<<<<<<<<<
 *         for axis in axes:
 *             ret._shape.push_back(self._shape[axis])
 */
  __pyx_v_ret->_strides.clear();

  /* "cupy/core/core.pyx":566
 *         ret._shape.clear()
 *         ret._strides.clear()
 *         for axis in axes:             # <<<<<<<<<<<<<<
 *             ret._shape.push_back(self._shape[axis])
 *             ret._strides.push_back(self._strides[axis])
 */
  __pyx_t_12 = __pyx_v_axes.begin();
  for (;;) {
    if (!(__pyx_t_12 != __pyx_v_axes.end())) break;
    __pyx_t_8 = *__pyx_t_12;
    ++__pyx_t_12;
    __pyx_v_axis = __pyx_t_8;

    /* "cupy/core/core.pyx":567
 *         ret._strides.clear()
 *         for axis in axes:
 *             ret._shape.push_back(self._shape[axis])             # <<<<<<<<<<<<<<
 *             ret._strides.push_back(self._strides[axis])
 *         ret._update_contiguity()
 */
    try {
      __pyx_v_ret->_shape.push_back((__pyx_v_self->_shape[__pyx_v_axis]));
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 567, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":568
 *         for axis in axes:
 *             ret._shape.push_back(self._shape[axis])
 *             ret._strides.push_back(self._strides[axis])             # <<<<<<<<<<<<<<
 *         ret._update_contiguity()
 *         return ret
 */
    try {
      __pyx_v_ret->_strides.push_back((__pyx_v_self->_strides[__pyx_v_axis]));
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 568, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":566
 *         ret._shape.clear()
 *         ret._strides.clear()
 *         for axis in axes:             # <<<<<<<<<<<<<<
 *             ret._shape.push_back(self._shape[axis])
 *             ret._strides.push_back(self._strides[axis])
 */
  }

  /* "cupy/core/core.pyx":569
 *             ret._shape.push_back(self._shape[axis])
 *             ret._strides.push_back(self._strides[axis])
 *         ret._update_contiguity()             # <<<<<<<<<<<<<<
 *         return ret
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ret->__pyx_vtab)->_update_contiguity(__pyx_v_ret, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":570
 *             ret._strides.push_back(self._strides[axis])
 *         ret._update_contiguity()
 *         return ret             # <<<<<<<<<<<<<<
 * 
 *     def transpose(self, *axes):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":527
 * 
 *     # TODO(okuta): Implement resize
 *     cpdef ndarray _transpose(self, vector.vector[Py_ssize_t] axes):             # <<<<<<<<<<<<<<
 *         cdef ndarray ret
 *         cdef vector.vector[Py_ssize_t] a_axes, rev_axes
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray._transpose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_23_transpose(PyObject *__pyx_v_self, PyObject *__pyx_arg_axes); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_22_transpose[] = "ndarray._transpose(self, vector[Py_ssize_t] axes) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_23_transpose(PyObject *__pyx_v_self, PyObject *__pyx_arg_axes) {
  std::vector<Py_ssize_t>  __pyx_v_axes;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_transpose (wrapper)", 0);
  assert(__pyx_arg_axes); {
    __pyx_v_axes = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_arg_axes); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 527, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray._transpose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_22_transpose(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((std::vector<Py_ssize_t> )__pyx_v_axes));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_22_transpose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_axes) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_transpose", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_7ndarray__transpose(__pyx_v_self, __pyx_v_axes, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray._transpose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":572
 *         return ret
 * 
 *     def transpose(self, *axes):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array with axes permuted.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_25transpose(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_24transpose[] = "ndarray.transpose(self, *axes)\nReturns a view of the array with axes permuted.\n\n        .. seealso::\n           :func:`cupy.transpose` for full documentation,\n           :meth:`numpy.ndarray.reshape`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_25transpose(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axes = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transpose (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "transpose", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_axes = __pyx_args;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_24transpose(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axes);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_axes);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_24transpose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axes) {
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  std::vector<Py_ssize_t>  __pyx_t_5;
  __Pyx_RefNannySetupContext("transpose", 0);
  __Pyx_INCREF(__pyx_v_axes);

  /* "cupy/core/core.pyx":583
 *         cdef vector.vector[Py_ssize_t] vec_axes, a_axes, temp_axes
 *         cdef Py_ssize_t ndim, axis
 *         if len(axes) == 1:             # <<<<<<<<<<<<<<
 *             a = axes[0]
 *             if a is None:
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_axes); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 583, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 == 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":584
 *         cdef Py_ssize_t ndim, axis
 *         if len(axes) == 1:
 *             a = axes[0]             # <<<<<<<<<<<<<<
 *             if a is None:
 *                 axes = ()
 */
    __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_axes, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 584, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_a = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":585
 *         if len(axes) == 1:
 *             a = axes[0]
 *             if a is None:             # <<<<<<<<<<<<<<
 *                 axes = ()
 *             elif cpython.PySequence_Check(a):
 */
    __pyx_t_2 = (__pyx_v_a == Py_None);
    __pyx_t_4 = (__pyx_t_2 != 0);
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":586
 *             a = axes[0]
 *             if a is None:
 *                 axes = ()             # <<<<<<<<<<<<<<
 *             elif cpython.PySequence_Check(a):
 *                 axes = a
 */
      __Pyx_INCREF(__pyx_empty_tuple);
      __Pyx_DECREF_SET(__pyx_v_axes, __pyx_empty_tuple);

      /* "cupy/core/core.pyx":585
 *         if len(axes) == 1:
 *             a = axes[0]
 *             if a is None:             # <<<<<<<<<<<<<<
 *                 axes = ()
 *             elif cpython.PySequence_Check(a):
 */
      goto __pyx_L4;
    }

    /* "cupy/core/core.pyx":587
 *             if a is None:
 *                 axes = ()
 *             elif cpython.PySequence_Check(a):             # <<<<<<<<<<<<<<
 *                 axes = a
 *         return self._transpose(axes)
 */
    __pyx_t_4 = (PySequence_Check(__pyx_v_a) != 0);
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":588
 *                 axes = ()
 *             elif cpython.PySequence_Check(a):
 *                 axes = a             # <<<<<<<<<<<<<<
 *         return self._transpose(axes)
 * 
 */
      __Pyx_INCREF(__pyx_v_a);
      __Pyx_DECREF_SET(__pyx_v_axes, __pyx_v_a);

      /* "cupy/core/core.pyx":587
 *             if a is None:
 *                 axes = ()
 *             elif cpython.PySequence_Check(a):             # <<<<<<<<<<<<<<
 *                 axes = a
 *         return self._transpose(axes)
 */
    }
    __pyx_L4:;

    /* "cupy/core/core.pyx":583
 *         cdef vector.vector[Py_ssize_t] vec_axes, a_axes, temp_axes
 *         cdef Py_ssize_t ndim, axis
 *         if len(axes) == 1:             # <<<<<<<<<<<<<<
 *             a = axes[0]
 *             if a is None:
 */
  }

  /* "cupy/core/core.pyx":589
 *             elif cpython.PySequence_Check(a):
 *                 axes = a
 *         return self._transpose(axes)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray swapaxes(self, Py_ssize_t axis1, Py_ssize_t axis2):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_axes); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 589, __pyx_L1_error)
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_transpose(__pyx_v_self, __pyx_t_5, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":572
 *         return ret
 * 
 *     def transpose(self, *axes):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array with axes permuted.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.ndarray.transpose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_axes);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":591
 *         return self._transpose(axes)
 * 
 *     cpdef ndarray swapaxes(self, Py_ssize_t axis1, Py_ssize_t axis2):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array with two axes swapped.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_27swapaxes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_swapaxes(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, Py_ssize_t __pyx_v_axis1, Py_ssize_t __pyx_v_axis2, int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_ndim;
  std::vector<Py_ssize_t>  __pyx_v_axes;
  Py_ssize_t __pyx_v_i;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  __Pyx_RefNannySetupContext("swapaxes", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_swapaxes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 591, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_27swapaxes)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_axis1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 591, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_axis2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 591, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(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_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_4};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 591, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_4};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 591, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 591, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        if (__pyx_t_6) {
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
        __pyx_t_3 = 0;
        __pyx_t_4 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 591, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 591, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":599
 * 
 *         """
 *         cdef Py_ssize_t ndim = self.ndim             # <<<<<<<<<<<<<<
 *         cdef vector.vector[Py_ssize_t] axes
 *         if axis1 < -ndim or axis1 >= ndim or axis2 < -ndim or axis2 >= ndim:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 599, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 599, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_9;

  /* "cupy/core/core.pyx":601
 *         cdef Py_ssize_t ndim = self.ndim
 *         cdef vector.vector[Py_ssize_t] axes
 *         if axis1 < -ndim or axis1 >= ndim or axis2 < -ndim or axis2 >= ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError('Axis out of range')
 *         axis1 %= ndim
 */
  __pyx_t_11 = ((__pyx_v_axis1 < (-__pyx_v_ndim)) != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_10 = __pyx_t_11;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_11 = ((__pyx_v_axis1 >= __pyx_v_ndim) != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_10 = __pyx_t_11;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_11 = ((__pyx_v_axis2 < (-__pyx_v_ndim)) != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_10 = __pyx_t_11;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_11 = ((__pyx_v_axis2 >= __pyx_v_ndim) != 0);
  __pyx_t_10 = __pyx_t_11;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_10)) {

    /* "cupy/core/core.pyx":602
 *         cdef vector.vector[Py_ssize_t] axes
 *         if axis1 < -ndim or axis1 >= ndim or axis2 < -ndim or axis2 >= ndim:
 *             raise ValueError('Axis out of range')             # <<<<<<<<<<<<<<
 *         axis1 %= ndim
 *         axis2 %= ndim
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 602, __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(0, 602, __pyx_L1_error)

    /* "cupy/core/core.pyx":601
 *         cdef Py_ssize_t ndim = self.ndim
 *         cdef vector.vector[Py_ssize_t] axes
 *         if axis1 < -ndim or axis1 >= ndim or axis2 < -ndim or axis2 >= ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError('Axis out of range')
 *         axis1 %= ndim
 */
  }

  /* "cupy/core/core.pyx":603
 *         if axis1 < -ndim or axis1 >= ndim or axis2 < -ndim or axis2 >= ndim:
 *             raise ValueError('Axis out of range')
 *         axis1 %= ndim             # <<<<<<<<<<<<<<
 *         axis2 %= ndim
 *         for i in range(ndim):
 */
  if (unlikely(__pyx_v_ndim == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 603, __pyx_L1_error)
  }
  __pyx_v_axis1 = __Pyx_mod_Py_ssize_t(__pyx_v_axis1, __pyx_v_ndim);

  /* "cupy/core/core.pyx":604
 *             raise ValueError('Axis out of range')
 *         axis1 %= ndim
 *         axis2 %= ndim             # <<<<<<<<<<<<<<
 *         for i in range(ndim):
 *             axes.push_back(i)
 */
  if (unlikely(__pyx_v_ndim == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 604, __pyx_L1_error)
  }
  __pyx_v_axis2 = __Pyx_mod_Py_ssize_t(__pyx_v_axis2, __pyx_v_ndim);

  /* "cupy/core/core.pyx":605
 *         axis1 %= ndim
 *         axis2 %= ndim
 *         for i in range(ndim):             # <<<<<<<<<<<<<<
 *             axes.push_back(i)
 *         axes[axis1], axes[axis2] = axes[axis2], axes[axis1]
 */
  __pyx_t_9 = __pyx_v_ndim;
  __pyx_t_12 = __pyx_t_9;
  for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
    __pyx_v_i = __pyx_t_13;

    /* "cupy/core/core.pyx":606
 *         axis2 %= ndim
 *         for i in range(ndim):
 *             axes.push_back(i)             # <<<<<<<<<<<<<<
 *         axes[axis1], axes[axis2] = axes[axis2], axes[axis1]
 *         return self._transpose(axes)
 */
    try {
      __pyx_v_axes.push_back(__pyx_v_i);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 606, __pyx_L1_error)
    }
  }

  /* "cupy/core/core.pyx":607
 *         for i in range(ndim):
 *             axes.push_back(i)
 *         axes[axis1], axes[axis2] = axes[axis2], axes[axis1]             # <<<<<<<<<<<<<<
 *         return self._transpose(axes)
 * 
 */
  __pyx_t_9 = (__pyx_v_axes[__pyx_v_axis2]);
  __pyx_t_12 = (__pyx_v_axes[__pyx_v_axis1]);
  (__pyx_v_axes[__pyx_v_axis1]) = __pyx_t_9;
  (__pyx_v_axes[__pyx_v_axis2]) = __pyx_t_12;

  /* "cupy/core/core.pyx":608
 *             axes.push_back(i)
 *         axes[axis1], axes[axis2] = axes[axis2], axes[axis1]
 *         return self._transpose(axes)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray flatten(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_transpose(__pyx_v_self, __pyx_v_axes, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 608, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":591
 *         return self._transpose(axes)
 * 
 *     cpdef ndarray swapaxes(self, Py_ssize_t axis1, Py_ssize_t axis2):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array with two axes swapped.
 * 
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.core.core.ndarray.swapaxes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_27swapaxes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_26swapaxes[] = "ndarray.swapaxes(self, Py_ssize_t axis1, Py_ssize_t axis2) -> ndarray\nReturns a view of the array with two axes swapped.\n\n        .. seealso::\n           :func:`cupy.swapaxes` for full documentation,\n           :meth:`numpy.ndarray.swapaxes`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_27swapaxes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  Py_ssize_t __pyx_v_axis1;
  Py_ssize_t __pyx_v_axis2;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("swapaxes (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis1,&__pyx_n_s_axis2,0};
    PyObject* values[2] = {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  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_axis1)) != 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_axis2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("swapaxes", 1, 2, 2, 1); __PYX_ERR(0, 591, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "swapaxes") < 0)) __PYX_ERR(0, 591, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_axis1 = __Pyx_PyIndex_AsSsize_t(values[0]); if (unlikely((__pyx_v_axis1 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 591, __pyx_L3_error)
    __pyx_v_axis2 = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_axis2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 591, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("swapaxes", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 591, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.swapaxes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_26swapaxes(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis1, __pyx_v_axis2);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_26swapaxes(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, Py_ssize_t __pyx_v_axis1, Py_ssize_t __pyx_v_axis2) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("swapaxes", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_7ndarray_swapaxes(__pyx_v_self, __pyx_v_axis1, __pyx_v_axis2, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.swapaxes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":610
 *         return self._transpose(axes)
 * 
 *     cpdef ndarray flatten(self):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array flatten into one dimension.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_29flatten(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_flatten(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_newarray = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("flatten", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_flatten); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 610, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_29flatten)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 610, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 610, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 610, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":622
 *         """
 *         # TODO(beam2d): Support ordering option
 *         newarray = self.copy(order='C')             # <<<<<<<<<<<<<<
 *         newarray._shape.assign(<Py_ssize_t>1, self.size)
 *         newarray._strides.assign(<Py_ssize_t>1,
 */
  __pyx_t_5.__pyx_n = 1;
  __pyx_t_5.order = __pyx_n_s_C;
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->copy(__pyx_v_self, 0, &__pyx_t_5)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 622, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":623
 *         # TODO(beam2d): Support ordering option
 *         newarray = self.copy(order='C')
 *         newarray._shape.assign(<Py_ssize_t>1, self.size)             # <<<<<<<<<<<<<<
 *         newarray._strides.assign(<Py_ssize_t>1,
 *                                  <Py_ssize_t>self.itemsize)
 */
  try {
    __pyx_v_newarray->_shape.assign(((Py_ssize_t)1), __pyx_v_self->size);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 623, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":625
 *         newarray._shape.assign(<Py_ssize_t>1, self.size)
 *         newarray._strides.assign(<Py_ssize_t>1,
 *                                  <Py_ssize_t>self.itemsize)             # <<<<<<<<<<<<<<
 *         newarray._c_contiguous = True
 *         newarray._f_contiguous = True
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":624
 *         newarray = self.copy(order='C')
 *         newarray._shape.assign(<Py_ssize_t>1, self.size)
 *         newarray._strides.assign(<Py_ssize_t>1,             # <<<<<<<<<<<<<<
 *                                  <Py_ssize_t>self.itemsize)
 *         newarray._c_contiguous = True
 */
  try {
    __pyx_v_newarray->_strides.assign(((Py_ssize_t)1), ((Py_ssize_t)__pyx_t_6));
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 624, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":626
 *         newarray._strides.assign(<Py_ssize_t>1,
 *                                  <Py_ssize_t>self.itemsize)
 *         newarray._c_contiguous = True             # <<<<<<<<<<<<<<
 *         newarray._f_contiguous = True
 *         return newarray
 */
  __pyx_v_newarray->_c_contiguous = 1;

  /* "cupy/core/core.pyx":627
 *                                  <Py_ssize_t>self.itemsize)
 *         newarray._c_contiguous = True
 *         newarray._f_contiguous = True             # <<<<<<<<<<<<<<
 *         return newarray
 * 
 */
  __pyx_v_newarray->_f_contiguous = 1;

  /* "cupy/core/core.pyx":628
 *         newarray._c_contiguous = True
 *         newarray._f_contiguous = True
 *         return newarray             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray ravel(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
  __pyx_r = __pyx_v_newarray;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":610
 *         return self._transpose(axes)
 * 
 *     cpdef ndarray flatten(self):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array flatten into one dimension.
 * 
 */

  /* 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("cupy.core.core.ndarray.flatten", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_newarray);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_29flatten(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_28flatten[] = "ndarray.flatten(self) -> ndarray\nReturns a copy of the array flatten into one dimension.\n\n        It currently supports C-order only.\n\n        Returns:\n            cupy.ndarray: A copy of the array with one dimension.\n\n        .. seealso:: :meth:`numpy.ndarray.flatten`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_29flatten(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("flatten (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_28flatten(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_28flatten(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("flatten", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_7ndarray_flatten(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 610, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.flatten", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":630
 *         return newarray
 * 
 *     cpdef ndarray ravel(self):             # <<<<<<<<<<<<<<
 *         """Returns an array flattened into one dimension.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_31ravel(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_ravel(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  std::vector<Py_ssize_t>  __pyx_v_shape;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  __Pyx_RefNannySetupContext("ravel", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ravel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_31ravel)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 630, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 630, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 630, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":640
 *         # TODO(beam2d): Support ordering option
 *         cdef vector.vector[Py_ssize_t] shape
 *         shape.push_back(self.size)             # <<<<<<<<<<<<<<
 *         return self._reshape(shape)
 * 
 */
  try {
    __pyx_v_shape.push_back(__pyx_v_self->size);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 640, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":641
 *         cdef vector.vector[Py_ssize_t] shape
 *         shape.push_back(self.size)
 *         return self._reshape(shape)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray squeeze(self, axis=None):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_reshape(__pyx_v_self, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 641, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":630
 *         return newarray
 * 
 *     cpdef ndarray ravel(self):             # <<<<<<<<<<<<<<
 *         """Returns an array flattened into one dimension.
 * 
 */

  /* 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("cupy.core.core.ndarray.ravel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_31ravel(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_30ravel[] = "ndarray.ravel(self) -> ndarray\nReturns an array flattened into one dimension.\n\n        .. seealso::\n           :func:`cupy.ravel` for full documentation,\n           :meth:`numpy.ndarray.ravel`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_31ravel(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ravel (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_30ravel(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_30ravel(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("ravel", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_7ndarray_ravel(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.ravel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":643
 *         return self._reshape(shape)
 * 
 *     cpdef ndarray squeeze(self, axis=None):             # <<<<<<<<<<<<<<
 *         """Returns a view with size-one axes removed.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_33squeeze(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_squeeze(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_squeeze *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  std::vector<char>  __pyx_v_axis_flags;
  std::vector<Py_ssize_t>  __pyx_v_newshape;
  std::vector<Py_ssize_t>  __pyx_v_newstrides;
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_naxes;
  Py_ssize_t __pyx_v__axis;
  Py_ssize_t __pyx_v_idim;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_axis_orig;
  long __pyx_v_any_ones;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_v = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  std::vector<char>  __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides __pyx_t_14;
  __Pyx_RefNannySetupContext("squeeze", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_squeeze); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_33squeeze)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_axis); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 643, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_axis};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 643, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_axis};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 643, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 643, __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 = NULL;
          __Pyx_INCREF(__pyx_v_axis);
          __Pyx_GIVEREF(__pyx_v_axis);
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_axis);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 643, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 643, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":656
 *         cdef Py_ssize_t ndim, naxes, _axis
 * 
 *         ndim = self._shape.size()             # <<<<<<<<<<<<<<
 *         axis_flags = vector.vector[char](ndim, 0)
 * 
 */
  __pyx_v_ndim = __pyx_v_self->_shape.size();

  /* "cupy/core/core.pyx":657
 * 
 *         ndim = self._shape.size()
 *         axis_flags = vector.vector[char](ndim, 0)             # <<<<<<<<<<<<<<
 * 
 *         # Convert axis to boolean flag.
 */
  try {
    __pyx_t_6 = std::vector<char> (__pyx_v_ndim, 0);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 657, __pyx_L1_error)
  }
  __pyx_v_axis_flags = __pyx_t_6;

  /* "cupy/core/core.pyx":660
 * 
 *         # Convert axis to boolean flag.
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             for idim in range(ndim):
 *                 if self._shape[idim] == 1:
 */
  __pyx_t_7 = (__pyx_v_axis == Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":661
 *         # Convert axis to boolean flag.
 *         if axis is None:
 *             for idim in range(ndim):             # <<<<<<<<<<<<<<
 *                 if self._shape[idim] == 1:
 *                     axis_flags[idim] = 1
 */
    __pyx_t_9 = __pyx_v_ndim;
    __pyx_t_10 = __pyx_t_9;
    for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
      __pyx_v_idim = __pyx_t_11;

      /* "cupy/core/core.pyx":662
 *         if axis is None:
 *             for idim in range(ndim):
 *                 if self._shape[idim] == 1:             # <<<<<<<<<<<<<<
 *                     axis_flags[idim] = 1
 *         elif isinstance(axis, tuple):
 */
      __pyx_t_8 = (((__pyx_v_self->_shape[__pyx_v_idim]) == 1) != 0);
      if (__pyx_t_8) {

        /* "cupy/core/core.pyx":663
 *             for idim in range(ndim):
 *                 if self._shape[idim] == 1:
 *                     axis_flags[idim] = 1             # <<<<<<<<<<<<<<
 *         elif isinstance(axis, tuple):
 *             naxes = <Py_ssize_t>len(axis)
 */
        (__pyx_v_axis_flags[__pyx_v_idim]) = 1;

        /* "cupy/core/core.pyx":662
 *         if axis is None:
 *             for idim in range(ndim):
 *                 if self._shape[idim] == 1:             # <<<<<<<<<<<<<<
 *                     axis_flags[idim] = 1
 *         elif isinstance(axis, tuple):
 */
      }
    }

    /* "cupy/core/core.pyx":660
 * 
 *         # Convert axis to boolean flag.
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             for idim in range(ndim):
 *                 if self._shape[idim] == 1:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":664
 *                 if self._shape[idim] == 1:
 *                     axis_flags[idim] = 1
 *         elif isinstance(axis, tuple):             # <<<<<<<<<<<<<<
 *             naxes = <Py_ssize_t>len(axis)
 *             for i in range(naxes):
 */
  __pyx_t_8 = PyTuple_Check(__pyx_v_axis); 
  __pyx_t_7 = (__pyx_t_8 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":665
 *                     axis_flags[idim] = 1
 *         elif isinstance(axis, tuple):
 *             naxes = <Py_ssize_t>len(axis)             # <<<<<<<<<<<<<<
 *             for i in range(naxes):
 *                 _axis = <Py_ssize_t>axis[i]
 */
    __pyx_t_9 = PyObject_Length(__pyx_v_axis); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 665, __pyx_L1_error)
    __pyx_v_naxes = ((Py_ssize_t)__pyx_t_9);

    /* "cupy/core/core.pyx":666
 *         elif isinstance(axis, tuple):
 *             naxes = <Py_ssize_t>len(axis)
 *             for i in range(naxes):             # <<<<<<<<<<<<<<
 *                 _axis = <Py_ssize_t>axis[i]
 *                 axis_orig = _axis
 */
    __pyx_t_9 = __pyx_v_naxes;
    __pyx_t_10 = __pyx_t_9;
    for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
      __pyx_v_i = __pyx_t_11;

      /* "cupy/core/core.pyx":667
 *             naxes = <Py_ssize_t>len(axis)
 *             for i in range(naxes):
 *                 _axis = <Py_ssize_t>axis[i]             # <<<<<<<<<<<<<<
 *                 axis_orig = _axis
 *                 if _axis < 0:
 */
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_axis, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 667, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 667, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v__axis = ((Py_ssize_t)__pyx_t_12);

      /* "cupy/core/core.pyx":668
 *             for i in range(naxes):
 *                 _axis = <Py_ssize_t>axis[i]
 *                 axis_orig = _axis             # <<<<<<<<<<<<<<
 *                 if _axis < 0:
 *                     _axis += ndim
 */
      __pyx_v_axis_orig = __pyx_v__axis;

      /* "cupy/core/core.pyx":669
 *                 _axis = <Py_ssize_t>axis[i]
 *                 axis_orig = _axis
 *                 if _axis < 0:             # <<<<<<<<<<<<<<
 *                     _axis += ndim
 *                 if _axis < 0 or _axis >= ndim:
 */
      __pyx_t_7 = ((__pyx_v__axis < 0) != 0);
      if (__pyx_t_7) {

        /* "cupy/core/core.pyx":670
 *                 axis_orig = _axis
 *                 if _axis < 0:
 *                     _axis += ndim             # <<<<<<<<<<<<<<
 *                 if _axis < 0 or _axis >= ndim:
 *                     raise _AxisError(
 */
        __pyx_v__axis = (__pyx_v__axis + __pyx_v_ndim);

        /* "cupy/core/core.pyx":669
 *                 _axis = <Py_ssize_t>axis[i]
 *                 axis_orig = _axis
 *                 if _axis < 0:             # <<<<<<<<<<<<<<
 *                     _axis += ndim
 *                 if _axis < 0 or _axis >= ndim:
 */
      }

      /* "cupy/core/core.pyx":671
 *                 if _axis < 0:
 *                     _axis += ndim
 *                 if _axis < 0 or _axis >= ndim:             # <<<<<<<<<<<<<<
 *                     raise _AxisError(
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %
 */
      __pyx_t_8 = ((__pyx_v__axis < 0) != 0);
      if (!__pyx_t_8) {
      } else {
        __pyx_t_7 = __pyx_t_8;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_8 = ((__pyx_v__axis >= __pyx_v_ndim) != 0);
      __pyx_t_7 = __pyx_t_8;
      __pyx_L11_bool_binop_done:;
      if (unlikely(__pyx_t_7)) {

        /* "cupy/core/core.pyx":672
 *                     _axis += ndim
 *                 if _axis < 0 or _axis >= ndim:
 *                     raise _AxisError(             # <<<<<<<<<<<<<<
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %
 *                         (axis_orig, ndim, ndim))
 */
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 672, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);

        /* "cupy/core/core.pyx":674
 *                     raise _AxisError(
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %
 *                         (axis_orig, ndim, ndim))             # <<<<<<<<<<<<<<
 *                 if axis_flags[_axis] == 1:
 *                     raise ValueError("duplicate value in 'axis'")
 */
        __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_axis_orig); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 674, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 674, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 674, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 674, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_4);
        __pyx_t_3 = 0;
        __pyx_t_5 = 0;
        __pyx_t_4 = 0;

        /* "cupy/core/core.pyx":673
 *                 if _axis < 0 or _axis >= ndim:
 *                     raise _AxisError(
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %             # <<<<<<<<<<<<<<
 *                         (axis_orig, ndim, ndim))
 *                 if axis_flags[_axis] == 1:
 */
        __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_axis_entry_d_is_out_of_bounds_d, __pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 673, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_13 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_13)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        if (!__pyx_t_13) {
          __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_2)) {
            PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_4};
            __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
            PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_4};
            __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else
          #endif
          {
            __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 672, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_13); __pyx_t_13 = NULL;
            __Pyx_GIVEREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
            __pyx_t_4 = 0;
            __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(0, 672, __pyx_L1_error)

        /* "cupy/core/core.pyx":671
 *                 if _axis < 0:
 *                     _axis += ndim
 *                 if _axis < 0 or _axis >= ndim:             # <<<<<<<<<<<<<<
 *                     raise _AxisError(
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %
 */
      }

      /* "cupy/core/core.pyx":675
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %
 *                         (axis_orig, ndim, ndim))
 *                 if axis_flags[_axis] == 1:             # <<<<<<<<<<<<<<
 *                     raise ValueError("duplicate value in 'axis'")
 *                 axis_flags[_axis] = 1
 */
      __pyx_t_7 = (((__pyx_v_axis_flags[__pyx_v__axis]) == 1) != 0);
      if (unlikely(__pyx_t_7)) {

        /* "cupy/core/core.pyx":676
 *                         (axis_orig, ndim, ndim))
 *                 if axis_flags[_axis] == 1:
 *                     raise ValueError("duplicate value in 'axis'")             # <<<<<<<<<<<<<<
 *                 axis_flags[_axis] = 1
 *         else:
 */
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 676, __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(0, 676, __pyx_L1_error)

        /* "cupy/core/core.pyx":675
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %
 *                         (axis_orig, ndim, ndim))
 *                 if axis_flags[_axis] == 1:             # <<<<<<<<<<<<<<
 *                     raise ValueError("duplicate value in 'axis'")
 *                 axis_flags[_axis] = 1
 */
      }

      /* "cupy/core/core.pyx":677
 *                 if axis_flags[_axis] == 1:
 *                     raise ValueError("duplicate value in 'axis'")
 *                 axis_flags[_axis] = 1             # <<<<<<<<<<<<<<
 *         else:
 *             _axis = <Py_ssize_t>axis
 */
      (__pyx_v_axis_flags[__pyx_v__axis]) = 1;
    }

    /* "cupy/core/core.pyx":664
 *                 if self._shape[idim] == 1:
 *                     axis_flags[idim] = 1
 *         elif isinstance(axis, tuple):             # <<<<<<<<<<<<<<
 *             naxes = <Py_ssize_t>len(axis)
 *             for i in range(naxes):
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":679
 *                 axis_flags[_axis] = 1
 *         else:
 *             _axis = <Py_ssize_t>axis             # <<<<<<<<<<<<<<
 *             axis_orig = _axis
 *             if _axis < 0:
 */
  /*else*/ {
    __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_axis); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 679, __pyx_L1_error)
    __pyx_v__axis = ((Py_ssize_t)__pyx_t_9);

    /* "cupy/core/core.pyx":680
 *         else:
 *             _axis = <Py_ssize_t>axis
 *             axis_orig = _axis             # <<<<<<<<<<<<<<
 *             if _axis < 0:
 *                 _axis += ndim
 */
    __pyx_v_axis_orig = __pyx_v__axis;

    /* "cupy/core/core.pyx":681
 *             _axis = <Py_ssize_t>axis
 *             axis_orig = _axis
 *             if _axis < 0:             # <<<<<<<<<<<<<<
 *                 _axis += ndim
 *             if ndim == 0 and (_axis == 0 or _axis == -1):
 */
    __pyx_t_7 = ((__pyx_v__axis < 0) != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":682
 *             axis_orig = _axis
 *             if _axis < 0:
 *                 _axis += ndim             # <<<<<<<<<<<<<<
 *             if ndim == 0 and (_axis == 0 or _axis == -1):
 *                 # Special case letting axis={-1,0} slip through for scalars,
 */
      __pyx_v__axis = (__pyx_v__axis + __pyx_v_ndim);

      /* "cupy/core/core.pyx":681
 *             _axis = <Py_ssize_t>axis
 *             axis_orig = _axis
 *             if _axis < 0:             # <<<<<<<<<<<<<<
 *                 _axis += ndim
 *             if ndim == 0 and (_axis == 0 or _axis == -1):
 */
    }

    /* "cupy/core/core.pyx":683
 *             if _axis < 0:
 *                 _axis += ndim
 *             if ndim == 0 and (_axis == 0 or _axis == -1):             # <<<<<<<<<<<<<<
 *                 # Special case letting axis={-1,0} slip through for scalars,
 *                 # for backwards compatibility reasons.
 */
    __pyx_t_8 = ((__pyx_v_ndim == 0) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L16_bool_binop_done;
    }
    switch (__pyx_v__axis) {
      case 0:
      case -1L:
      __pyx_t_8 = 1;
      break;
      default:
      __pyx_t_8 = 0;
      break;
    }
    __pyx_t_7 = __pyx_t_8;
    __pyx_L16_bool_binop_done:;
    if (__pyx_t_7) {
      goto __pyx_L15;
    }

    /* "cupy/core/core.pyx":688
 *                 pass
 *             else:
 *                 if _axis < 0 or _axis >= ndim:             # <<<<<<<<<<<<<<
 *                     raise _AxisError(
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %
 */
    /*else*/ {
      __pyx_t_8 = ((__pyx_v__axis < 0) != 0);
      if (!__pyx_t_8) {
      } else {
        __pyx_t_7 = __pyx_t_8;
        goto __pyx_L19_bool_binop_done;
      }
      __pyx_t_8 = ((__pyx_v__axis >= __pyx_v_ndim) != 0);
      __pyx_t_7 = __pyx_t_8;
      __pyx_L19_bool_binop_done:;
      if (unlikely(__pyx_t_7)) {

        /* "cupy/core/core.pyx":689
 *             else:
 *                 if _axis < 0 or _axis >= ndim:
 *                     raise _AxisError(             # <<<<<<<<<<<<<<
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %
 *                         (axis_orig, ndim, ndim))
 */
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 689, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);

        /* "cupy/core/core.pyx":691
 *                     raise _AxisError(
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %
 *                         (axis_orig, ndim, ndim))             # <<<<<<<<<<<<<<
 *                 axis_flags[_axis] = 1
 * 
 */
        __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_axis_orig); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 691, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 691, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_13 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 691, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 691, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_13);
        __pyx_t_5 = 0;
        __pyx_t_4 = 0;
        __pyx_t_13 = 0;

        /* "cupy/core/core.pyx":690
 *                 if _axis < 0 or _axis >= ndim:
 *                     raise _AxisError(
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %             # <<<<<<<<<<<<<<
 *                         (axis_orig, ndim, ndim))
 *                 axis_flags[_axis] = 1
 */
        __pyx_t_13 = __Pyx_PyString_Format(__pyx_kp_s_axis_entry_d_is_out_of_bounds_d, __pyx_t_3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 690, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(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);
          }
        }
        if (!__pyx_t_3) {
          __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 689, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_2)) {
            PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_13};
            __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 689, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
            PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_13};
            __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 689, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          } else
          #endif
          {
            __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 689, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
            __Pyx_GIVEREF(__pyx_t_13);
            PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_13);
            __pyx_t_13 = 0;
            __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 689, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(0, 689, __pyx_L1_error)

        /* "cupy/core/core.pyx":688
 *                 pass
 *             else:
 *                 if _axis < 0 or _axis >= ndim:             # <<<<<<<<<<<<<<
 *                     raise _AxisError(
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %
 */
      }

      /* "cupy/core/core.pyx":692
 *                         "'axis' entry %d is out of bounds [-%d, %d)" %
 *                         (axis_orig, ndim, ndim))
 *                 axis_flags[_axis] = 1             # <<<<<<<<<<<<<<
 * 
 *         # Verify that the axes requested are all of size one
 */
      (__pyx_v_axis_flags[__pyx_v__axis]) = 1;
    }
    __pyx_L15:;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":695
 * 
 *         # Verify that the axes requested are all of size one
 *         any_ones = 0             # <<<<<<<<<<<<<<
 *         for idim in range(ndim):
 *             if axis_flags[idim] != 0:
 */
  __pyx_v_any_ones = 0;

  /* "cupy/core/core.pyx":696
 *         # Verify that the axes requested are all of size one
 *         any_ones = 0
 *         for idim in range(ndim):             # <<<<<<<<<<<<<<
 *             if axis_flags[idim] != 0:
 *                 if self._shape[idim] == 1:
 */
  __pyx_t_9 = __pyx_v_ndim;
  __pyx_t_10 = __pyx_t_9;
  for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
    __pyx_v_idim = __pyx_t_11;

    /* "cupy/core/core.pyx":697
 *         any_ones = 0
 *         for idim in range(ndim):
 *             if axis_flags[idim] != 0:             # <<<<<<<<<<<<<<
 *                 if self._shape[idim] == 1:
 *                     any_ones = 1
 */
    __pyx_t_7 = (((__pyx_v_axis_flags[__pyx_v_idim]) != 0) != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":698
 *         for idim in range(ndim):
 *             if axis_flags[idim] != 0:
 *                 if self._shape[idim] == 1:             # <<<<<<<<<<<<<<
 *                     any_ones = 1
 *                 else:
 */
      __pyx_t_7 = (((__pyx_v_self->_shape[__pyx_v_idim]) == 1) != 0);
      if (likely(__pyx_t_7)) {

        /* "cupy/core/core.pyx":699
 *             if axis_flags[idim] != 0:
 *                 if self._shape[idim] == 1:
 *                     any_ones = 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError('cannot select an axis to squeeze out '
 */
        __pyx_v_any_ones = 1;

        /* "cupy/core/core.pyx":698
 *         for idim in range(ndim):
 *             if axis_flags[idim] != 0:
 *                 if self._shape[idim] == 1:             # <<<<<<<<<<<<<<
 *                     any_ones = 1
 *                 else:
 */
        goto __pyx_L24;
      }

      /* "cupy/core/core.pyx":701
 *                     any_ones = 1
 *                 else:
 *                     raise ValueError('cannot select an axis to squeeze out '             # <<<<<<<<<<<<<<
 *                                      'which has size not equal to one')
 * 
 */
      /*else*/ {
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 701, __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(0, 701, __pyx_L1_error)
      }
      __pyx_L24:;

      /* "cupy/core/core.pyx":697
 *         any_ones = 0
 *         for idim in range(ndim):
 *             if axis_flags[idim] != 0:             # <<<<<<<<<<<<<<
 *                 if self._shape[idim] == 1:
 *                     any_ones = 1
 */
    }
  }

  /* "cupy/core/core.pyx":705
 * 
 *         # If there were no axes to squeeze out, return the same array
 *         if any_ones == 0:             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  __pyx_t_7 = ((__pyx_v_any_ones == 0) != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":706
 *         # If there were no axes to squeeze out, return the same array
 *         if any_ones == 0:
 *             return self             # <<<<<<<<<<<<<<
 * 
 *         for i in range(ndim):
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":705
 * 
 *         # If there were no axes to squeeze out, return the same array
 *         if any_ones == 0:             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  }

  /* "cupy/core/core.pyx":708
 *             return self
 * 
 *         for i in range(ndim):             # <<<<<<<<<<<<<<
 *             if axis_flags[i] == 0:
 *                 newshape.push_back(self._shape[i])
 */
  __pyx_t_9 = __pyx_v_ndim;
  __pyx_t_10 = __pyx_t_9;
  for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
    __pyx_v_i = __pyx_t_11;

    /* "cupy/core/core.pyx":709
 * 
 *         for i in range(ndim):
 *             if axis_flags[i] == 0:             # <<<<<<<<<<<<<<
 *                 newshape.push_back(self._shape[i])
 *                 newstrides.push_back(self._strides[i])
 */
    __pyx_t_7 = (((__pyx_v_axis_flags[__pyx_v_i]) == 0) != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":710
 *         for i in range(ndim):
 *             if axis_flags[i] == 0:
 *                 newshape.push_back(self._shape[i])             # <<<<<<<<<<<<<<
 *                 newstrides.push_back(self._strides[i])
 * 
 */
      try {
        __pyx_v_newshape.push_back((__pyx_v_self->_shape[__pyx_v_i]));
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 710, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":711
 *             if axis_flags[i] == 0:
 *                 newshape.push_back(self._shape[i])
 *                 newstrides.push_back(self._strides[i])             # <<<<<<<<<<<<<<
 * 
 *         v = self.view()
 */
      try {
        __pyx_v_newstrides.push_back((__pyx_v_self->_strides[__pyx_v_i]));
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 711, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":709
 * 
 *         for i in range(ndim):
 *             if axis_flags[i] == 0:             # <<<<<<<<<<<<<<
 *                 newshape.push_back(self._shape[i])
 *                 newstrides.push_back(self._strides[i])
 */
    }
  }

  /* "cupy/core/core.pyx":713
 *                 newstrides.push_back(self._strides[i])
 * 
 *         v = self.view()             # <<<<<<<<<<<<<<
 *         v._set_shape_and_strides(newshape, newstrides, False)
 *         return v
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":714
 * 
 *         v = self.view()
 *         v._set_shape_and_strides(newshape, newstrides, False)             # <<<<<<<<<<<<<<
 *         return v
 * 
 */
  __pyx_t_14.__pyx_n = 1;
  __pyx_t_14.update_c_contiguity = 0;
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_v->__pyx_vtab)->_set_shape_and_strides(__pyx_v_v, __pyx_v_newshape, __pyx_v_newstrides, 0, &__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 714, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":715
 *         v = self.view()
 *         v._set_shape_and_strides(newshape, newstrides, False)
 *         return v             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_v));
  __pyx_r = __pyx_v_v;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":643
 *         return self._reshape(shape)
 * 
 *     cpdef ndarray squeeze(self, axis=None):             # <<<<<<<<<<<<<<
 *         """Returns a view with size-one axes removed.
 * 
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("cupy.core.core.ndarray.squeeze", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_v);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_33squeeze(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_32squeeze[] = "ndarray.squeeze(self, axis=None) -> ndarray\nReturns a view with size-one axes removed.\n\n        .. seealso::\n           :func:`cupy.squeeze` for full documentation,\n           :meth:`numpy.ndarray.squeeze`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_33squeeze(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("squeeze (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "squeeze") < 0)) __PYX_ERR(0, 643, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_axis = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("squeeze", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 643, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.squeeze", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_32squeeze(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_32squeeze(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_squeeze __pyx_t_2;
  __Pyx_RefNannySetupContext("squeeze", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->squeeze(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.squeeze", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":720
 *     # Item selection and manipulation
 *     # -------------------------------------------------------------------------
 *     cpdef ndarray take(self, indices, axis=None, out=None):             # <<<<<<<<<<<<<<
 *         """Returns an array of elements at given indices along the axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_35take(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_take(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_indices, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_take *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__take __pyx_t_7;
  __Pyx_RefNannySetupContext("take", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_out = __pyx_optional_args->out;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_take); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 720, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_35take)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_indices, __pyx_v_axis, __pyx_v_out};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_indices, __pyx_v_axis, __pyx_v_out};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 720, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_indices);
        __Pyx_GIVEREF(__pyx_v_indices);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_indices);
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_axis);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_out);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 720, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":728
 * 
 *         """
 *         return _take(self, indices, li=axis, ri=axis, out=out)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement put
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  if (!(likely(((__pyx_v_out) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_out, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 728, __pyx_L1_error)
  __pyx_t_7.__pyx_n = 3;
  __pyx_t_7.li = __pyx_v_axis;
  __pyx_t_7.ri = __pyx_v_axis;
  __pyx_t_7.out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_out);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__take(__pyx_v_self, __pyx_v_indices, 0, &__pyx_t_7)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":720
 *     # Item selection and manipulation
 *     # -------------------------------------------------------------------------
 *     cpdef ndarray take(self, indices, axis=None, out=None):             # <<<<<<<<<<<<<<
 *         """Returns an array of elements at given indices along the axis.
 * 
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.take", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_35take(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_34take[] = "ndarray.take(self, indices, axis=None, out=None) -> ndarray\nReturns an array of elements at given indices along the axis.\n\n        .. seealso::\n           :func:`cupy.take` for full documentation,\n           :meth:`numpy.ndarray.take`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_35take(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_indices = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("take (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_indices,&__pyx_n_s_axis,&__pyx_n_s_out,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    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_indices)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "take") < 0)) __PYX_ERR(0, 720, __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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_indices = values[0];
    __pyx_v_axis = values[1];
    __pyx_v_out = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("take", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 720, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.take", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_34take(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_indices, __pyx_v_axis, __pyx_v_out);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_34take(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_indices, PyObject *__pyx_v_axis, PyObject *__pyx_v_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_take __pyx_t_2;
  __Pyx_RefNannySetupContext("take", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->take(__pyx_v_self, __pyx_v_indices, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.take", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":732
 *     # TODO(okuta): Implement put
 * 
 *     cpdef repeat(self, repeats, axis=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with repeated arrays along an axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_37repeat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_repeat(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_repeats, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__repeat __pyx_t_7;
  __Pyx_RefNannySetupContext("repeat", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_repeat); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 732, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_37repeat)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_repeats, __pyx_v_axis};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 732, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_repeats, __pyx_v_axis};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 732, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 732, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_repeats);
        __Pyx_GIVEREF(__pyx_v_repeats);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_repeats);
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_axis);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 732, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":740
 * 
 *         """
 *         return _repeat(self, repeats, axis)             # <<<<<<<<<<<<<<
 * 
 *     cpdef choose(self, choices, out=None, mode='raise'):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7.__pyx_n = 1;
  __pyx_t_7.axis = __pyx_v_axis;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__repeat(__pyx_v_self, __pyx_v_repeats, 0, &__pyx_t_7)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":732
 *     # TODO(okuta): Implement put
 * 
 *     cpdef repeat(self, repeats, axis=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with repeated arrays along an axis.
 * 
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.repeat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_37repeat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_36repeat[] = "ndarray.repeat(self, repeats, axis=None)\nReturns an array with repeated arrays along an axis.\n\n        .. seealso::\n            :func:`cupy.repeat` for full documentation,\n            :meth:`numpy.ndarray.repeat`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_37repeat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_repeats = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("repeat (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_repeats,&__pyx_n_s_axis,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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_repeats)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "repeat") < 0)) __PYX_ERR(0, 732, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_repeats = values[0];
    __pyx_v_axis = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("repeat", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 732, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.repeat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_36repeat(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_repeats, __pyx_v_axis);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_36repeat(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_repeats, PyObject *__pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat __pyx_t_2;
  __Pyx_RefNannySetupContext("repeat", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_1 = __pyx_vtabptr_4cupy_4core_4core_ndarray->repeat(__pyx_v_self, __pyx_v_repeats, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.repeat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":742
 *         return _repeat(self, repeats, axis)
 * 
 *     cpdef choose(self, choices, out=None, mode='raise'):             # <<<<<<<<<<<<<<
 *         a = self
 *         n = choices.shape[0]
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_39choose(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_choose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_choices, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_choose *__pyx_optional_args) {
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_mode = ((PyObject *)__pyx_n_s_raise);
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_n = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_ba = NULL;
  PyObject *__pyx_v_bcs = NULL;
  PyObject *__pyx_v_n_channel = 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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("choose", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_out = __pyx_optional_args->out;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_mode = __pyx_optional_args->mode;
      }
    }
  }
  __Pyx_INCREF(__pyx_v_choices);
  __Pyx_INCREF(__pyx_v_out);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_choose); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 742, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_39choose)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_choices, __pyx_v_out, __pyx_v_mode};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 742, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_choices, __pyx_v_out, __pyx_v_mode};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 742, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 742, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_choices);
        __Pyx_GIVEREF(__pyx_v_choices);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_choices);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_out);
        __Pyx_INCREF(__pyx_v_mode);
        __Pyx_GIVEREF(__pyx_v_mode);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_mode);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 742, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":743
 * 
 *     cpdef choose(self, choices, out=None, mode='raise'):
 *         a = self             # <<<<<<<<<<<<<<
 *         n = choices.shape[0]
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_v_a = ((PyObject *)__pyx_v_self);

  /* "cupy/core/core.pyx":744
 *     cpdef choose(self, choices, out=None, mode='raise'):
 *         a = self
 *         n = choices.shape[0]             # <<<<<<<<<<<<<<
 * 
 *         # broadcast `a` and `choices[i]` for all i
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_choices, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":747
 * 
 *         # broadcast `a` and `choices[i]` for all i
 *         if a.ndim < choices.ndim - 1:             # <<<<<<<<<<<<<<
 *             for i in range(choices.ndim - 1 - a.ndim):
 *                 a = a[None, ...]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_choices, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":748
 *         # broadcast `a` and `choices[i]` for all i
 *         if a.ndim < choices.ndim - 1:
 *             for i in range(choices.ndim - 1 - a.ndim):             # <<<<<<<<<<<<<<
 *                 a = a[None, ...]
 *         elif a.ndim > choices.ndim - 1:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_choices, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 748, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 748, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 748, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 748, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 748, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 748, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 748, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_8 >= 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_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 748, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 748, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_8 >= 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_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 748, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 748, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_9(__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, 748, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":749
 *         if a.ndim < choices.ndim - 1:
 *             for i in range(choices.ndim - 1 - a.ndim):
 *                 a = a[None, ...]             # <<<<<<<<<<<<<<
 *         elif a.ndim > choices.ndim - 1:
 *             for i in range(a.ndim + 1 - choices.ndim):
 */
      __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_a, __pyx_tuple__18); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 749, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_a, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":748
 *         # broadcast `a` and `choices[i]` for all i
 *         if a.ndim < choices.ndim - 1:
 *             for i in range(choices.ndim - 1 - a.ndim):             # <<<<<<<<<<<<<<
 *                 a = a[None, ...]
 *         elif a.ndim > choices.ndim - 1:
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":747
 * 
 *         # broadcast `a` and `choices[i]` for all i
 *         if a.ndim < choices.ndim - 1:             # <<<<<<<<<<<<<<
 *             for i in range(choices.ndim - 1 - a.ndim):
 *                 a = a[None, ...]
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":750
 *             for i in range(choices.ndim - 1 - a.ndim):
 *                 a = a[None, ...]
 *         elif a.ndim > choices.ndim - 1:             # <<<<<<<<<<<<<<
 *             for i in range(a.ndim + 1 - choices.ndim):
 *                 choices = choices[:, None, ...]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_choices, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":751
 *                 a = a[None, ...]
 *         elif a.ndim > choices.ndim - 1:
 *             for i in range(a.ndim + 1 - choices.ndim):             # <<<<<<<<<<<<<<
 *                 choices = choices[:, None, ...]
 *         ba, bcs = broadcast(a, choices).values
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_choices, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 751, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 751, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_8 >= 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_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 751, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_8 >= 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_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 751, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_9(__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, 751, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":752
 *         elif a.ndim > choices.ndim - 1:
 *             for i in range(a.ndim + 1 - choices.ndim):
 *                 choices = choices[:, None, ...]             # <<<<<<<<<<<<<<
 *         ba, bcs = broadcast(a, choices).values
 * 
 */
      __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_choices, __pyx_tuple__20); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_choices, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":751
 *                 a = a[None, ...]
 *         elif a.ndim > choices.ndim - 1:
 *             for i in range(a.ndim + 1 - choices.ndim):             # <<<<<<<<<<<<<<
 *                 choices = choices[:, None, ...]
 *         ba, bcs = broadcast(a, choices).values
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":750
 *             for i in range(choices.ndim - 1 - a.ndim):
 *                 a = a[None, ...]
 *         elif a.ndim > choices.ndim - 1:             # <<<<<<<<<<<<<<
 *             for i in range(a.ndim + 1 - choices.ndim):
 *                 choices = choices[:, None, ...]
 */
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":753
 *             for i in range(a.ndim + 1 - choices.ndim):
 *                 choices = choices[:, None, ...]
 *         ba, bcs = broadcast(a, choices).values             # <<<<<<<<<<<<<<
 * 
 *         if out is None:
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 753, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_a);
  __Pyx_GIVEREF(__pyx_v_a);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_a);
  __Pyx_INCREF(__pyx_v_choices);
  __Pyx_GIVEREF(__pyx_v_choices);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_choices);
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 753, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = ((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_t_1)->values;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  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(0, 753, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 753, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 753, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 753, __pyx_L1_error)
  }
  __pyx_v_ba = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_bcs = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":755
 *         ba, bcs = broadcast(a, choices).values
 * 
 *         if out is None:             # <<<<<<<<<<<<<<
 *             out = ndarray(ba.shape[1:], choices.dtype)
 * 
 */
  __pyx_t_7 = (__pyx_v_out == Py_None);
  __pyx_t_10 = (__pyx_t_7 != 0);
  if (__pyx_t_10) {

    /* "cupy/core/core.pyx":756
 * 
 *         if out is None:
 *             out = ndarray(ba.shape[1:], choices.dtype)             # <<<<<<<<<<<<<<
 * 
 *         n_channel = numpy.prod(bcs[0].shape)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ba, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 756, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_t_2, 1, 0, NULL, NULL, &__pyx_slice__21, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 756, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_choices, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 756, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 756, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_3 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 756, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_out, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":755
 *         ba, bcs = broadcast(a, choices).values
 * 
 *         if out is None:             # <<<<<<<<<<<<<<
 *             out = ndarray(ba.shape[1:], choices.dtype)
 * 
 */
  }

  /* "cupy/core/core.pyx":758
 *             out = ndarray(ba.shape[1:], choices.dtype)
 * 
 *         n_channel = numpy.prod(bcs[0].shape)             # <<<<<<<<<<<<<<
 *         if mode == 'raise':
 *             if not ((a < n).all() and (0 <= a).all()):
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_prod); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_bcs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 758, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_6};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 758, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_6};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 758, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 758, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 758, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_n_channel = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":759
 * 
 *         n_channel = numpy.prod(bcs[0].shape)
 *         if mode == 'raise':             # <<<<<<<<<<<<<<
 *             if not ((a < n).all() and (0 <= a).all()):
 *                 raise ValueError('invalid entry in choice array')
 */
  __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_raise, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 759, __pyx_L1_error)
  if (__pyx_t_10) {

    /* "cupy/core/core.pyx":760
 *         n_channel = numpy.prod(bcs[0].shape)
 *         if mode == 'raise':
 *             if not ((a < n).all() and (0 <= a).all()):             # <<<<<<<<<<<<<<
 *                 raise ValueError('invalid entry in choice array')
 *             _choose_kernel(ba[0], bcs, n_channel, out)
 */
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_a, __pyx_v_n, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 760, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_all); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 760, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 760, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 760, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 760, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_7) {
    } else {
      __pyx_t_10 = __pyx_t_7;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_4 = PyObject_RichCompare(__pyx_int_0, __pyx_v_a, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 760, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_all); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 760, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 760, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 760, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 760, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_10 = __pyx_t_7;
    __pyx_L11_bool_binop_done:;
    __pyx_t_7 = ((!__pyx_t_10) != 0);
    if (unlikely(__pyx_t_7)) {

      /* "cupy/core/core.pyx":761
 *         if mode == 'raise':
 *             if not ((a < n).all() and (0 <= a).all()):
 *                 raise ValueError('invalid entry in choice array')             # <<<<<<<<<<<<<<
 *             _choose_kernel(ba[0], bcs, n_channel, out)
 *         elif mode == 'wrap':
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 761, __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(0, 761, __pyx_L1_error)

      /* "cupy/core/core.pyx":760
 *         n_channel = numpy.prod(bcs[0].shape)
 *         if mode == 'raise':
 *             if not ((a < n).all() and (0 <= a).all()):             # <<<<<<<<<<<<<<
 *                 raise ValueError('invalid entry in choice array')
 *             _choose_kernel(ba[0], bcs, n_channel, out)
 */
    }

    /* "cupy/core/core.pyx":762
 *             if not ((a < n).all() and (0 <= a).all()):
 *                 raise ValueError('invalid entry in choice array')
 *             _choose_kernel(ba[0], bcs, n_channel, out)             # <<<<<<<<<<<<<<
 *         elif mode == 'wrap':
 *             ba = ba[0] % n
 */
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_ba, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 762, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__choose_kernel);
    __pyx_t_4 = __pyx_v_4cupy_4core_4core__choose_kernel; __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_3, __pyx_v_bcs, __pyx_v_n_channel, __pyx_v_out};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 762, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_3, __pyx_v_bcs, __pyx_v_n_channel, __pyx_v_out};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 762, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 762, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_5, __pyx_t_3);
      __Pyx_INCREF(__pyx_v_bcs);
      __Pyx_GIVEREF(__pyx_v_bcs);
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_5, __pyx_v_bcs);
      __Pyx_INCREF(__pyx_v_n_channel);
      __Pyx_GIVEREF(__pyx_v_n_channel);
      PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_5, __pyx_v_n_channel);
      __Pyx_INCREF(__pyx_v_out);
      __Pyx_GIVEREF(__pyx_v_out);
      PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_5, __pyx_v_out);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 762, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":759
 * 
 *         n_channel = numpy.prod(bcs[0].shape)
 *         if mode == 'raise':             # <<<<<<<<<<<<<<
 *             if not ((a < n).all() and (0 <= a).all()):
 *                 raise ValueError('invalid entry in choice array')
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":763
 *                 raise ValueError('invalid entry in choice array')
 *             _choose_kernel(ba[0], bcs, n_channel, out)
 *         elif mode == 'wrap':             # <<<<<<<<<<<<<<
 *             ba = ba[0] % n
 *             _choose_kernel(ba, bcs, n_channel, out)
 */
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_wrap, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 763, __pyx_L1_error)
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":764
 *             _choose_kernel(ba[0], bcs, n_channel, out)
 *         elif mode == 'wrap':
 *             ba = ba[0] % n             # <<<<<<<<<<<<<<
 *             _choose_kernel(ba, bcs, n_channel, out)
 *         elif mode == 'clip':
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_ba, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyNumber_Remainder(__pyx_t_2, __pyx_v_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_ba, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":765
 *         elif mode == 'wrap':
 *             ba = ba[0] % n
 *             _choose_kernel(ba, bcs, n_channel, out)             # <<<<<<<<<<<<<<
 *         elif mode == 'clip':
 *             _choose_clip_kernel(ba[0], bcs, n_channel, n, out)
 */
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__choose_kernel);
    __pyx_t_2 = __pyx_v_4cupy_4core_4core__choose_kernel; __pyx_t_1 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[5] = {__pyx_t_1, __pyx_v_ba, __pyx_v_bcs, __pyx_v_n_channel, __pyx_v_out};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 765, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[5] = {__pyx_t_1, __pyx_v_ba, __pyx_v_bcs, __pyx_v_n_channel, __pyx_v_out};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 765, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 765, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(__pyx_v_ba);
      __Pyx_GIVEREF(__pyx_v_ba);
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_5, __pyx_v_ba);
      __Pyx_INCREF(__pyx_v_bcs);
      __Pyx_GIVEREF(__pyx_v_bcs);
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_5, __pyx_v_bcs);
      __Pyx_INCREF(__pyx_v_n_channel);
      __Pyx_GIVEREF(__pyx_v_n_channel);
      PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_5, __pyx_v_n_channel);
      __Pyx_INCREF(__pyx_v_out);
      __Pyx_GIVEREF(__pyx_v_out);
      PyTuple_SET_ITEM(__pyx_t_3, 3+__pyx_t_5, __pyx_v_out);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 765, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":763
 *                 raise ValueError('invalid entry in choice array')
 *             _choose_kernel(ba[0], bcs, n_channel, out)
 *         elif mode == 'wrap':             # <<<<<<<<<<<<<<
 *             ba = ba[0] % n
 *             _choose_kernel(ba, bcs, n_channel, out)
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":766
 *             ba = ba[0] % n
 *             _choose_kernel(ba, bcs, n_channel, out)
 *         elif mode == 'clip':             # <<<<<<<<<<<<<<
 *             _choose_clip_kernel(ba[0], bcs, n_channel, n, out)
 *         else:
 */
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_clip, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 766, __pyx_L1_error)
  if (likely(__pyx_t_7)) {

    /* "cupy/core/core.pyx":767
 *             _choose_kernel(ba, bcs, n_channel, out)
 *         elif mode == 'clip':
 *             _choose_clip_kernel(ba[0], bcs, n_channel, n, out)             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError('clipmode not understood')
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_ba, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__choose_clip_kernel);
    __pyx_t_3 = __pyx_v_4cupy_4core_4core__choose_clip_kernel; __pyx_t_1 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_t_2, __pyx_v_bcs, __pyx_v_n_channel, __pyx_v_n, __pyx_v_out};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 767, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_t_2, __pyx_v_bcs, __pyx_v_n_channel, __pyx_v_n, __pyx_v_out};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 767, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 767, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_2);
      __Pyx_INCREF(__pyx_v_bcs);
      __Pyx_GIVEREF(__pyx_v_bcs);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_bcs);
      __Pyx_INCREF(__pyx_v_n_channel);
      __Pyx_GIVEREF(__pyx_v_n_channel);
      PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_n_channel);
      __Pyx_INCREF(__pyx_v_n);
      __Pyx_GIVEREF(__pyx_v_n);
      PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_n);
      __Pyx_INCREF(__pyx_v_out);
      __Pyx_GIVEREF(__pyx_v_out);
      PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_v_out);
      __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 767, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":766
 *             ba = ba[0] % n
 *             _choose_kernel(ba, bcs, n_channel, out)
 *         elif mode == 'clip':             # <<<<<<<<<<<<<<
 *             _choose_clip_kernel(ba[0], bcs, n_channel, n, out)
 *         else:
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":769
 *             _choose_clip_kernel(ba[0], bcs, n_channel, n, out)
 *         else:
 *             raise TypeError('clipmode not understood')             # <<<<<<<<<<<<<<
 * 
 *         return out
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 769, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 769, __pyx_L1_error)
  }
  __pyx_L9:;

  /* "cupy/core/core.pyx":771
 *             raise TypeError('clipmode not understood')
 * 
 *         return out             # <<<<<<<<<<<<<<
 * 
 *     def sort(self, axis=-1):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_out);
  __pyx_r = __pyx_v_out;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":742
 *         return _repeat(self, repeats, axis)
 * 
 *     cpdef choose(self, choices, out=None, mode='raise'):             # <<<<<<<<<<<<<<
 *         a = self
 *         n = choices.shape[0]
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.choose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_n);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_ba);
  __Pyx_XDECREF(__pyx_v_bcs);
  __Pyx_XDECREF(__pyx_v_n_channel);
  __Pyx_XDECREF(__pyx_v_choices);
  __Pyx_XDECREF(__pyx_v_out);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_39choose(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_38choose[] = "ndarray.choose(self, choices, out=None, mode='raise')";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_39choose(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_choices = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_mode = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("choose (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_choices,&__pyx_n_s_out,&__pyx_n_s_mode,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_n_s_raise);
    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_choices)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "choose") < 0)) __PYX_ERR(0, 742, __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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_choices = values[0];
    __pyx_v_out = values[1];
    __pyx_v_mode = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("choose", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 742, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.choose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_38choose(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_choices, __pyx_v_out, __pyx_v_mode);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_38choose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_choices, PyObject *__pyx_v_out, PyObject *__pyx_v_mode) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_choose __pyx_t_2;
  __Pyx_RefNannySetupContext("choose", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.mode = __pyx_v_mode;
  __pyx_t_1 = __pyx_vtabptr_4cupy_4core_4core_ndarray->choose(__pyx_v_self, __pyx_v_choices, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.choose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":773
 *         return out
 * 
 *     def sort(self, axis=-1):             # <<<<<<<<<<<<<<
 *         """Sort an array, in-place with a stable sorting algorithm.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_41sort(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_40sort[] = "ndarray.sort(self, axis=-1)\nSort an array, in-place with a stable sorting algorithm.\n\n        Args:\n            axis (int): Axis along which to sort. Default is -1, which means\n                sort along the last axis.\n\n        .. note::\n           For its implementation reason, ``ndarray.sort`` currently supports\n           only arrays with their own data, and does not support ``kind`` and\n           ``order`` parameters that ``numpy.ndarray.sort`` does support.\n\n        .. seealso::\n            :func:`cupy.sort` for full documentation,\n            :meth:`numpy.ndarray.sort`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_41sort(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sort (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_neg_1);
    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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sort") < 0)) __PYX_ERR(0, 773, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_axis = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sort", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 773, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.sort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_40sort(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_40sort(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis) {
  Py_ssize_t __pyx_v_ndim;
  PyObject *__pyx_v_data = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_keys_array = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("sort", 0);
  __Pyx_INCREF(__pyx_v_axis);

  /* "cupy/core/core.pyx":793
 *         # TODO(takagi): Support kind argument.
 * 
 *         cdef Py_ssize_t ndim = self.ndim             # <<<<<<<<<<<<<<
 * 
 *         if not cupy.cuda.thrust_enabled:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 793, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_2;

  /* "cupy/core/core.pyx":795
 *         cdef Py_ssize_t ndim = self.ndim
 * 
 *         if not cupy.cuda.thrust_enabled:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('Thrust is needed to use cupy.sort. Please '
 *                                'install CUDA Toolkit with Thrust then '
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 795, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_cuda); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 795, __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_thrust_enabled); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 795, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 795, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((!__pyx_t_4) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "cupy/core/core.pyx":796
 * 
 *         if not cupy.cuda.thrust_enabled:
 *             raise RuntimeError('Thrust is needed to use cupy.sort. Please '             # <<<<<<<<<<<<<<
 *                                'install CUDA Toolkit with Thrust then '
 *                                'reinstall CuPy after uninstalling it.')
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 796, __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(0, 796, __pyx_L1_error)

    /* "cupy/core/core.pyx":795
 *         cdef Py_ssize_t ndim = self.ndim
 * 
 *         if not cupy.cuda.thrust_enabled:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('Thrust is needed to use cupy.sort. Please '
 *                                'install CUDA Toolkit with Thrust then '
 */
  }

  /* "cupy/core/core.pyx":800
 *                                'reinstall CuPy after uninstalling it.')
 * 
 *         if ndim == 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Sorting arrays with the rank of zero is not '
 *                              'supported')  # as numpy.sort() raises
 */
  __pyx_t_5 = ((__pyx_v_ndim == 0) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "cupy/core/core.pyx":801
 * 
 *         if ndim == 0:
 *             raise ValueError('Sorting arrays with the rank of zero is not '             # <<<<<<<<<<<<<<
 *                              'supported')  # as numpy.sort() raises
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 801, __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(0, 801, __pyx_L1_error)

    /* "cupy/core/core.pyx":800
 *                                'reinstall CuPy after uninstalling it.')
 * 
 *         if ndim == 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Sorting arrays with the rank of zero is not '
 *                              'supported')  # as numpy.sort() raises
 */
  }

  /* "cupy/core/core.pyx":805
 * 
 *         # TODO(takagi): Support sorting views
 *         if not self._c_contiguous:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('Sorting non-contiguous array is not '
 *                                       'supported.')
 */
  __pyx_t_5 = ((!(__pyx_v_self->_c_contiguous != 0)) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "cupy/core/core.pyx":806
 *         # TODO(takagi): Support sorting views
 *         if not self._c_contiguous:
 *             raise NotImplementedError('Sorting non-contiguous array is not '             # <<<<<<<<<<<<<<
 *                                       'supported.')
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 806, __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(0, 806, __pyx_L1_error)

    /* "cupy/core/core.pyx":805
 * 
 *         # TODO(takagi): Support sorting views
 *         if not self._c_contiguous:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('Sorting non-contiguous array is not '
 *                                       'supported.')
 */
  }

  /* "cupy/core/core.pyx":809
 *                                       'supported.')
 * 
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 809, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 809, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":810
 * 
 *         if axis < 0:
 *             axis += ndim             # <<<<<<<<<<<<<<
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 810, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_axis, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 810, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":809
 *                                       'supported.')
 * 
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  }

  /* "cupy/core/core.pyx":811
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_int_0, __pyx_v_axis, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 811, __pyx_L1_error)
  if (__Pyx_PyObject_IsTrue(__pyx_t_3)) {
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 811, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 811, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = ((!__pyx_t_5) != 0);
  if (unlikely(__pyx_t_4)) {

    /* "cupy/core/core.pyx":812
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 812, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 812, __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(0, 812, __pyx_L1_error)

    /* "cupy/core/core.pyx":811
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  }

  /* "cupy/core/core.pyx":814
 *             raise _AxisError('Axis out of range')
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             data = self
 *         else:
 */
  __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_ndim - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 814, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 814, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 814, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":815
 * 
 *         if axis == ndim - 1:
 *             data = self             # <<<<<<<<<<<<<<
 *         else:
 *             data = cupy.rollaxis(self, axis, ndim).copy()
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_v_data = ((PyObject *)__pyx_v_self);

    /* "cupy/core/core.pyx":814
 *             raise _AxisError('Axis out of range')
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             data = self
 *         else:
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":817
 *             data = self
 *         else:
 *             data = cupy.rollaxis(self, axis, ndim).copy()             # <<<<<<<<<<<<<<
 * 
 *         if ndim == 1:
 */
  /*else*/ {
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 817, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_rollaxis); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 817, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 817, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(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_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[4] = {__pyx_t_8, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_t_6};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 817, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_7)) {
      PyObject *__pyx_temp[4] = {__pyx_t_8, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_t_6};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 817, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 817, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_axis);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 817, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_copy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 817, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (__pyx_t_1) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 817, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 817, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_data = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":819
 *             data = cupy.rollaxis(self, axis, ndim).copy()
 * 
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             thrust.sort(self.dtype, data.data.ptr, 0, self._shape)
 *         else:
 */
  __pyx_t_4 = ((__pyx_v_ndim == 1) != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":820
 * 
 *         if ndim == 1:
 *             thrust.sort(self.dtype, data.data.ptr, 0, self._shape)             # <<<<<<<<<<<<<<
 *         else:
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_thrust); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 820, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_sort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 820, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_data); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 820, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_ptr); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 820, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_shape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 820, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = NULL;
    __pyx_t_9 = 0;
    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_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_v_self->dtype, __pyx_t_10, __pyx_int_0, __pyx_t_7};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 820, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_v_self->dtype, __pyx_t_10, __pyx_int_0, __pyx_t_7};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 820, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 820, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_v_self->dtype);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_t_10);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_9, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_9, __pyx_t_7);
      __pyx_t_10 = 0;
      __pyx_t_7 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 820, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":819
 *             data = cupy.rollaxis(self, axis, ndim).copy()
 * 
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             thrust.sort(self.dtype, data.data.ptr, 0, self._shape)
 *         else:
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":822
 *             thrust.sort(self.dtype, data.data.ptr, 0, self._shape)
 *         else:
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)             # <<<<<<<<<<<<<<
 *             thrust.sort(
 *                 self.dtype, data.data.ptr, keys_array.data.ptr, data._shape)
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 822, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 822, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 822, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 822, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_intp); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 822, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 822, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 822, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_keys_array = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":823
 *         else:
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)
 *             thrust.sort(             # <<<<<<<<<<<<<<
 *                 self.dtype, data.data.ptr, keys_array.data.ptr, data._shape)
 * 
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_thrust); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":824
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)
 *             thrust.sort(
 *                 self.dtype, data.data.ptr, keys_array.data.ptr, data._shape)             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 824, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ptr); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 824, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_keys_array->data->ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 824, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 824, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_6 = NULL;
    __pyx_t_9 = 0;
    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_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_v_self->dtype, __pyx_t_8, __pyx_t_3, __pyx_t_10};
      __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 823, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_v_self->dtype, __pyx_t_8, __pyx_t_3, __pyx_t_10};
      __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 823, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 823, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_v_self->dtype);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_9, __pyx_t_10);
      __pyx_t_8 = 0;
      __pyx_t_3 = 0;
      __pyx_t_10 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 823, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __pyx_L9:;

  /* "cupy/core/core.pyx":826
 *                 self.dtype, data.data.ptr, keys_array.data.ptr, data._shape)
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             pass
 *         else:
 */
  __pyx_t_7 = PyInt_FromSsize_t((__pyx_v_ndim - 1)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 826, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_7, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 826, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 826, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {
    goto __pyx_L10;
  }

  /* "cupy/core/core.pyx":829
 *             pass
 *         else:
 *             data = cupy.rollaxis(data, -1, axis)             # <<<<<<<<<<<<<<
 *             elementwise_copy(data, self)
 * 
 */
  /*else*/ {
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 829, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_rollaxis); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 829, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_data, __pyx_int_neg_1, __pyx_v_axis};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 829, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_data, __pyx_int_neg_1, __pyx_v_axis};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 829, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 829, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_data);
      __Pyx_GIVEREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_data);
      __Pyx_INCREF(__pyx_int_neg_1);
      __Pyx_GIVEREF(__pyx_int_neg_1);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_int_neg_1);
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_v_axis);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 829, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":830
 *         else:
 *             data = cupy.rollaxis(data, -1, axis)
 *             elementwise_copy(data, self)             # <<<<<<<<<<<<<<
 * 
 *     def argsort(self, axis=-1):
 */
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_10 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_data, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 830, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_data, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 830, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 830, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_INCREF(__pyx_v_data);
      __Pyx_GIVEREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_9, __pyx_v_data);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_9, ((PyObject *)__pyx_v_self));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 830, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L10:;

  /* "cupy/core/core.pyx":773
 *         return out
 * 
 *     def sort(self, axis=-1):             # <<<<<<<<<<<<<<
 *         """Sort an array, in-place with a stable sorting algorithm.
 * 
 */

  /* 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_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core.ndarray.sort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_keys_array);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":832
 *             elementwise_copy(data, self)
 * 
 *     def argsort(self, axis=-1):             # <<<<<<<<<<<<<<
 *         """Returns the indices that would sort an array with stable sorting
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_43argsort(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_42argsort[] = "ndarray.argsort(self, axis=-1)\nReturns the indices that would sort an array with stable sorting\n\n        Args:\n            axis (int or None): Axis along which to sort. Default is -1, which\n                means sort along the last axis. If None is supplied, the array\n                is flattened before sorting.\n\n        Returns:\n            cupy.ndarray: Array of indices that sort the array.\n\n        .. seealso::\n            :func:`cupy.argsort` for full documentation,\n            :meth:`numpy.ndarray.argsort`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_43argsort(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argsort (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_neg_1);
    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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "argsort") < 0)) __PYX_ERR(0, 832, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_axis = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("argsort", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 832, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.argsort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_42argsort(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_42argsort(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis) {
  Py_ssize_t __pyx_v_ndim;
  PyObject *__pyx_v_data = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_idx_array = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_keys_array = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  __Pyx_RefNannySetupContext("argsort", 0);
  __Pyx_INCREF(__pyx_v_axis);

  /* "cupy/core/core.pyx":851
 *         # TODO(takagi): Support kind argument.
 * 
 *         cdef Py_ssize_t ndim = self.ndim             # <<<<<<<<<<<<<<
 * 
 *         if not cupy.cuda.thrust_enabled:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 851, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 851, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_2;

  /* "cupy/core/core.pyx":853
 *         cdef Py_ssize_t ndim = self.ndim
 * 
 *         if not cupy.cuda.thrust_enabled:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('Thrust is needed to use cupy.argsort. Please '
 *                                'install CUDA Toolkit with Thrust then '
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 853, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_cuda); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 853, __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_thrust_enabled); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 853, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 853, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((!__pyx_t_4) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "cupy/core/core.pyx":854
 * 
 *         if not cupy.cuda.thrust_enabled:
 *             raise RuntimeError('Thrust is needed to use cupy.argsort. Please '             # <<<<<<<<<<<<<<
 *                                'install CUDA Toolkit with Thrust then '
 *                                'reinstall CuPy after uninstalling it.')
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 854, __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(0, 854, __pyx_L1_error)

    /* "cupy/core/core.pyx":853
 *         cdef Py_ssize_t ndim = self.ndim
 * 
 *         if not cupy.cuda.thrust_enabled:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('Thrust is needed to use cupy.argsort. Please '
 *                                'install CUDA Toolkit with Thrust then '
 */
  }

  /* "cupy/core/core.pyx":858
 *                                'reinstall CuPy after uninstalling it.')
 * 
 *         if ndim == 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Sorting arrays with the rank of zero is not '
 *                              'supported')  # as numpy.argsort() raises
 */
  __pyx_t_5 = ((__pyx_v_ndim == 0) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "cupy/core/core.pyx":859
 * 
 *         if ndim == 0:
 *             raise ValueError('Sorting arrays with the rank of zero is not '             # <<<<<<<<<<<<<<
 *                              'supported')  # as numpy.argsort() raises
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 859, __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(0, 859, __pyx_L1_error)

    /* "cupy/core/core.pyx":858
 *                                'reinstall CuPy after uninstalling it.')
 * 
 *         if ndim == 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Sorting arrays with the rank of zero is not '
 *                              'supported')  # as numpy.argsort() raises
 */
  }

  /* "cupy/core/core.pyx":862
 *                              'supported')  # as numpy.argsort() raises
 * 
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             data = self.reshape(self.size)
 *             axis = -1
 */
  __pyx_t_5 = (__pyx_v_axis == Py_None);
  __pyx_t_4 = (__pyx_t_5 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":863
 * 
 *         if axis is None:
 *             data = self.reshape(self.size)             # <<<<<<<<<<<<<<
 *             axis = -1
 *         else:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 863, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 863, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 863, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 863, __pyx_L1_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_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 863, __pyx_L1_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_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 863, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 863, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_data = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":864
 *         if axis is None:
 *             data = self.reshape(self.size)
 *             axis = -1             # <<<<<<<<<<<<<<
 *         else:
 *             data = self
 */
    __Pyx_INCREF(__pyx_int_neg_1);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_int_neg_1);

    /* "cupy/core/core.pyx":862
 *                              'supported')  # as numpy.argsort() raises
 * 
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             data = self.reshape(self.size)
 *             axis = -1
 */
    goto __pyx_L5;
  }

  /* "cupy/core/core.pyx":866
 *             axis = -1
 *         else:
 *             data = self             # <<<<<<<<<<<<<<
 * 
 *         if axis < 0:
 */
  /*else*/ {
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_v_data = ((PyObject *)__pyx_v_self);
  }
  __pyx_L5:;

  /* "cupy/core/core.pyx":868
 *             data = self
 * 
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 868, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 868, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":869
 * 
 *         if axis < 0:
 *             axis += ndim             # <<<<<<<<<<<<<<
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 869, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_axis, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 869, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":868
 *             data = self
 * 
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  }

  /* "cupy/core/core.pyx":870
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_int_0, __pyx_v_axis, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 870, __pyx_L1_error)
  if (__Pyx_PyObject_IsTrue(__pyx_t_3)) {
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 870, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 870, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = ((!__pyx_t_4) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "cupy/core/core.pyx":871
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 871, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 871, __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(0, 871, __pyx_L1_error)

    /* "cupy/core/core.pyx":870
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  }

  /* "cupy/core/core.pyx":873
 *             raise _AxisError('Axis out of range')
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             data = data.copy()
 *         else:
 */
  __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_ndim - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 873, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 873, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 873, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":874
 * 
 *         if axis == ndim - 1:
 *             data = data.copy()             # <<<<<<<<<<<<<<
 *         else:
 *             data = cupy.rollaxis(data, axis, ndim).copy()
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 874, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_8) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 874, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 874, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":873
 *             raise _AxisError('Axis out of range')
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             data = data.copy()
 *         else:
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":876
 *             data = data.copy()
 *         else:
 *             data = cupy.rollaxis(data, axis, ndim).copy()             # <<<<<<<<<<<<<<
 * 
 *         idx_array = ndarray(data.shape, dtype=numpy.intp)
 */
  /*else*/ {
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 876, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_rollaxis); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 876, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 876, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_data, __pyx_v_axis, __pyx_t_8};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 876, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_data, __pyx_v_axis, __pyx_t_8};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 876, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 876, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_data);
      __Pyx_GIVEREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_data);
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_axis);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 876, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_copy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 876, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_1) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 876, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 876, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":878
 *             data = cupy.rollaxis(data, axis, ndim).copy()
 * 
 *         idx_array = ndarray(data.shape, dtype=numpy.intp)             # <<<<<<<<<<<<<<
 * 
 *         if ndim == 1:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 878, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 878, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 878, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 878, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_intp); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 878, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_10) < 0) __PYX_ERR(0, 878, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 878, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_idx_array = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":880
 *         idx_array = ndarray(data.shape, dtype=numpy.intp)
 * 
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             thrust.argsort(self.dtype, idx_array.data.ptr, data.data.ptr, 0,
 *                            data._shape)
 */
  __pyx_t_5 = ((__pyx_v_ndim == 1) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":881
 * 
 *         if ndim == 1:
 *             thrust.argsort(self.dtype, idx_array.data.ptr, data.data.ptr, 0,             # <<<<<<<<<<<<<<
 *                            data._shape)
 *         else:
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_thrust); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 881, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_argsort); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 881, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_idx_array->data->ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 881, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 881, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ptr); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 881, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":882
 *         if ndim == 1:
 *             thrust.argsort(self.dtype, idx_array.data.ptr, data.data.ptr, 0,
 *                            data._shape)             # <<<<<<<<<<<<<<
 *         else:
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 882, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[6] = {__pyx_t_7, __pyx_v_self->dtype, __pyx_t_3, __pyx_t_8, __pyx_int_0, __pyx_t_1};
      __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __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[6] = {__pyx_t_7, __pyx_v_self->dtype, __pyx_t_3, __pyx_t_8, __pyx_int_0, __pyx_t_1};
      __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_v_self->dtype);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_t_8);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_9, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_9, __pyx_t_1);
      __pyx_t_3 = 0;
      __pyx_t_8 = 0;
      __pyx_t_1 = 0;
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":880
 *         idx_array = ndarray(data.shape, dtype=numpy.intp)
 * 
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             thrust.argsort(self.dtype, idx_array.data.ptr, data.data.ptr, 0,
 *                            data._shape)
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":884
 *                            data._shape)
 *         else:
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)             # <<<<<<<<<<<<<<
 *             thrust.argsort(self.dtype, idx_array.data.ptr, data.data.ptr,
 *                            keys_array.data.ptr, data._shape)
 */
  /*else*/ {
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 884, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 884, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 884, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 884, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_intp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 884, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 884, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_6, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 884, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_v_keys_array = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":885
 *         else:
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)
 *             thrust.argsort(self.dtype, idx_array.data.ptr, data.data.ptr,             # <<<<<<<<<<<<<<
 *                            keys_array.data.ptr, data._shape)
 * 
 */
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_thrust); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 885, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_argsort); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 885, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyInt_FromSize_t(__pyx_v_idx_array->data->ptr); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 885, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_data); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 885, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_ptr); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 885, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

    /* "cupy/core/core.pyx":886
 *             keys_array = ndarray(data._shape, dtype=numpy.intp)
 *             thrust.argsort(self.dtype, idx_array.data.ptr, data.data.ptr,
 *                            keys_array.data.ptr, data._shape)             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
    __pyx_t_11 = __Pyx_PyInt_FromSize_t(__pyx_v_keys_array->data->ptr); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 886, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 886, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[6] = {__pyx_t_7, __pyx_v_self->dtype, __pyx_t_10, __pyx_t_8, __pyx_t_11, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 885, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[6] = {__pyx_t_7, __pyx_v_self->dtype, __pyx_t_10, __pyx_t_8, __pyx_t_11, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 885, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 885, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_v_self->dtype);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_9, __pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_9, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_9, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_9, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_9, __pyx_t_3);
      __pyx_t_10 = 0;
      __pyx_t_8 = 0;
      __pyx_t_11 = 0;
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 885, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L9:;

  /* "cupy/core/core.pyx":888
 *                            keys_array.data.ptr, data._shape)
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             return idx_array
 *         else:
 */
  __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_ndim - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":889
 * 
 *         if axis == ndim - 1:
 *             return idx_array             # <<<<<<<<<<<<<<
 *         else:
 *             return cupy.rollaxis(idx_array, -1, axis)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_idx_array));
    __pyx_r = ((PyObject *)__pyx_v_idx_array);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":888
 *                            keys_array.data.ptr, data._shape)
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             return idx_array
 *         else:
 */
  }

  /* "cupy/core/core.pyx":891
 *             return idx_array
 *         else:
 *             return cupy.rollaxis(idx_array, -1, axis)             # <<<<<<<<<<<<<<
 * 
 *     def partition(self, kth, axis=-1):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_rollaxis); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[4] = {__pyx_t_1, ((PyObject *)__pyx_v_idx_array), __pyx_int_neg_1, __pyx_v_axis};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 891, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[4] = {__pyx_t_1, ((PyObject *)__pyx_v_idx_array), __pyx_int_neg_1, __pyx_v_axis};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 891, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 891, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_idx_array));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_idx_array));
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, ((PyObject *)__pyx_v_idx_array));
      __Pyx_INCREF(__pyx_int_neg_1);
      __Pyx_GIVEREF(__pyx_int_neg_1);
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_int_neg_1);
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_9, __pyx_v_axis);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 891, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":832
 *             elementwise_copy(data, self)
 * 
 *     def argsort(self, axis=-1):             # <<<<<<<<<<<<<<
 *         """Returns the indices that would sort an array with stable sorting
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core.ndarray.argsort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_idx_array);
  __Pyx_XDECREF((PyObject *)__pyx_v_keys_array);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":893
 *             return cupy.rollaxis(idx_array, -1, axis)
 * 
 *     def partition(self, kth, axis=-1):             # <<<<<<<<<<<<<<
 *         """Partitions an array.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_45partition(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_44partition[] = "ndarray.partition(self, kth, axis=-1)\nPartitions an array.\n\n        Args:\n            kth (int or sequence of ints): Element index to partition by. If\n                supplied with a sequence of k-th it will partition all elements\n                indexed by k-th of them into their sorted position at once.\n\n            axis (int): Axis along which to sort. Default is -1, which means\n                sort along the last axis.\n\n        .. seealso::\n            :func:`cupy.partition` for full documentation,\n            :meth:`numpy.ndarray.partition`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_45partition(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_kth = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("partition (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_kth,&__pyx_n_s_axis,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_int_neg_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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_kth)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "partition") < 0)) __PYX_ERR(0, 893, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_kth = values[0];
    __pyx_v_axis = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("partition", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 893, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.partition", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_44partition(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_kth, __pyx_v_axis);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_44partition(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_kth, PyObject *__pyx_v_axis) {
  Py_ssize_t __pyx_v_ndim;
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_v_length = NULL;
  PyObject *__pyx_v_max_k = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_sz = NULL;
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_kern = NULL;
  PyObject *__pyx_v_merge_kern = NULL;
  long __pyx_v_block_size;
  PyObject *__pyx_v_grid_size = NULL;
  PyObject *__pyx_v_s = 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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *(*__pyx_t_11)(PyObject *);
  long __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  __Pyx_RefNannySetupContext("partition", 0);
  __Pyx_INCREF(__pyx_v_kth);
  __Pyx_INCREF(__pyx_v_axis);

  /* "cupy/core/core.pyx":910
 *         """
 * 
 *         if cupy.issubdtype(self.dtype, numpy.complexfloating):             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('Sorting arrays with dtype \'{}\' is '
 *                                       'not supported'.format(self.dtype))
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_issubdtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_complexfloating); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  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_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_self->dtype, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 910, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_self->dtype, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 910, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 910, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_self->dtype);
    __Pyx_GIVEREF(__pyx_v_self->dtype);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_self->dtype);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 910, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 910, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_t_7)) {

    /* "cupy/core/core.pyx":912
 *         if cupy.issubdtype(self.dtype, numpy.complexfloating):
 *             raise NotImplementedError('Sorting arrays with dtype \'{}\' is '
 *                                       'not supported'.format(self.dtype))             # <<<<<<<<<<<<<<
 * 
 *         cdef Py_ssize_t ndim = self.ndim
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Sorting_arrays_with_dtype_is_not, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 912, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 912, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_self->dtype};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 912, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_self->dtype};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 912, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 912, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_INCREF(__pyx_v_self->dtype);
        __Pyx_GIVEREF(__pyx_v_self->dtype);
        PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->dtype);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 912, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":911
 * 
 *         if cupy.issubdtype(self.dtype, numpy.complexfloating):
 *             raise NotImplementedError('Sorting arrays with dtype \'{}\' is '             # <<<<<<<<<<<<<<
 *                                       'not supported'.format(self.dtype))
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_NotImplementedError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 911, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 911, __pyx_L1_error)

    /* "cupy/core/core.pyx":910
 *         """
 * 
 *         if cupy.issubdtype(self.dtype, numpy.complexfloating):             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('Sorting arrays with dtype \'{}\' is '
 *                                       'not supported'.format(self.dtype))
 */
  }

  /* "cupy/core/core.pyx":914
 *                                       'not supported'.format(self.dtype))
 * 
 *         cdef Py_ssize_t ndim = self.ndim             # <<<<<<<<<<<<<<
 * 
 *         if ndim == 0:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 914, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 914, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_ndim = __pyx_t_8;

  /* "cupy/core/core.pyx":916
 *         cdef Py_ssize_t ndim = self.ndim
 * 
 *         if ndim == 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Sorting arrays with the rank of zero is not '
 *                              'supported')
 */
  __pyx_t_7 = ((__pyx_v_ndim == 0) != 0);
  if (unlikely(__pyx_t_7)) {

    /* "cupy/core/core.pyx":917
 * 
 *         if ndim == 0:
 *             raise ValueError('Sorting arrays with the rank of zero is not '             # <<<<<<<<<<<<<<
 *                              'supported')
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 917, __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(0, 917, __pyx_L1_error)

    /* "cupy/core/core.pyx":916
 *         cdef Py_ssize_t ndim = self.ndim
 * 
 *         if ndim == 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Sorting arrays with the rank of zero is not '
 *                              'supported')
 */
  }

  /* "cupy/core/core.pyx":920
 *                              'supported')
 * 
 *         if not self._c_contiguous:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('Sorting non-contiguous array is not '
 *                                       'supported.')
 */
  __pyx_t_7 = ((!(__pyx_v_self->_c_contiguous != 0)) != 0);
  if (unlikely(__pyx_t_7)) {

    /* "cupy/core/core.pyx":921
 * 
 *         if not self._c_contiguous:
 *             raise NotImplementedError('Sorting non-contiguous array is not '             # <<<<<<<<<<<<<<
 *                                       'supported.')
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 921, __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(0, 921, __pyx_L1_error)

    /* "cupy/core/core.pyx":920
 *                              'supported')
 * 
 *         if not self._c_contiguous:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('Sorting non-contiguous array is not '
 *                                       'supported.')
 */
  }

  /* "cupy/core/core.pyx":924
 *                                       'supported.')
 * 
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 924, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 924, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":925
 * 
 *         if axis < 0:
 *             axis += ndim             # <<<<<<<<<<<<<<
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 925, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_axis, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 925, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":924
 *                                       'supported.')
 * 
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  }

  /* "cupy/core/core.pyx":926
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_int_0, __pyx_v_axis, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 926, __pyx_L1_error)
  if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 926, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 926, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 926, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_9 = ((!__pyx_t_7) != 0);
  if (unlikely(__pyx_t_9)) {

    /* "cupy/core/core.pyx":927
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 927, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 927, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 927, __pyx_L1_error)

    /* "cupy/core/core.pyx":926
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  }

  /* "cupy/core/core.pyx":929
 *             raise _AxisError('Axis out of range')
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             data = self
 *         else:
 */
  __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_ndim - 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":930
 * 
 *         if axis == ndim - 1:
 *             data = self             # <<<<<<<<<<<<<<
 *         else:
 *             data = cupy.rollaxis(self, axis, ndim).copy()
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_v_data = ((PyObject *)__pyx_v_self);

    /* "cupy/core/core.pyx":929
 *             raise _AxisError('Axis out of range')
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             data = self
 *         else:
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":932
 *             data = self
 *         else:
 *             data = cupy.rollaxis(self, axis, ndim).copy()             # <<<<<<<<<<<<<<
 * 
 *         length = self.shape[axis]
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 932, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_rollaxis); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 932, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 932, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[4] = {__pyx_t_2, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_t_4};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 932, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[4] = {__pyx_t_2, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_t_4};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 932, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 932, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_5, __pyx_v_axis);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_5, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 932, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_copy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 932, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 932, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 932, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_data = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":934
 *             data = cupy.rollaxis(self, axis, ndim).copy()
 * 
 *         length = self.shape[axis]             # <<<<<<<<<<<<<<
 *         if isinstance(kth, int):
 *             kth = kth,
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 934, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_axis); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 934, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_length = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":935
 * 
 *         length = self.shape[axis]
 *         if isinstance(kth, int):             # <<<<<<<<<<<<<<
 *             kth = kth,
 *         max_k = 0
 */
  __pyx_t_9 = PyInt_Check(__pyx_v_kth); 
  __pyx_t_7 = (__pyx_t_9 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":936
 *         length = self.shape[axis]
 *         if isinstance(kth, int):
 *             kth = kth,             # <<<<<<<<<<<<<<
 *         max_k = 0
 *         for k in kth:
 */
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 936, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_kth);
    __Pyx_GIVEREF(__pyx_v_kth);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_kth);
    __Pyx_DECREF_SET(__pyx_v_kth, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":935
 * 
 *         length = self.shape[axis]
 *         if isinstance(kth, int):             # <<<<<<<<<<<<<<
 *             kth = kth,
 *         max_k = 0
 */
  }

  /* "cupy/core/core.pyx":937
 *         if isinstance(kth, int):
 *             kth = kth,
 *         max_k = 0             # <<<<<<<<<<<<<<
 *         for k in kth:
 *             if k < 0:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_max_k = __pyx_int_0;

  /* "cupy/core/core.pyx":938
 *             kth = kth,
 *         max_k = 0
 *         for k in kth:             # <<<<<<<<<<<<<<
 *             if k < 0:
 *                 k += length
 */
  if (likely(PyList_CheckExact(__pyx_v_kth)) || PyTuple_CheckExact(__pyx_v_kth)) {
    __pyx_t_6 = __pyx_v_kth; __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_kth); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 938, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 938, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_6))) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 938, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 938, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 938, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 938, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_11(__pyx_t_6);
      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, 938, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":939
 *         max_k = 0
 *         for k in kth:
 *             if k < 0:             # <<<<<<<<<<<<<<
 *                 k += length
 *             if not (0 <= k < length):
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_k, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 939, __pyx_L1_error)
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 939, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":940
 *         for k in kth:
 *             if k < 0:
 *                 k += length             # <<<<<<<<<<<<<<
 *             if not (0 <= k < length):
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 */
      __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_v_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 940, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":939
 *         max_k = 0
 *         for k in kth:
 *             if k < 0:             # <<<<<<<<<<<<<<
 *                 k += length
 *             if not (0 <= k < length):
 */
    }

    /* "cupy/core/core.pyx":941
 *             if k < 0:
 *                 k += length
 *             if not (0 <= k < length):             # <<<<<<<<<<<<<<
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 *             if max_k < k:
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_int_0, __pyx_v_k, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 941, __pyx_L1_error)
    if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
      __Pyx_DECREF(__pyx_t_1);
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_k, __pyx_v_length, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 941, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 941, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_9 = ((!__pyx_t_7) != 0);
    if (unlikely(__pyx_t_9)) {

      /* "cupy/core/core.pyx":942
 *                 k += length
 *             if not (0 <= k < length):
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))             # <<<<<<<<<<<<<<
 *             if max_k < k:
 *                 max_k = k
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_kth_out_of_bounds, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 942, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_k, __pyx_v_length};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 942, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_k, __pyx_v_length};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 942, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 942, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_INCREF(__pyx_v_k);
        __Pyx_GIVEREF(__pyx_v_k);
        PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_k);
        __Pyx_INCREF(__pyx_v_length);
        __Pyx_GIVEREF(__pyx_v_length);
        PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_length);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 942, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 942, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 942, __pyx_L1_error)

      /* "cupy/core/core.pyx":941
 *             if k < 0:
 *                 k += length
 *             if not (0 <= k < length):             # <<<<<<<<<<<<<<
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 *             if max_k < k:
 */
    }

    /* "cupy/core/core.pyx":943
 *             if not (0 <= k < length):
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 *             if max_k < k:             # <<<<<<<<<<<<<<
 *                 max_k = k
 * 
 */
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_max_k, __pyx_v_k, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 943, __pyx_L1_error)
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 943, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_9) {

      /* "cupy/core/core.pyx":944
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 *             if max_k < k:
 *                 max_k = k             # <<<<<<<<<<<<<<
 * 
 *         # For simplicity, max_k is round up to the power of 2. If max_k is
 */
      __Pyx_INCREF(__pyx_v_k);
      __Pyx_DECREF_SET(__pyx_v_max_k, __pyx_v_k);

      /* "cupy/core/core.pyx":943
 *             if not (0 <= k < length):
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 *             if max_k < k:             # <<<<<<<<<<<<<<
 *                 max_k = k
 * 
 */
    }

    /* "cupy/core/core.pyx":938
 *             kth = kth,
 *         max_k = 0
 *         for k in kth:             # <<<<<<<<<<<<<<
 *             if k < 0:
 *                 k += length
 */
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":949
 *         # already the power of 2, it is round up to the next power of 2 because
 *         # we need to collect the first max(kth)+1 elements.
 *         max_k = max(32, 1 << max_k.bit_length())             # <<<<<<<<<<<<<<
 * 
 *         # The parameter t is the length of the list that stores elements to be
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_max_k, __pyx_n_s_bit_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 949, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 949, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 949, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Lshift(__pyx_int_1, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 949, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_12 = 32;
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 949, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_t_1, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 949, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 949, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_9) {
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_6 = __pyx_t_3;
  } else {
    __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 949, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __pyx_t_4;
    __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __pyx_t_6;
  __Pyx_INCREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_max_k, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":954
 *         # selected for each thread. We divide the array into sz subarrays.
 *         # These parameters are determined from the measurement on TITAN X.
 *         t = 4             # <<<<<<<<<<<<<<
 *         sz = 512
 *         while sz > 0 and length // sz < max_k + 32 * t:
 */
  __Pyx_INCREF(__pyx_int_4);
  __pyx_v_t = __pyx_int_4;

  /* "cupy/core/core.pyx":955
 *         # These parameters are determined from the measurement on TITAN X.
 *         t = 4
 *         sz = 512             # <<<<<<<<<<<<<<
 *         while sz > 0 and length // sz < max_k + 32 * t:
 *             sz //= 2
 */
  __Pyx_INCREF(__pyx_int_512);
  __pyx_v_sz = __pyx_int_512;

  /* "cupy/core/core.pyx":956
 *         t = 4
 *         sz = 512
 *         while sz > 0 and length // sz < max_k + 32 * t:             # <<<<<<<<<<<<<<
 *             sz //= 2
 *         sz *= self.size // length
 */
  while (1) {
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_sz, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 956, __pyx_L1_error)
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_7) {
    } else {
      __pyx_t_9 = __pyx_t_7;
      goto __pyx_L17_bool_binop_done;
    }
    __pyx_t_3 = PyNumber_FloorDivide(__pyx_v_length, __pyx_v_sz); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyNumber_Multiply(__pyx_int_32, __pyx_v_t); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PyNumber_Add(__pyx_v_max_k, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_9 = __pyx_t_7;
    __pyx_L17_bool_binop_done:;
    if (!__pyx_t_9) break;

    /* "cupy/core/core.pyx":957
 *         sz = 512
 *         while sz > 0 and length // sz < max_k + 32 * t:
 *             sz //= 2             # <<<<<<<<<<<<<<
 *         sz *= self.size // length
 * 
 */
    __pyx_t_6 = __Pyx_PyInt_FloorDivideObjC(__pyx_v_sz, __pyx_int_2, 2, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 957, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF_SET(__pyx_v_sz, __pyx_t_6);
    __pyx_t_6 = 0;
  }

  /* "cupy/core/core.pyx":958
 *         while sz > 0 and length // sz < max_k + 32 * t:
 *             sz //= 2
 *         sz *= self.size // length             # <<<<<<<<<<<<<<
 * 
 *         # If the array size is small or k is large, we simply sort the array.
 */
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 958, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = PyNumber_FloorDivide(__pyx_t_6, __pyx_v_length); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 958, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_sz, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 958, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_sz, __pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":961
 * 
 *         # If the array size is small or k is large, we simply sort the array.
 *         if length < 32 or sz <= 32 or max_k >= 1024:             # <<<<<<<<<<<<<<
 *             # kth is ignored.
 *             data.sort(axis=-1)
 */
  __pyx_t_6 = PyObject_RichCompare(__pyx_v_length, __pyx_int_32, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 961, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 961, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!__pyx_t_7) {
  } else {
    __pyx_t_9 = __pyx_t_7;
    goto __pyx_L20_bool_binop_done;
  }
  __pyx_t_6 = PyObject_RichCompare(__pyx_v_sz, __pyx_int_32, Py_LE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 961, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 961, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!__pyx_t_7) {
  } else {
    __pyx_t_9 = __pyx_t_7;
    goto __pyx_L20_bool_binop_done;
  }
  __pyx_t_6 = PyObject_RichCompare(__pyx_v_max_k, __pyx_int_1024, Py_GE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 961, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 961, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_9 = __pyx_t_7;
  __pyx_L20_bool_binop_done:;
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":963
 *         if length < 32 or sz <= 32 or max_k >= 1024:
 *             # kth is ignored.
 *             data.sort(axis=-1)             # <<<<<<<<<<<<<<
 *         else:
 *             shape = data.shape
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_sort); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 963, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 963, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_axis, __pyx_int_neg_1) < 0) __PYX_ERR(0, 963, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 963, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":961
 * 
 *         # If the array size is small or k is large, we simply sort the array.
 *         if length < 32 or sz <= 32 or max_k >= 1024:             # <<<<<<<<<<<<<<
 *             # kth is ignored.
 *             data.sort(axis=-1)
 */
    goto __pyx_L19;
  }

  /* "cupy/core/core.pyx":965
 *             data.sort(axis=-1)
 *         else:
 *             shape = data.shape             # <<<<<<<<<<<<<<
 *             data = data.ravel()
 * 
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 965, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_shape = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":966
 *         else:
 *             shape = data.shape
 *             data = data.ravel()             # <<<<<<<<<<<<<<
 * 
 *             # For each subarray, we collect first k elements to the head.
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_ravel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 966, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 966, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 966, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":969
 * 
 *             # For each subarray, we collect first k elements to the head.
 *             kern, merge_kern = _partition_kernel(self.dtype)             # <<<<<<<<<<<<<<
 *             block_size = 32
 *             grid_size = sz
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_partition_kernel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 969, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_self->dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 969, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_self->dtype};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 969, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_self->dtype};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 969, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 969, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_INCREF(__pyx_v_self->dtype);
        __Pyx_GIVEREF(__pyx_v_self->dtype);
        PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_self->dtype);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 969, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      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(0, 969, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      #else
      __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 969, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 969, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 969, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_13 = Py_TYPE(__pyx_t_6)->tp_iternext;
      index = 0; __pyx_t_4 = __pyx_t_13(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L23_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      index = 1; __pyx_t_1 = __pyx_t_13(__pyx_t_6); if (unlikely(!__pyx_t_1)) goto __pyx_L23_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_6), 2) < 0) __PYX_ERR(0, 969, __pyx_L1_error)
      __pyx_t_13 = NULL;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L24_unpacking_done;
      __pyx_L23_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_13 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 969, __pyx_L1_error)
      __pyx_L24_unpacking_done:;
    }
    __pyx_v_kern = __pyx_t_4;
    __pyx_t_4 = 0;
    __pyx_v_merge_kern = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":970
 *             # For each subarray, we collect first k elements to the head.
 *             kern, merge_kern = _partition_kernel(self.dtype)
 *             block_size = 32             # <<<<<<<<<<<<<<
 *             grid_size = sz
 *             kern(grid=(grid_size,), block=(block_size,), args=(
 */
    __pyx_v_block_size = 32;

    /* "cupy/core/core.pyx":971
 *             kern, merge_kern = _partition_kernel(self.dtype)
 *             block_size = 32
 *             grid_size = sz             # <<<<<<<<<<<<<<
 *             kern(grid=(grid_size,), block=(block_size,), args=(
 *                 data, max_k, self.size, t, sz))
 */
    __Pyx_INCREF(__pyx_v_sz);
    __pyx_v_grid_size = __pyx_v_sz;

    /* "cupy/core/core.pyx":972
 *             block_size = 32
 *             grid_size = sz
 *             kern(grid=(grid_size,), block=(block_size,), args=(             # <<<<<<<<<<<<<<
 *                 data, max_k, self.size, t, sz))
 * 
 */
    __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_grid_size);
    __Pyx_GIVEREF(__pyx_v_grid_size);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_grid_size);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_grid, __pyx_t_1) < 0) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_block_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_block, __pyx_t_4) < 0) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":973
 *             grid_size = sz
 *             kern(grid=(grid_size,), block=(block_size,), args=(
 *                 data, max_k, self.size, t, sz))             # <<<<<<<<<<<<<<
 * 
 *             # Merge heads of subarrays.
 */
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 973, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 973, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_data);
    __Pyx_GIVEREF(__pyx_v_data);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_data);
    __Pyx_INCREF(__pyx_v_max_k);
    __Pyx_GIVEREF(__pyx_v_max_k);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_max_k);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_4);
    __Pyx_INCREF(__pyx_v_t);
    __Pyx_GIVEREF(__pyx_v_t);
    PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_t);
    __Pyx_INCREF(__pyx_v_sz);
    __Pyx_GIVEREF(__pyx_v_sz);
    PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_v_sz);
    __pyx_t_4 = 0;
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_args, __pyx_t_1) < 0) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":972
 *             block_size = 32
 *             grid_size = sz
 *             kern(grid=(grid_size,), block=(block_size,), args=(             # <<<<<<<<<<<<<<
 *                 data, max_k, self.size, t, sz))
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_kern, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":976
 * 
 *             # Merge heads of subarrays.
 *             s = 1             # <<<<<<<<<<<<<<
 *             while s < sz // (self.size // length):
 *                 block_size = 32
 */
    __Pyx_INCREF(__pyx_int_1);
    __pyx_v_s = __pyx_int_1;

    /* "cupy/core/core.pyx":977
 *             # Merge heads of subarrays.
 *             s = 1
 *             while s < sz // (self.size // length):             # <<<<<<<<<<<<<<
 *                 block_size = 32
 *                 grid_size = sz // s // 2
 */
    while (1) {
      __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 977, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyNumber_FloorDivide(__pyx_t_1, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 977, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_FloorDivide(__pyx_v_sz, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 977, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_s, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 977, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 977, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!__pyx_t_9) break;

      /* "cupy/core/core.pyx":978
 *             s = 1
 *             while s < sz // (self.size // length):
 *                 block_size = 32             # <<<<<<<<<<<<<<
 *                 grid_size = sz // s // 2
 *                 merge_kern(grid=(grid_size,), block=(block_size,), args=(
 */
      __pyx_v_block_size = 32;

      /* "cupy/core/core.pyx":979
 *             while s < sz // (self.size // length):
 *                 block_size = 32
 *                 grid_size = sz // s // 2             # <<<<<<<<<<<<<<
 *                 merge_kern(grid=(grid_size,), block=(block_size,), args=(
 *                     data, max_k, self.size, sz, s))
 */
      __pyx_t_3 = PyNumber_FloorDivide(__pyx_v_sz, __pyx_v_s); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 979, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_3, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 979, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v_grid_size, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":980
 *                 block_size = 32
 *                 grid_size = sz // s // 2
 *                 merge_kern(grid=(grid_size,), block=(block_size,), args=(             # <<<<<<<<<<<<<<
 *                     data, max_k, self.size, sz, s))
 *                 s *= 2
 */
      __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 980, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 980, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_grid_size);
      __Pyx_GIVEREF(__pyx_v_grid_size);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_grid_size);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_grid, __pyx_t_3) < 0) __PYX_ERR(0, 980, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_block_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 980, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 980, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_block, __pyx_t_4) < 0) __PYX_ERR(0, 980, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":981
 *                 grid_size = sz // s // 2
 *                 merge_kern(grid=(grid_size,), block=(block_size,), args=(
 *                     data, max_k, self.size, sz, s))             # <<<<<<<<<<<<<<
 *                 s *= 2
 * 
 */
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 981, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 981, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_data);
      __Pyx_GIVEREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_data);
      __Pyx_INCREF(__pyx_v_max_k);
      __Pyx_GIVEREF(__pyx_v_max_k);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_max_k);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_4);
      __Pyx_INCREF(__pyx_v_sz);
      __Pyx_GIVEREF(__pyx_v_sz);
      PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_sz);
      __Pyx_INCREF(__pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_s);
      __pyx_t_4 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_args, __pyx_t_3) < 0) __PYX_ERR(0, 980, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":980
 *                 block_size = 32
 *                 grid_size = sz // s // 2
 *                 merge_kern(grid=(grid_size,), block=(block_size,), args=(             # <<<<<<<<<<<<<<
 *                     data, max_k, self.size, sz, s))
 *                 s *= 2
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_merge_kern, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 980, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":982
 *                 merge_kern(grid=(grid_size,), block=(block_size,), args=(
 *                     data, max_k, self.size, sz, s))
 *                 s *= 2             # <<<<<<<<<<<<<<
 * 
 *             data = data.reshape(shape)
 */
      __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_v_s, __pyx_int_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 982, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_3);
      __pyx_t_3 = 0;
    }

    /* "cupy/core/core.pyx":984
 *                 s *= 2
 * 
 *             data = data.reshape(shape)             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 984, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 984, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_shape};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 984, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_shape};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 984, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 984, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(__pyx_v_shape);
        __Pyx_GIVEREF(__pyx_v_shape);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_shape);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 984, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L19:;

  /* "cupy/core/core.pyx":986
 *             data = data.reshape(shape)
 * 
 *         if axis == ndim - 1:             # <<<<<<<<<<<<<<
 *             pass
 *         else:
 */
  __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_ndim - 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 986, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 986, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 986, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_9) {
    goto __pyx_L27;
  }

  /* "cupy/core/core.pyx":989
 *             pass
 *         else:
 *             data = cupy.rollaxis(data, -1, axis)             # <<<<<<<<<<<<<<
 *             elementwise_copy(data, self)
 * 
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 989, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_rollaxis); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 989, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_data, __pyx_int_neg_1, __pyx_v_axis};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 989, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_data, __pyx_int_neg_1, __pyx_v_axis};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 989, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 989, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(__pyx_v_data);
      __Pyx_GIVEREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_data);
      __Pyx_INCREF(__pyx_int_neg_1);
      __Pyx_GIVEREF(__pyx_int_neg_1);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_int_neg_1);
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_5, __pyx_v_axis);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 989, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":990
 *         else:
 *             data = cupy.rollaxis(data, -1, axis)
 *             elementwise_copy(data, self)             # <<<<<<<<<<<<<<
 * 
 *     def argpartition(self, kth, axis=-1):
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 990, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_data, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 990, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_data, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 990, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 990, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_v_data);
      __Pyx_GIVEREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_5, __pyx_v_data);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 990, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L27:;

  /* "cupy/core/core.pyx":893
 *             return cupy.rollaxis(idx_array, -1, axis)
 * 
 *     def partition(self, kth, axis=-1):             # <<<<<<<<<<<<<<
 *         """Partitions an array.
 * 
 */

  /* 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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.core.core.ndarray.partition", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF(__pyx_v_length);
  __Pyx_XDECREF(__pyx_v_max_k);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_sz);
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_kern);
  __Pyx_XDECREF(__pyx_v_merge_kern);
  __Pyx_XDECREF(__pyx_v_grid_size);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_kth);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":992
 *             elementwise_copy(data, self)
 * 
 *     def argpartition(self, kth, axis=-1):             # <<<<<<<<<<<<<<
 *         """Returns the indices that would partially sort an array.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_47argpartition(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_46argpartition[] = "ndarray.argpartition(self, kth, axis=-1)\nReturns the indices that would partially sort an array.\n\n        Args:\n            kth (int or sequence of ints): Element index to partition by. If\n                supplied with a sequence of k-th it will partition all elements\n                indexed by k-th of them into their sorted position at once.\n            axis (int or None): Axis along which to sort. Default is -1, which\n                means sort along the last axis. If None is supplied, the array\n                is flattened before sorting.\n\n        Returns:\n            cupy.ndarray: Array of the same type and shape as ``a``.\n\n        .. seealso::\n            :func:`cupy.argpartition` for full documentation,\n            :meth:`numpy.ndarray.argpartition`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_47argpartition(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_kth = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argpartition (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_kth,&__pyx_n_s_axis,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_int_neg_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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_kth)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "argpartition") < 0)) __PYX_ERR(0, 992, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_kth = values[0];
    __pyx_v_axis = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("argpartition", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 992, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.argpartition", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_46argpartition(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_kth, __pyx_v_axis);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_46argpartition(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_kth, PyObject *__pyx_v_axis) {
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_v_ndim = NULL;
  PyObject *__pyx_v_length = NULL;
  PyObject *__pyx_v_k = NULL;
  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;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("argpartition", 0);
  __Pyx_INCREF(__pyx_v_kth);
  __Pyx_INCREF(__pyx_v_axis);

  /* "cupy/core/core.pyx":1011
 * 
 *         """
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             data = self.reshape(self.size)
 *             axis = -1
 */
  __pyx_t_1 = (__pyx_v_axis == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1012
 *         """
 *         if axis is None:
 *             data = self.reshape(self.size)             # <<<<<<<<<<<<<<
 *             axis = -1
 *         else:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1012, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1012, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1012, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1012, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1012, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1012, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1012, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_data = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1013
 *         if axis is None:
 *             data = self.reshape(self.size)
 *             axis = -1             # <<<<<<<<<<<<<<
 *         else:
 *             data = self
 */
    __Pyx_INCREF(__pyx_int_neg_1);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_int_neg_1);

    /* "cupy/core/core.pyx":1011
 * 
 *         """
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             data = self.reshape(self.size)
 *             axis = -1
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1015
 *             axis = -1
 *         else:
 *             data = self             # <<<<<<<<<<<<<<
 * 
 *         ndim = data.ndim
 */
  /*else*/ {
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_v_data = ((PyObject *)__pyx_v_self);
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1017
 *             data = self
 * 
 *         ndim = data.ndim             # <<<<<<<<<<<<<<
 *         if axis < 0:
 *             axis += ndim
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1017, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ndim = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1018
 * 
 *         ndim = data.ndim
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1018, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1018, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1019
 *         ndim = data.ndim
 *         if axis < 0:
 *             axis += ndim             # <<<<<<<<<<<<<<
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')
 */
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_axis, __pyx_v_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1019, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1018
 * 
 *         ndim = data.ndim
 *         if axis < 0:             # <<<<<<<<<<<<<<
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 */
  }

  /* "cupy/core/core.pyx":1020
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_int_0, __pyx_v_axis, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1020, __pyx_L1_error)
  if (__Pyx_PyObject_IsTrue(__pyx_t_3)) {
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_axis, __pyx_v_ndim, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1020, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1020, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = ((!__pyx_t_2) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cupy/core/core.pyx":1021
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         length = data.shape[axis]
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1021, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1021, __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(0, 1021, __pyx_L1_error)

    /* "cupy/core/core.pyx":1020
 *         if axis < 0:
 *             axis += ndim
 *         if not (0 <= axis < ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis out of range')
 * 
 */
  }

  /* "cupy/core/core.pyx":1023
 *             raise _AxisError('Axis out of range')
 * 
 *         length = data.shape[axis]             # <<<<<<<<<<<<<<
 *         if isinstance(kth, int):
 *             kth = kth,
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1023, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_v_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1023, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_length = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1024
 * 
 *         length = data.shape[axis]
 *         if isinstance(kth, int):             # <<<<<<<<<<<<<<
 *             kth = kth,
 *         for k in kth:
 */
  __pyx_t_1 = PyInt_Check(__pyx_v_kth); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1025
 *         length = data.shape[axis]
 *         if isinstance(kth, int):
 *             kth = kth,             # <<<<<<<<<<<<<<
 *         for k in kth:
 *             if k < 0:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1025, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_kth);
    __Pyx_GIVEREF(__pyx_v_kth);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_kth);
    __Pyx_DECREF_SET(__pyx_v_kth, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1024
 * 
 *         length = data.shape[axis]
 *         if isinstance(kth, int):             # <<<<<<<<<<<<<<
 *             kth = kth,
 *         for k in kth:
 */
  }

  /* "cupy/core/core.pyx":1026
 *         if isinstance(kth, int):
 *             kth = kth,
 *         for k in kth:             # <<<<<<<<<<<<<<
 *             if k < 0:
 *                 k += length
 */
  if (likely(PyList_CheckExact(__pyx_v_kth)) || PyTuple_CheckExact(__pyx_v_kth)) {
    __pyx_t_3 = __pyx_v_kth; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_kth); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1026, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1026, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1026, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1026, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1026, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1026, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_9(__pyx_t_3);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1026, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":1027
 *             kth = kth,
 *         for k in kth:
 *             if k < 0:             # <<<<<<<<<<<<<<
 *                 k += length
 *             if not (0 <= k < length):
 */
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1027, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1027, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1028
 *         for k in kth:
 *             if k < 0:
 *                 k += length             # <<<<<<<<<<<<<<
 *             if not (0 <= k < length):
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 */
      __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_k, __pyx_v_length); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1028, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1027
 *             kth = kth,
 *         for k in kth:
 *             if k < 0:             # <<<<<<<<<<<<<<
 *                 k += length
 *             if not (0 <= k < length):
 */
    }

    /* "cupy/core/core.pyx":1029
 *             if k < 0:
 *                 k += length
 *             if not (0 <= k < length):             # <<<<<<<<<<<<<<
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 * 
 */
    __pyx_t_4 = PyObject_RichCompare(__pyx_int_0, __pyx_v_k, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1029, __pyx_L1_error)
    if (__Pyx_PyObject_IsTrue(__pyx_t_4)) {
      __Pyx_DECREF(__pyx_t_4);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_v_length, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1029, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1029, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = ((!__pyx_t_2) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "cupy/core/core.pyx":1030
 *                 k += length
 *             if not (0 <= k < length):
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))             # <<<<<<<<<<<<<<
 * 
 *         # TODO(takgi) For its implementation reason, cupy.ndarray.argsort
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_kth_out_of_bounds, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1030, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_5 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_k, __pyx_v_length};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1030, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_k, __pyx_v_length};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1030, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1030, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_5) {
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        }
        __Pyx_INCREF(__pyx_v_k);
        __Pyx_GIVEREF(__pyx_v_k);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_10, __pyx_v_k);
        __Pyx_INCREF(__pyx_v_length);
        __Pyx_GIVEREF(__pyx_v_length);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_10, __pyx_v_length);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1030, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1030, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __PYX_ERR(0, 1030, __pyx_L1_error)

      /* "cupy/core/core.pyx":1029
 *             if k < 0:
 *                 k += length
 *             if not (0 <= k < length):             # <<<<<<<<<<<<<<
 *                 raise ValueError('kth(={}) out of bounds {}'.format(k, length))
 * 
 */
    }

    /* "cupy/core/core.pyx":1026
 *         if isinstance(kth, int):
 *             kth = kth,
 *         for k in kth:             # <<<<<<<<<<<<<<
 *             if k < 0:
 *                 k += length
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1037
 * 
 *         # kth is ignored.
 *         return cupy.argsort(data, axis=axis)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement searchsorted
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1037, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_argsort); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1037, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1037, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_data);
  __Pyx_GIVEREF(__pyx_v_data);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_data);
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1037, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1037, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1037, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":992
 *             elementwise_copy(data, self)
 * 
 *     def argpartition(self, kth, axis=-1):             # <<<<<<<<<<<<<<
 *         """Returns the indices that would partially sort an array.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core.ndarray.argpartition", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF(__pyx_v_ndim);
  __Pyx_XDECREF(__pyx_v_length);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_kth);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1041
 *     # TODO(okuta): Implement searchsorted
 * 
 *     def nonzero(self):             # <<<<<<<<<<<<<<
 *         """Return the indices of the elements that are non-zero.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_49nonzero(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_48nonzero[] = "ndarray.nonzero(self)\nReturn the indices of the elements that are non-zero.\n\n        Returned Array is containing the indices of the non-zero elements\n        in that dimension.\n\n        Returns:\n            tuple of arrays: Indices of elements that are non-zero.\n\n        .. seealso::\n            :func:`numpy.nonzero`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_49nonzero(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("nonzero (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_48nonzero(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_48nonzero(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  Py_ssize_t __pyx_v_count_nonzero;
  Py_ssize_t __pyx_v_ndim;
  PyObject *__pyx_v_dtype = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_r = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_scan_index = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dst = NULL;
  PyObject *__pyx_v_kern = NULL;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  long __pyx_t_7;
  std::vector<Py_ssize_t> ::size_type __pyx_t_8;
  std::vector<Py_ssize_t> ::size_type __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  Py_ssize_t __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  __Pyx_RefNannySetupContext("nonzero", 0);

  /* "cupy/core/core.pyx":1055
 *         """
 *         cdef Py_ssize_t count_nonzero, ndim
 *         dtype = numpy.int64             # <<<<<<<<<<<<<<
 *         if self.size == 0:
 *             count_nonzero = 0
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dtype = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":1056
 *         cdef Py_ssize_t count_nonzero, ndim
 *         dtype = numpy.int64
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             count_nonzero = 0
 *         else:
 */
  __pyx_t_3 = ((__pyx_v_self->size == 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":1057
 *         dtype = numpy.int64
 *         if self.size == 0:
 *             count_nonzero = 0             # <<<<<<<<<<<<<<
 *         else:
 *             r = self.ravel()
 */
    __pyx_v_count_nonzero = 0;

    /* "cupy/core/core.pyx":1056
 *         cdef Py_ssize_t count_nonzero, ndim
 *         dtype = numpy.int64
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             count_nonzero = 0
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1059
 *             count_nonzero = 0
 *         else:
 *             r = self.ravel()             # <<<<<<<<<<<<<<
 *             scan_index = scan((r != 0).astype(dtype))
 *             count_nonzero = int(scan_index[-1])
 */
  /*else*/ {
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->ravel(__pyx_v_self, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1059, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":1060
 *         else:
 *             r = self.ravel()
 *             scan_index = scan((r != 0).astype(dtype))             # <<<<<<<<<<<<<<
 *             count_nonzero = int(scan_index[-1])
 *         ndim = max(self._shape.size(), 1)
 */
    __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_r), __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1060, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1060, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_1) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1060, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_dtype};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1060, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_dtype};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1060, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1060, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_dtype);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1060, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1060, __pyx_L1_error)
    __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core_scan(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2), 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1060, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_scan_index = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":1061
 *             r = self.ravel()
 *             scan_index = scan((r != 0).astype(dtype))
 *             count_nonzero = int(scan_index[-1])             # <<<<<<<<<<<<<<
 *         ndim = max(self._shape.size(), 1)
 *         if count_nonzero == 0:
 */
    __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_v_scan_index), -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1061, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1061, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1061, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_count_nonzero = __pyx_t_6;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1062
 *             scan_index = scan((r != 0).astype(dtype))
 *             count_nonzero = int(scan_index[-1])
 *         ndim = max(self._shape.size(), 1)             # <<<<<<<<<<<<<<
 *         if count_nonzero == 0:
 *             return (ndarray((0,), dtype=dtype),) * ndim
 */
  __pyx_t_7 = 1;
  __pyx_t_8 = __pyx_v_self->_shape.size();
  if (((__pyx_t_7 > __pyx_t_8) != 0)) {
    __pyx_t_9 = __pyx_t_7;
  } else {
    __pyx_t_9 = __pyx_t_8;
  }
  __pyx_v_ndim = __pyx_t_9;

  /* "cupy/core/core.pyx":1063
 *             count_nonzero = int(scan_index[-1])
 *         ndim = max(self._shape.size(), 1)
 *         if count_nonzero == 0:             # <<<<<<<<<<<<<<
 *             return (ndarray((0,), dtype=dtype),) * ndim
 * 
 */
  __pyx_t_3 = ((__pyx_v_count_nonzero == 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":1064
 *         ndim = max(self._shape.size(), 1)
 *         if count_nonzero == 0:
 *             return (ndarray((0,), dtype=dtype),) * ndim             # <<<<<<<<<<<<<<
 * 
 *         dst = ndarray((count_nonzero * ndim,), dtype=dtype)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1064, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 1064, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_tuple__36, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1064, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1 * ((__pyx_v_ndim<0) ? 0:__pyx_v_ndim)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1064, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    { Py_ssize_t __pyx_temp;
      for (__pyx_temp=0; __pyx_temp < __pyx_v_ndim; __pyx_temp++) {
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_2, __pyx_temp, __pyx_t_4);
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1063
 *             count_nonzero = int(scan_index[-1])
 *         ndim = max(self._shape.size(), 1)
 *         if count_nonzero == 0:             # <<<<<<<<<<<<<<
 *             return (ndarray((0,), dtype=dtype),) * ndim
 * 
 */
  }

  /* "cupy/core/core.pyx":1066
 *             return (ndarray((0,), dtype=dtype),) * ndim
 * 
 *         dst = ndarray((count_nonzero * ndim,), dtype=dtype)             # <<<<<<<<<<<<<<
 *         if ndim <= 1:
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)
 */
  __pyx_t_2 = PyInt_FromSsize_t((__pyx_v_count_nonzero * __pyx_v_ndim)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1066, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1066, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1066, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1066, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 1066, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1066, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_dst = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":1067
 * 
 *         dst = ndarray((count_nonzero * ndim,), dtype=dtype)
 *         if ndim <= 1:             # <<<<<<<<<<<<<<
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)
 *             kern.linear_launch(self.size, (r, scan_index, dst))
 */
  __pyx_t_3 = ((__pyx_v_ndim <= 1) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":1068
 *         dst = ndarray((count_nonzero * ndim,), dtype=dtype)
 *         if ndim <= 1:
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)             # <<<<<<<<<<<<<<
 *             kern.linear_launch(self.size, (r, scan_index, dst))
 *             return dst,
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_nonzero_1d_kernel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1068, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_self->dtype, __pyx_v_dtype};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1068, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_self->dtype, __pyx_v_dtype};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1068, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1068, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_v_self->dtype);
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_10, __pyx_v_self->dtype);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_10, __pyx_v_dtype);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1068, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_kern = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1069
 *         if ndim <= 1:
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)
 *             kern.linear_launch(self.size, (r, scan_index, dst))             # <<<<<<<<<<<<<<
 *             return dst,
 *         else:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_kern, __pyx_n_s_linear_launch); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1069, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1069, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(!__pyx_v_r)) { __Pyx_RaiseUnboundLocalError("r"); __PYX_ERR(0, 1069, __pyx_L1_error) }
    if (unlikely(!__pyx_v_scan_index)) { __Pyx_RaiseUnboundLocalError("scan_index"); __PYX_ERR(0, 1069, __pyx_L1_error) }
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1069, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_r));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_r));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_scan_index));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_scan_index));
    PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_scan_index));
    __Pyx_INCREF(((PyObject *)__pyx_v_dst));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_dst));
    PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_dst));
    __pyx_t_11 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_1, __pyx_t_2};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1069, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_1, __pyx_t_2};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1069, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1069, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_11) {
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_10, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_10, __pyx_t_2);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1069, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1070
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)
 *             kern.linear_launch(self.size, (r, scan_index, dst))
 *             return dst,             # <<<<<<<<<<<<<<
 *         else:
 *             kern = _nonzero_kernel(self.dtype, ndim, dtype, dtype)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1070, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_v_dst));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_dst));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_dst));
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1067
 * 
 *         dst = ndarray((count_nonzero * ndim,), dtype=dtype)
 *         if ndim <= 1:             # <<<<<<<<<<<<<<
 *             kern = _nonzero_1d_kernel(self.dtype, dtype)
 *             kern.linear_launch(self.size, (r, scan_index, dst))
 */
  }

  /* "cupy/core/core.pyx":1072
 *             return dst,
 *         else:
 *             kern = _nonzero_kernel(self.dtype, ndim, dtype, dtype)             # <<<<<<<<<<<<<<
 *             kern.linear_launch(self.size,
 *                                (r, Indexer(self.shape), scan_index, dst))
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_nonzero_kernel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1072, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1072, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_2 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_2, __pyx_v_self->dtype, __pyx_t_12, __pyx_v_dtype, __pyx_v_dtype};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1072, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_2, __pyx_v_self->dtype, __pyx_t_12, __pyx_v_dtype, __pyx_v_dtype};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1072, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1072, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_INCREF(__pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_v_self->dtype);
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_10, __pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_10, __pyx_t_12);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_10, __pyx_v_dtype);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_10, __pyx_v_dtype);
      __pyx_t_12 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1072, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_kern = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1073
 *         else:
 *             kern = _nonzero_kernel(self.dtype, ndim, dtype, dtype)
 *             kern.linear_launch(self.size,             # <<<<<<<<<<<<<<
 *                                (r, Indexer(self.shape), scan_index, dst))
 *             return tuple([dst[i::ndim] for i in range(ndim)])
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_kern, __pyx_n_s_linear_launch); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1073, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1073, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "cupy/core/core.pyx":1074
 *             kern = _nonzero_kernel(self.dtype, ndim, dtype, dtype)
 *             kern.linear_launch(self.size,
 *                                (r, Indexer(self.shape), scan_index, dst))             # <<<<<<<<<<<<<<
 *             return tuple([dst[i::ndim] for i in range(ndim)])
 * 
 */
    if (unlikely(!__pyx_v_r)) { __Pyx_RaiseUnboundLocalError("r"); __PYX_ERR(0, 1074, __pyx_L1_error) }
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1074, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1074, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    if (unlikely(!__pyx_v_scan_index)) { __Pyx_RaiseUnboundLocalError("scan_index"); __PYX_ERR(0, 1074, __pyx_L1_error) }
    __pyx_t_12 = PyTuple_New(4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1074, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_INCREF(((PyObject *)__pyx_v_r));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_r));
    PyTuple_SET_ITEM(__pyx_t_12, 0, ((PyObject *)__pyx_v_r));
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_scan_index));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_scan_index));
    PyTuple_SET_ITEM(__pyx_t_12, 2, ((PyObject *)__pyx_v_scan_index));
    __Pyx_INCREF(((PyObject *)__pyx_v_dst));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_dst));
    PyTuple_SET_ITEM(__pyx_t_12, 3, ((PyObject *)__pyx_v_dst));
    __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_1, __pyx_t_12};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1073, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_1, __pyx_t_12};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1073, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1073, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_12);
      __pyx_t_1 = 0;
      __pyx_t_12 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1073, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1075
 *             kern.linear_launch(self.size,
 *                                (r, Indexer(self.shape), scan_index, dst))
 *             return tuple([dst[i::ndim] for i in range(ndim)])             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement compress
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1075, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __pyx_v_ndim;
    __pyx_t_13 = __pyx_t_6;
    for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
      __pyx_v_i = __pyx_t_14;
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1075, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1075, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = PySlice_New(__pyx_t_4, Py_None, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1075, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dst), __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1075, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 1075, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __pyx_t_11 = PyList_AsTuple(((PyObject*)__pyx_t_5)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1075, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_t_11;
    __pyx_t_11 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1041
 *     # TODO(okuta): Implement searchsorted
 * 
 *     def nonzero(self):             # <<<<<<<<<<<<<<
 *         """Return the indices of the elements that are non-zero.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core.ndarray.nonzero", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF((PyObject *)__pyx_v_r);
  __Pyx_XDECREF((PyObject *)__pyx_v_scan_index);
  __Pyx_XDECREF((PyObject *)__pyx_v_dst);
  __Pyx_XDECREF(__pyx_v_kern);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1079
 *     # TODO(okuta): Implement compress
 * 
 *     cpdef ndarray diagonal(self, offset=0, axis1=0, axis2=1):             # <<<<<<<<<<<<<<
 *         """Returns a view of the specified diagonals.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_51diagonal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_diagonal(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_diagonal *__pyx_optional_args) {
  PyObject *__pyx_v_offset = ((PyObject *)__pyx_int_0);
  PyObject *__pyx_v_axis1 = ((PyObject *)__pyx_int_0);
  PyObject *__pyx_v_axis2 = ((PyObject *)__pyx_int_1);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  struct __pyx_opt_args_4cupy_4core_4core__diagonal __pyx_t_10;
  __Pyx_RefNannySetupContext("diagonal", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_offset = __pyx_optional_args->offset;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_axis1 = __pyx_optional_args->axis1;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_axis2 = __pyx_optional_args->axis2;
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_diagonal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1079, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_51diagonal)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_offset, __pyx_v_axis1, __pyx_v_axis2};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1079, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_offset, __pyx_v_axis1, __pyx_v_axis2};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1079, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1079, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_offset);
        __Pyx_GIVEREF(__pyx_v_offset);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_offset);
        __Pyx_INCREF(__pyx_v_axis1);
        __Pyx_GIVEREF(__pyx_v_axis1);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_axis1);
        __Pyx_INCREF(__pyx_v_axis2);
        __Pyx_GIVEREF(__pyx_v_axis2);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_axis2);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1079, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1079, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1087
 * 
 *         """
 *         return _diagonal(self, offset, axis1, axis2)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_v_offset); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1087, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_v_axis1); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1087, __pyx_L1_error)
  __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_axis2); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1087, __pyx_L1_error)
  __pyx_t_10.__pyx_n = 3;
  __pyx_t_10.offset = __pyx_t_7;
  __pyx_t_10.axis1 = __pyx_t_8;
  __pyx_t_10.axis2 = __pyx_t_9;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__diagonal(__pyx_v_self, 0, &__pyx_t_10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1087, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1079
 *     # TODO(okuta): Implement compress
 * 
 *     cpdef ndarray diagonal(self, offset=0, axis1=0, axis2=1):             # <<<<<<<<<<<<<<
 *         """Returns a view of the specified diagonals.
 * 
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.diagonal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_51diagonal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_50diagonal[] = "ndarray.diagonal(self, offset=0, axis1=0, axis2=1) -> ndarray\nReturns a view of the specified diagonals.\n\n        .. seealso::\n           :func:`cupy.diagonal` for full documentation,\n           :meth:`numpy.ndarray.diagonal`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_51diagonal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_offset = 0;
  PyObject *__pyx_v_axis1 = 0;
  PyObject *__pyx_v_axis2 = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("diagonal (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_offset,&__pyx_n_s_axis1,&__pyx_n_s_axis2,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)__pyx_int_0);
    values[1] = ((PyObject *)__pyx_int_0);
    values[2] = ((PyObject *)__pyx_int_1);
    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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offset);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis1);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis2);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "diagonal") < 0)) __PYX_ERR(0, 1079, __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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_offset = values[0];
    __pyx_v_axis1 = values[1];
    __pyx_v_axis2 = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("diagonal", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1079, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.diagonal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_50diagonal(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_offset, __pyx_v_axis1, __pyx_v_axis2);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_50diagonal(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_offset, PyObject *__pyx_v_axis1, PyObject *__pyx_v_axis2) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_diagonal __pyx_t_2;
  __Pyx_RefNannySetupContext("diagonal", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.offset = __pyx_v_offset;
  __pyx_t_2.axis1 = __pyx_v_axis1;
  __pyx_t_2.axis2 = __pyx_v_axis2;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->diagonal(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1079, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.diagonal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1092
 *     # Calculation
 *     # -------------------------------------------------------------------------
 *     cpdef ndarray max(self, axis=None, out=None, dtype=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the maximum along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_53max(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_max(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_max *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("max", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_out = __pyx_optional_args->out;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_dtype = __pyx_optional_args->dtype;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_keepdims = __pyx_optional_args->keepdims;
          }
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_max); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1092, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_53max)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1092, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1092, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1092, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_axis);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_out);
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_dtype);
        __Pyx_INCREF(__pyx_v_keepdims);
        __Pyx_GIVEREF(__pyx_v_keepdims);
        PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_keepdims);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1092, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1092, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1100
 * 
 *         """
 *         return _amax(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_amax); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":1101
 *         """
 *         return _amax(
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray argmax(self, axis=None, out=None, dtype=None,
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1101, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1101, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 1101, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 1101, __pyx_L1_error)

  /* "cupy/core/core.pyx":1100
 * 
 *         """
 *         return _amax(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1100, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1092
 *     # Calculation
 *     # -------------------------------------------------------------------------
 *     cpdef ndarray max(self, axis=None, out=None, dtype=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the maximum along a given axis.
 * 
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.max", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_53max(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_52max[] = "ndarray.max(self, axis=None, out=None, dtype=None, keepdims=False) -> ndarray\nReturns the maximum along a given axis.\n\n        .. seealso::\n           :func:`cupy.amax` for full documentation,\n           :meth:`numpy.ndarray.max`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_53max(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("max (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_out,&__pyx_n_s_dtype,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "max") < 0)) __PYX_ERR(0, 1092, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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;
      }
    }
    __pyx_v_axis = values[0];
    __pyx_v_out = values[1];
    __pyx_v_dtype = values[2];
    __pyx_v_keepdims = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("max", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1092, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.max", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_52max(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_52max(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_dtype, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_max __pyx_t_2;
  __Pyx_RefNannySetupContext("max", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->max(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1092, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.max", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1103
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmax(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the maximum along a given axis.
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_55argmax(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_argmax(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmax *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);

  /* "cupy/core/core.pyx":1104
 * 
 *     cpdef ndarray argmax(self, axis=None, out=None, dtype=None,
 *                          keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the indices of the maximum along a given axis.
 * 
 */
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("argmax", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_out = __pyx_optional_args->out;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_dtype = __pyx_optional_args->dtype;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_keepdims = __pyx_optional_args->keepdims;
          }
        }
      }
    }
  }

  /* "cupy/core/core.pyx":1103
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmax(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the maximum along a given axis.
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_argmax); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1103, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_55argmax)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1103, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1103, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1103, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_axis);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_out);
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_dtype);
        __Pyx_INCREF(__pyx_v_keepdims);
        __Pyx_GIVEREF(__pyx_v_keepdims);
        PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_keepdims);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1103, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1103, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1112
 * 
 *         """
 *         return _argmax(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":1113
 *         """
 *         return _argmax(
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray min(self, axis=None, out=None, dtype=None, keepdims=False):
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1113, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1113, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 1113, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 1113, __pyx_L1_error)

  /* "cupy/core/core.pyx":1112
 * 
 *         """
 *         return _argmax(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__argmax, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1112, __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;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1112, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1103
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmax(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the maximum along a given axis.
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.argmax", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_55argmax(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_54argmax[] = "ndarray.argmax(self, axis=None, out=None, dtype=None, keepdims=False) -> ndarray\nReturns the indices of the maximum along a given axis.\n\n        .. seealso::\n           :func:`cupy.argmax` for full documentation,\n           :meth:`numpy.ndarray.argmax`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_55argmax(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argmax (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_out,&__pyx_n_s_dtype,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);

    /* "cupy/core/core.pyx":1104
 * 
 *     cpdef ndarray argmax(self, axis=None, out=None, dtype=None,
 *                          keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the indices of the maximum along a given axis.
 * 
 */
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "argmax") < 0)) __PYX_ERR(0, 1103, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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;
      }
    }
    __pyx_v_axis = values[0];
    __pyx_v_out = values[1];
    __pyx_v_dtype = values[2];
    __pyx_v_keepdims = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("argmax", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1103, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.argmax", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_54argmax(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims);

  /* "cupy/core/core.pyx":1103
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmax(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the maximum along a given axis.
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_54argmax(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_dtype, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmax __pyx_t_2;
  __Pyx_RefNannySetupContext("argmax", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->argmax(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1103, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.argmax", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1115
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray min(self, axis=None, out=None, dtype=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the minimum along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_57min(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_min(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_min *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("min", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_out = __pyx_optional_args->out;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_dtype = __pyx_optional_args->dtype;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_keepdims = __pyx_optional_args->keepdims;
          }
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_min); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1115, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_57min)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1115, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1115, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1115, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_axis);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_out);
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_dtype);
        __Pyx_INCREF(__pyx_v_keepdims);
        __Pyx_GIVEREF(__pyx_v_keepdims);
        PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_keepdims);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1115, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1115, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1123
 * 
 *         """
 *         return _amin(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_amin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":1124
 *         """
 *         return _amin(
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray argmin(self, axis=None, out=None, dtype=None,
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1124, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1124, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 1124, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 1124, __pyx_L1_error)

  /* "cupy/core/core.pyx":1123
 * 
 *         """
 *         return _amin(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1123, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1115
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray min(self, axis=None, out=None, dtype=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the minimum along a given axis.
 * 
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.min", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_57min(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_56min[] = "ndarray.min(self, axis=None, out=None, dtype=None, keepdims=False) -> ndarray\nReturns the minimum along a given axis.\n\n        .. seealso::\n           :func:`cupy.amin` for full documentation,\n           :meth:`numpy.ndarray.min`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_57min(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("min (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_out,&__pyx_n_s_dtype,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "min") < 0)) __PYX_ERR(0, 1115, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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;
      }
    }
    __pyx_v_axis = values[0];
    __pyx_v_out = values[1];
    __pyx_v_dtype = values[2];
    __pyx_v_keepdims = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("min", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1115, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.min", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_56min(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_56min(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_dtype, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_min __pyx_t_2;
  __Pyx_RefNannySetupContext("min", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->min(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.min", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1126
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmin(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the minimum along a given axis.
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_59argmin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_argmin(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmin *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);

  /* "cupy/core/core.pyx":1127
 * 
 *     cpdef ndarray argmin(self, axis=None, out=None, dtype=None,
 *                          keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the indices of the minimum along a given axis.
 * 
 */
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("argmin", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_out = __pyx_optional_args->out;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_dtype = __pyx_optional_args->dtype;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_keepdims = __pyx_optional_args->keepdims;
          }
        }
      }
    }
  }

  /* "cupy/core/core.pyx":1126
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmin(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the minimum along a given axis.
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_argmin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1126, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_59argmin)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1126, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1126, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1126, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_axis);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_out);
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_dtype);
        __Pyx_INCREF(__pyx_v_keepdims);
        __Pyx_GIVEREF(__pyx_v_keepdims);
        PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_keepdims);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1126, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1126, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1135
 * 
 *         """
 *         return _argmin(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":1136
 *         """
 *         return _argmin(
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement ptp
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1135, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1136, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1136, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 1136, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 1136, __pyx_L1_error)

  /* "cupy/core/core.pyx":1135
 * 
 *         """
 *         return _argmin(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__argmin, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1135, __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;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1135, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1126
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmin(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the minimum along a given axis.
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.argmin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_59argmin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_58argmin[] = "ndarray.argmin(self, axis=None, out=None, dtype=None, keepdims=False) -> ndarray\nReturns the indices of the minimum along a given axis.\n\n        .. seealso::\n           :func:`cupy.argmin` for full documentation,\n           :meth:`numpy.ndarray.argmin`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_59argmin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argmin (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_out,&__pyx_n_s_dtype,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);

    /* "cupy/core/core.pyx":1127
 * 
 *     cpdef ndarray argmin(self, axis=None, out=None, dtype=None,
 *                          keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the indices of the minimum along a given axis.
 * 
 */
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "argmin") < 0)) __PYX_ERR(0, 1126, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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;
      }
    }
    __pyx_v_axis = values[0];
    __pyx_v_out = values[1];
    __pyx_v_dtype = values[2];
    __pyx_v_keepdims = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("argmin", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1126, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.argmin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_58argmin(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims);

  /* "cupy/core/core.pyx":1126
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 *     cpdef ndarray argmin(self, axis=None, out=None, dtype=None,             # <<<<<<<<<<<<<<
 *                          keepdims=False):
 *         """Returns the indices of the minimum along a given axis.
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_58argmin(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_dtype, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmin __pyx_t_2;
  __Pyx_RefNannySetupContext("argmin", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->argmin(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.argmin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1140
 *     # TODO(okuta): Implement ptp
 * 
 *     cpdef ndarray clip(self, a_min=None, a_max=None, out=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with values limited to [a_min, a_max].
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_61clip(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_clip(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip *__pyx_optional_args) {
  PyObject *__pyx_v_a_min = ((PyObject *)Py_None);
  PyObject *__pyx_v_a_max = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("clip", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_a_min = __pyx_optional_args->a_min;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_a_max = __pyx_optional_args->a_max;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
        }
      }
    }
  }
  __Pyx_INCREF(__pyx_v_a_min);
  __Pyx_INCREF(__pyx_v_a_max);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clip); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1140, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_61clip)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_a_min, __pyx_v_a_max, __pyx_v_out};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1140, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_a_min, __pyx_v_a_max, __pyx_v_out};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1140, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1140, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_a_min);
        __Pyx_GIVEREF(__pyx_v_a_min);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_a_min);
        __Pyx_INCREF(__pyx_v_a_max);
        __Pyx_GIVEREF(__pyx_v_a_max);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_a_max);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_out);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1140, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1140, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1148
 * 
 *         """
 *         if a_min is None and a_max is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('array_clip: must set either max or min')
 *         if a_min is None:
 */
  __pyx_t_8 = (__pyx_v_a_min == Py_None);
  __pyx_t_9 = (__pyx_t_8 != 0);
  if (__pyx_t_9) {
  } else {
    __pyx_t_7 = __pyx_t_9;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_9 = (__pyx_v_a_max == Py_None);
  __pyx_t_8 = (__pyx_t_9 != 0);
  __pyx_t_7 = __pyx_t_8;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_7)) {

    /* "cupy/core/core.pyx":1149
 *         """
 *         if a_min is None and a_max is None:
 *             raise ValueError('array_clip: must set either max or min')             # <<<<<<<<<<<<<<
 *         if a_min is None:
 *             if issubclass(self.dtype.type, numpy.floating):
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1149, __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(0, 1149, __pyx_L1_error)

    /* "cupy/core/core.pyx":1148
 * 
 *         """
 *         if a_min is None and a_max is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('array_clip: must set either max or min')
 *         if a_min is None:
 */
  }

  /* "cupy/core/core.pyx":1150
 *         if a_min is None and a_max is None:
 *             raise ValueError('array_clip: must set either max or min')
 *         if a_min is None:             # <<<<<<<<<<<<<<
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_min = self.dtype.type('-inf')
 */
  __pyx_t_7 = (__pyx_v_a_min == Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1151
 *             raise ValueError('array_clip: must set either max or min')
 *         if a_min is None:
 *             if issubclass(self.dtype.type, numpy.floating):             # <<<<<<<<<<<<<<
 *                 a_min = self.dtype.type('-inf')
 *             elif issubclass(self.dtype.type, numpy.integer):
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1151, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1151, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_floating); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1151, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_8 = PyObject_IsSubclass(__pyx_t_1, __pyx_t_3); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1151, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = (__pyx_t_8 != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":1152
 *         if a_min is None:
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_min = self.dtype.type('-inf')             # <<<<<<<<<<<<<<
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_min = numpy.iinfo(self.dtype.type).min
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v_a_min, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":1151
 *             raise ValueError('array_clip: must set either max or min')
 *         if a_min is None:
 *             if issubclass(self.dtype.type, numpy.floating):             # <<<<<<<<<<<<<<
 *                 a_min = self.dtype.type('-inf')
 *             elif issubclass(self.dtype.type, numpy.integer):
 */
      goto __pyx_L7;
    }

    /* "cupy/core/core.pyx":1153
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_min = self.dtype.type('-inf')
 *             elif issubclass(self.dtype.type, numpy.integer):             # <<<<<<<<<<<<<<
 *                 a_min = numpy.iinfo(self.dtype.type).min
 *         if a_max is None:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_integer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = PyObject_IsSubclass(__pyx_t_1, __pyx_t_2); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 1153, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_8 = (__pyx_t_7 != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1154
 *                 a_min = self.dtype.type('-inf')
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_min = numpy.iinfo(self.dtype.type).min             # <<<<<<<<<<<<<<
 *         if a_max is None:
 *             if issubclass(self.dtype.type, numpy.floating):
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1154, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1154, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1154, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_6) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1154, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_1};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1154, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_1};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1154, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        {
          __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1154, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_1);
          __pyx_t_1 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1154, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_min); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1154, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_a_min, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":1153
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_min = self.dtype.type('-inf')
 *             elif issubclass(self.dtype.type, numpy.integer):             # <<<<<<<<<<<<<<
 *                 a_min = numpy.iinfo(self.dtype.type).min
 *         if a_max is None:
 */
    }
    __pyx_L7:;

    /* "cupy/core/core.pyx":1150
 *         if a_min is None and a_max is None:
 *             raise ValueError('array_clip: must set either max or min')
 *         if a_min is None:             # <<<<<<<<<<<<<<
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_min = self.dtype.type('-inf')
 */
  }

  /* "cupy/core/core.pyx":1155
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_min = numpy.iinfo(self.dtype.type).min
 *         if a_max is None:             # <<<<<<<<<<<<<<
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_max = self.dtype.type('inf')
 */
  __pyx_t_8 = (__pyx_v_a_max == Py_None);
  __pyx_t_7 = (__pyx_t_8 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":1156
 *                 a_min = numpy.iinfo(self.dtype.type).min
 *         if a_max is None:
 *             if issubclass(self.dtype.type, numpy.floating):             # <<<<<<<<<<<<<<
 *                 a_max = self.dtype.type('inf')
 *             elif issubclass(self.dtype.type, numpy.integer):
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_floating); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = PyObject_IsSubclass(__pyx_t_3, __pyx_t_4); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 1156, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = (__pyx_t_7 != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1157
 *         if a_max is None:
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_max = self.dtype.type('inf')             # <<<<<<<<<<<<<<
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_max = numpy.iinfo(self.dtype.type).max
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1157, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1157, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_a_max, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":1156
 *                 a_min = numpy.iinfo(self.dtype.type).min
 *         if a_max is None:
 *             if issubclass(self.dtype.type, numpy.floating):             # <<<<<<<<<<<<<<
 *                 a_max = self.dtype.type('inf')
 *             elif issubclass(self.dtype.type, numpy.integer):
 */
      goto __pyx_L9;
    }

    /* "cupy/core/core.pyx":1158
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_max = self.dtype.type('inf')
 *             elif issubclass(self.dtype.type, numpy.integer):             # <<<<<<<<<<<<<<
 *                 a_max = numpy.iinfo(self.dtype.type).max
 *         return _clip(self, a_min, a_max, out=out)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1158, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1158, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_integer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1158, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = PyObject_IsSubclass(__pyx_t_3, __pyx_t_2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1158, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = (__pyx_t_8 != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":1159
 *                 a_max = self.dtype.type('inf')
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_max = numpy.iinfo(self.dtype.type).max             # <<<<<<<<<<<<<<
 *         return _clip(self, a_min, a_max, out=out)
 * 
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1159, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1159, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1159, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_1) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1159, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1159, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1159, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1159, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1159, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_max); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1159, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_a_max, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1158
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_max = self.dtype.type('inf')
 *             elif issubclass(self.dtype.type, numpy.integer):             # <<<<<<<<<<<<<<
 *                 a_max = numpy.iinfo(self.dtype.type).max
 *         return _clip(self, a_min, a_max, out=out)
 */
    }
    __pyx_L9:;

    /* "cupy/core/core.pyx":1155
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_min = numpy.iinfo(self.dtype.type).min
 *         if a_max is None:             # <<<<<<<<<<<<<<
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_max = self.dtype.type('inf')
 */
  }

  /* "cupy/core/core.pyx":1160
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_max = numpy.iinfo(self.dtype.type).max
 *         return _clip(self, a_min, a_max, out=out)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement round
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_clip_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_INCREF(__pyx_v_a_min);
  __Pyx_GIVEREF(__pyx_v_a_min);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_a_min);
  __Pyx_INCREF(__pyx_v_a_max);
  __Pyx_GIVEREF(__pyx_v_a_max);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_a_max);
  __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1160, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1160, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1140
 *     # TODO(okuta): Implement ptp
 * 
 *     cpdef ndarray clip(self, a_min=None, a_max=None, out=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with values limited to [a_min, a_max].
 * 
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.clip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_a_min);
  __Pyx_XDECREF(__pyx_v_a_max);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_61clip(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_60clip[] = "ndarray.clip(self, a_min=None, a_max=None, out=None) -> ndarray\nReturns an array with values limited to [a_min, a_max].\n\n        .. seealso::\n           :func:`cupy.clip` for full documentation,\n           :meth:`numpy.ndarray.clip`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_61clip(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_a_min = 0;
  PyObject *__pyx_v_a_max = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clip (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a_min,&__pyx_n_s_a_max,&__pyx_n_s_out,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_a_min);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_a_max);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "clip") < 0)) __PYX_ERR(0, 1140, __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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a_min = values[0];
    __pyx_v_a_max = values[1];
    __pyx_v_out = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("clip", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1140, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.clip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_60clip(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_a_min, __pyx_v_a_max, __pyx_v_out);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_60clip(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_a_min, PyObject *__pyx_v_a_max, PyObject *__pyx_v_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip __pyx_t_2;
  __Pyx_RefNannySetupContext("clip", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.a_min = __pyx_v_a_min;
  __pyx_t_2.a_max = __pyx_v_a_max;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->clip(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.clip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1164
 *     # TODO(okuta): Implement round
 * 
 *     cpdef ndarray trace(self, offset=0, axis1=0, axis2=1, dtype=None,             # <<<<<<<<<<<<<<
 *                         out=None):
 *         """Returns the sum along diagonals of the array.
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_63trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_trace(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_trace *__pyx_optional_args) {
  PyObject *__pyx_v_offset = ((PyObject *)__pyx_int_0);
  PyObject *__pyx_v_axis1 = ((PyObject *)__pyx_int_0);
  PyObject *__pyx_v_axis2 = ((PyObject *)__pyx_int_1);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);

  /* "cupy/core/core.pyx":1165
 * 
 *     cpdef ndarray trace(self, offset=0, axis1=0, axis2=1, dtype=None,
 *                         out=None):             # <<<<<<<<<<<<<<
 *         """Returns the sum along diagonals of the array.
 * 
 */
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_d = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_diagonal __pyx_t_7;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum __pyx_t_8;
  __Pyx_RefNannySetupContext("trace", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_offset = __pyx_optional_args->offset;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_axis1 = __pyx_optional_args->axis1;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_axis2 = __pyx_optional_args->axis2;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_dtype = __pyx_optional_args->dtype;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_out = __pyx_optional_args->out;
            }
          }
        }
      }
    }
  }

  /* "cupy/core/core.pyx":1164
 *     # TODO(okuta): Implement round
 * 
 *     cpdef ndarray trace(self, offset=0, axis1=0, axis2=1, dtype=None,             # <<<<<<<<<<<<<<
 *                         out=None):
 *         """Returns the sum along diagonals of the array.
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_63trace)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_offset, __pyx_v_axis1, __pyx_v_axis2, __pyx_v_dtype, __pyx_v_out};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1164, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_offset, __pyx_v_axis1, __pyx_v_axis2, __pyx_v_dtype, __pyx_v_out};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1164, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1164, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_offset);
        __Pyx_GIVEREF(__pyx_v_offset);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_offset);
        __Pyx_INCREF(__pyx_v_axis1);
        __Pyx_GIVEREF(__pyx_v_axis1);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_axis1);
        __Pyx_INCREF(__pyx_v_axis2);
        __Pyx_GIVEREF(__pyx_v_axis2);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_axis2);
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_dtype);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_v_out);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1164, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1164, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1173
 * 
 *         """
 *         d = self.diagonal(offset, axis1, axis2)             # <<<<<<<<<<<<<<
 *         return d.sum(-1, dtype, out, False)
 * 
 */
  __pyx_t_7.__pyx_n = 3;
  __pyx_t_7.offset = __pyx_v_offset;
  __pyx_t_7.axis1 = __pyx_v_axis1;
  __pyx_t_7.axis2 = __pyx_v_axis2;
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->diagonal(__pyx_v_self, 0, &__pyx_t_7)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_d = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1174
 *         """
 *         d = self.diagonal(offset, axis1, axis2)
 *         return d.sum(-1, dtype, out, False)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray sum(self, axis=None, dtype=None, out=None, keepdims=False):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_8.__pyx_n = 4;
  __pyx_t_8.axis = __pyx_int_neg_1;
  __pyx_t_8.dtype = __pyx_v_dtype;
  __pyx_t_8.out = __pyx_v_out;
  __pyx_t_8.keepdims = Py_False;
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_d->__pyx_vtab)->sum(__pyx_v_d, 0, &__pyx_t_8)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1164
 *     # TODO(okuta): Implement round
 * 
 *     cpdef ndarray trace(self, offset=0, axis1=0, axis2=1, dtype=None,             # <<<<<<<<<<<<<<
 *                         out=None):
 *         """Returns the sum along diagonals of the array.
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.trace", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_d);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_63trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_62trace[] = "ndarray.trace(self, offset=0, axis1=0, axis2=1, dtype=None, out=None) -> ndarray\nReturns the sum along diagonals of the array.\n\n        .. seealso::\n           :func:`cupy.trace` for full documentation,\n           :meth:`numpy.ndarray.trace`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_63trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_offset = 0;
  PyObject *__pyx_v_axis1 = 0;
  PyObject *__pyx_v_axis2 = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("trace (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_offset,&__pyx_n_s_axis1,&__pyx_n_s_axis2,&__pyx_n_s_dtype,&__pyx_n_s_out,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[0] = ((PyObject *)__pyx_int_0);
    values[1] = ((PyObject *)__pyx_int_0);
    values[2] = ((PyObject *)__pyx_int_1);
    values[3] = ((PyObject *)Py_None);

    /* "cupy/core/core.pyx":1165
 * 
 *     cpdef ndarray trace(self, offset=0, axis1=0, axis2=1, dtype=None,
 *                         out=None):             # <<<<<<<<<<<<<<
 *         """Returns the sum along diagonals of the array.
 * 
 */
    values[4] = ((PyObject *)Py_None);
    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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offset);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis1);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis2);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          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_out);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "trace") < 0)) __PYX_ERR(0, 1164, __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);
        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;
      }
    }
    __pyx_v_offset = values[0];
    __pyx_v_axis1 = values[1];
    __pyx_v_axis2 = values[2];
    __pyx_v_dtype = values[3];
    __pyx_v_out = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("trace", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1164, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.trace", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_62trace(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_offset, __pyx_v_axis1, __pyx_v_axis2, __pyx_v_dtype, __pyx_v_out);

  /* "cupy/core/core.pyx":1164
 *     # TODO(okuta): Implement round
 * 
 *     cpdef ndarray trace(self, offset=0, axis1=0, axis2=1, dtype=None,             # <<<<<<<<<<<<<<
 *                         out=None):
 *         """Returns the sum along diagonals of the array.
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_62trace(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_offset, PyObject *__pyx_v_axis1, PyObject *__pyx_v_axis2, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_trace __pyx_t_2;
  __Pyx_RefNannySetupContext("trace", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 5;
  __pyx_t_2.offset = __pyx_v_offset;
  __pyx_t_2.axis1 = __pyx_v_axis1;
  __pyx_t_2.axis2 = __pyx_v_axis2;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->trace(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.trace", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1176
 *         return d.sum(-1, dtype, out, False)
 * 
 *     cpdef ndarray sum(self, axis=None, dtype=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the sum along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_65sum(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_sum(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("sum", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_dtype = __pyx_optional_args->dtype;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_keepdims = __pyx_optional_args->keepdims;
          }
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_sum); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1176, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_65sum)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1176, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1176, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1176, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_axis);
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_dtype);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_out);
        __Pyx_INCREF(__pyx_v_keepdims);
        __Pyx_GIVEREF(__pyx_v_keepdims);
        PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_keepdims);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1176, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1176, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1184
 * 
 *         """
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             return _sum_auto_dtype(self, axis, dtype, out, keepdims)
 *         else:
 */
  __pyx_t_7 = (__pyx_v_dtype == Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1185
 *         """
 *         if dtype is None:
 *             return _sum_auto_dtype(self, axis, dtype, out, keepdims)             # <<<<<<<<<<<<<<
 *         else:
 *             return _sum_keep_dtype(self, axis, dtype, out, keepdims)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_sum_auto_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1185, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(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_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[6] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1185, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[6] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1185, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_axis);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_dtype);
      __Pyx_INCREF(__pyx_v_out);
      __Pyx_GIVEREF(__pyx_v_out);
      PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_out);
      __Pyx_INCREF(__pyx_v_keepdims);
      __Pyx_GIVEREF(__pyx_v_keepdims);
      PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_v_keepdims);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1185, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1184
 * 
 *         """
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             return _sum_auto_dtype(self, axis, dtype, out, keepdims)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1187
 *             return _sum_auto_dtype(self, axis, dtype, out, keepdims)
 *         else:
 *             return _sum_keep_dtype(self, axis, dtype, out, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement cumsum
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_sum_keep_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1187, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[6] = {__pyx_t_6, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1187, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[6] = {__pyx_t_6, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1187, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1187, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_5, __pyx_v_axis);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_5, __pyx_v_dtype);
      __Pyx_INCREF(__pyx_v_out);
      __Pyx_GIVEREF(__pyx_v_out);
      PyTuple_SET_ITEM(__pyx_t_3, 3+__pyx_t_5, __pyx_v_out);
      __Pyx_INCREF(__pyx_v_keepdims);
      __Pyx_GIVEREF(__pyx_v_keepdims);
      PyTuple_SET_ITEM(__pyx_t_3, 4+__pyx_t_5, __pyx_v_keepdims);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1187, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1187, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1176
 *         return d.sum(-1, dtype, out, False)
 * 
 *     cpdef ndarray sum(self, axis=None, dtype=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the sum along a given axis.
 * 
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.sum", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_65sum(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_64sum[] = "ndarray.sum(self, axis=None, dtype=None, out=None, keepdims=False) -> ndarray\nReturns the sum along a given axis.\n\n        .. seealso::\n           :func:`cupy.sum` for full documentation,\n           :meth:`numpy.ndarray.sum`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_65sum(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sum (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sum") < 0)) __PYX_ERR(0, 1176, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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;
      }
    }
    __pyx_v_axis = values[0];
    __pyx_v_dtype = values[1];
    __pyx_v_out = values[2];
    __pyx_v_keepdims = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sum", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1176, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.sum", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_64sum(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_64sum(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum __pyx_t_2;
  __Pyx_RefNannySetupContext("sum", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->sum(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1176, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.sum", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1191
 *     # TODO(okuta): Implement cumsum
 * 
 *     cpdef ndarray mean(self, axis=None, dtype=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the mean along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_67mean(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_mean(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_mean *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("mean", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_dtype = __pyx_optional_args->dtype;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_keepdims = __pyx_optional_args->keepdims;
          }
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_mean); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1191, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_67mean)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1191, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1191, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1191, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_axis);
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_dtype);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_out);
        __Pyx_INCREF(__pyx_v_keepdims);
        __Pyx_GIVEREF(__pyx_v_keepdims);
        PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_keepdims);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1191, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1191, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1199
 * 
 *         """
 *         return _mean(self, axis=axis, dtype=dtype, out=out, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray var(self, axis=None, dtype=None, out=None, ddof=0,
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1199, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 1199, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1199, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 1199, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__mean, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1199, __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;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1199, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1191
 *     # TODO(okuta): Implement cumsum
 * 
 *     cpdef ndarray mean(self, axis=None, dtype=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the mean along a given axis.
 * 
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.mean", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_67mean(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_66mean[] = "ndarray.mean(self, axis=None, dtype=None, out=None, keepdims=False) -> ndarray\nReturns the mean along a given axis.\n\n        .. seealso::\n           :func:`cupy.mean` for full documentation,\n           :meth:`numpy.ndarray.mean`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_67mean(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("mean (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "mean") < 0)) __PYX_ERR(0, 1191, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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;
      }
    }
    __pyx_v_axis = values[0];
    __pyx_v_dtype = values[1];
    __pyx_v_out = values[2];
    __pyx_v_keepdims = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("mean", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1191, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.mean", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_66mean(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_66mean(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_mean __pyx_t_2;
  __Pyx_RefNannySetupContext("mean", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->mean(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.mean", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1201
 *         return _mean(self, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
 * 
 *     cpdef ndarray var(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the variance along a given axis.
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_69var(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_var(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_var *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_ddof = ((PyObject *)__pyx_int_0);

  /* "cupy/core/core.pyx":1202
 * 
 *     cpdef ndarray var(self, axis=None, dtype=None, out=None, ddof=0,
 *                       keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the variance along a given axis.
 * 
 */
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__var __pyx_t_7;
  __Pyx_RefNannySetupContext("var", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_dtype = __pyx_optional_args->dtype;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_ddof = __pyx_optional_args->ddof;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_keepdims = __pyx_optional_args->keepdims;
            }
          }
        }
      }
    }
  }

  /* "cupy/core/core.pyx":1201
 *         return _mean(self, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
 * 
 *     cpdef ndarray var(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the variance along a given axis.
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_var); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_69var)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1201, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1201, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1201, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_axis);
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_dtype);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_out);
        __Pyx_INCREF(__pyx_v_ddof);
        __Pyx_GIVEREF(__pyx_v_ddof);
        PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_ddof);
        __Pyx_INCREF(__pyx_v_keepdims);
        __Pyx_GIVEREF(__pyx_v_keepdims);
        PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_v_keepdims);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1201, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1201, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1210
 * 
 *         """
 *         return _var(self, axis=axis, dtype=dtype, out=out, ddof=ddof,             # <<<<<<<<<<<<<<
 *                     keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":1211
 *         """
 *         return _var(self, axis=axis, dtype=dtype, out=out, ddof=ddof,
 *                     keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,
 */
  __pyx_t_7.__pyx_n = 5;
  __pyx_t_7.axis = __pyx_v_axis;
  __pyx_t_7.dtype = __pyx_v_dtype;
  __pyx_t_7.out = __pyx_v_out;
  __pyx_t_7.ddof = __pyx_v_ddof;
  __pyx_t_7.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__var(__pyx_v_self, 0, &__pyx_t_7)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1210, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1201
 *         return _mean(self, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
 * 
 *     cpdef ndarray var(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the variance along a given axis.
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_69var(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_68var[] = "ndarray.var(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False) -> ndarray\nReturns the variance along a given axis.\n\n        .. seealso::\n           :func:`cupy.var` for full documentation,\n           :meth:`numpy.ndarray.var`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_69var(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_ddof = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("var (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_ddof,&__pyx_n_s_keepdims,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)__pyx_int_0);

    /* "cupy/core/core.pyx":1202
 * 
 *     cpdef ndarray var(self, axis=None, dtype=None, out=None, ddof=0,
 *                       keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the variance along a given axis.
 * 
 */
    values[4] = ((PyObject *)Py_False);
    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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ddof);
          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_keepdims);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "var") < 0)) __PYX_ERR(0, 1201, __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);
        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;
      }
    }
    __pyx_v_axis = values[0];
    __pyx_v_dtype = values[1];
    __pyx_v_out = values[2];
    __pyx_v_ddof = values[3];
    __pyx_v_keepdims = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("var", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1201, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_68var(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims);

  /* "cupy/core/core.pyx":1201
 *         return _mean(self, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
 * 
 *     cpdef ndarray var(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the variance along a given axis.
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_68var(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_ddof, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_var __pyx_t_2;
  __Pyx_RefNannySetupContext("var", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 5;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.ddof = __pyx_v_ddof;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->var(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1213
 *                     keepdims=keepdims)
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the standard deviation along a given axis.
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_71std(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_std(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_std *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_ddof = ((PyObject *)__pyx_int_0);

  /* "cupy/core/core.pyx":1214
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,
 *                       keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the standard deviation along a given axis.
 * 
 */
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__std __pyx_t_7;
  __Pyx_RefNannySetupContext("std", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_dtype = __pyx_optional_args->dtype;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_ddof = __pyx_optional_args->ddof;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_keepdims = __pyx_optional_args->keepdims;
            }
          }
        }
      }
    }
  }

  /* "cupy/core/core.pyx":1213
 *                     keepdims=keepdims)
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the standard deviation along a given axis.
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_std); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1213, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_71std)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1213, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1213, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1213, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_axis);
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_dtype);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_out);
        __Pyx_INCREF(__pyx_v_ddof);
        __Pyx_GIVEREF(__pyx_v_ddof);
        PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_ddof);
        __Pyx_INCREF(__pyx_v_keepdims);
        __Pyx_GIVEREF(__pyx_v_keepdims);
        PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_v_keepdims);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1213, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1213, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1222
 * 
 *         """
 *         return _std(self, axis=axis, dtype=dtype, out=out, ddof=ddof,             # <<<<<<<<<<<<<<
 *                     keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":1223
 *         """
 *         return _std(self, axis=axis, dtype=dtype, out=out, ddof=ddof,
 *                     keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray prod(self, axis=None, dtype=None, out=None, keepdims=None):
 */
  __pyx_t_7.__pyx_n = 5;
  __pyx_t_7.axis = __pyx_v_axis;
  __pyx_t_7.dtype = __pyx_v_dtype;
  __pyx_t_7.out = __pyx_v_out;
  __pyx_t_7.ddof = __pyx_v_ddof;
  __pyx_t_7.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__std(((PyObject *)__pyx_v_self), 0, &__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":1222
 * 
 *         """
 *         return _std(self, axis=axis, dtype=dtype, out=out, ddof=ddof,             # <<<<<<<<<<<<<<
 *                     keepdims=keepdims)
 * 
 */
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1222, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1213
 *                     keepdims=keepdims)
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the standard deviation along a given axis.
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.std", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_71std(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_70std[] = "ndarray.std(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False) -> ndarray\nReturns the standard deviation along a given axis.\n\n        .. seealso::\n           :func:`cupy.std` for full documentation,\n           :meth:`numpy.ndarray.std`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_71std(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_ddof = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("std (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_ddof,&__pyx_n_s_keepdims,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)__pyx_int_0);

    /* "cupy/core/core.pyx":1214
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,
 *                       keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the standard deviation along a given axis.
 * 
 */
    values[4] = ((PyObject *)Py_False);
    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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ddof);
          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_keepdims);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "std") < 0)) __PYX_ERR(0, 1213, __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);
        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;
      }
    }
    __pyx_v_axis = values[0];
    __pyx_v_dtype = values[1];
    __pyx_v_out = values[2];
    __pyx_v_ddof = values[3];
    __pyx_v_keepdims = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("std", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1213, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.std", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_70std(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims);

  /* "cupy/core/core.pyx":1213
 *                     keepdims=keepdims)
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                       keepdims=False):
 *         """Returns the standard deviation along a given axis.
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_70std(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_ddof, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_std __pyx_t_2;
  __Pyx_RefNannySetupContext("std", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 5;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.ddof = __pyx_v_ddof;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->std(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.std", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1225
 *                     keepdims=keepdims)
 * 
 *     cpdef ndarray prod(self, axis=None, dtype=None, out=None, keepdims=None):             # <<<<<<<<<<<<<<
 *         """Returns the product along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_73prod(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_prod(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("prod", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_dtype = __pyx_optional_args->dtype;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_keepdims = __pyx_optional_args->keepdims;
          }
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_prod); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_73prod)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1225, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1225, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1225, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_axis);
        __Pyx_INCREF(__pyx_v_dtype);
        __Pyx_GIVEREF(__pyx_v_dtype);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_dtype);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_out);
        __Pyx_INCREF(__pyx_v_keepdims);
        __Pyx_GIVEREF(__pyx_v_keepdims);
        PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_keepdims);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1225, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1225, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1233
 * 
 *         """
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             return _prod_auto_dtype(self, axis, dtype, out, keepdims)
 *         else:
 */
  __pyx_t_7 = (__pyx_v_dtype == Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1234
 *         """
 *         if dtype is None:
 *             return _prod_auto_dtype(self, axis, dtype, out, keepdims)             # <<<<<<<<<<<<<<
 *         else:
 *             return _prod_keep_dtype(self, axis, dtype, out, keepdims)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_prod_auto_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(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_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[6] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1234, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[6] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1234, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1234, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_axis);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_dtype);
      __Pyx_INCREF(__pyx_v_out);
      __Pyx_GIVEREF(__pyx_v_out);
      PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_out);
      __Pyx_INCREF(__pyx_v_keepdims);
      __Pyx_GIVEREF(__pyx_v_keepdims);
      PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_v_keepdims);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1234, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1234, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1233
 * 
 *         """
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             return _prod_auto_dtype(self, axis, dtype, out, keepdims)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1236
 *             return _prod_auto_dtype(self, axis, dtype, out, keepdims)
 *         else:
 *             return _prod_keep_dtype(self, axis, dtype, out, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement cumprod
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_prod_keep_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1236, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[6] = {__pyx_t_6, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1236, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[6] = {__pyx_t_6, ((PyObject *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1236, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1236, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_5, __pyx_v_axis);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_5, __pyx_v_dtype);
      __Pyx_INCREF(__pyx_v_out);
      __Pyx_GIVEREF(__pyx_v_out);
      PyTuple_SET_ITEM(__pyx_t_3, 3+__pyx_t_5, __pyx_v_out);
      __Pyx_INCREF(__pyx_v_keepdims);
      __Pyx_GIVEREF(__pyx_v_keepdims);
      PyTuple_SET_ITEM(__pyx_t_3, 4+__pyx_t_5, __pyx_v_keepdims);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1236, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1236, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1225
 *                     keepdims=keepdims)
 * 
 *     cpdef ndarray prod(self, axis=None, dtype=None, out=None, keepdims=None):             # <<<<<<<<<<<<<<
 *         """Returns the product along a given axis.
 * 
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.prod", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_73prod(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_72prod[] = "ndarray.prod(self, axis=None, dtype=None, out=None, keepdims=None) -> ndarray\nReturns the product along a given axis.\n\n        .. seealso::\n           :func:`cupy.prod` for full documentation,\n           :meth:`numpy.ndarray.prod`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_73prod(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("prod (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "prod") < 0)) __PYX_ERR(0, 1225, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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;
      }
    }
    __pyx_v_axis = values[0];
    __pyx_v_dtype = values[1];
    __pyx_v_out = values[2];
    __pyx_v_keepdims = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("prod", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1225, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.prod", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_72prod(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_72prod(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod __pyx_t_2;
  __Pyx_RefNannySetupContext("prod", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->prod(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1225, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.prod", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1240
 *     # TODO(okuta): Implement cumprod
 * 
 *     cpdef ndarray all(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         return _all(self, axis=axis, out=out, keepdims=keepdims)
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_75all(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_all(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_all *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("all", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_out = __pyx_optional_args->out;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_keepdims = __pyx_optional_args->keepdims;
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1240, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_75all)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1240, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1240, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1240, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_axis);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_out);
        __Pyx_INCREF(__pyx_v_keepdims);
        __Pyx_GIVEREF(__pyx_v_keepdims);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_keepdims);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1240, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1240, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1241
 * 
 *     cpdef ndarray all(self, axis=None, out=None, keepdims=False):
 *         return _all(self, axis=axis, out=out, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray any(self, axis=None, out=None, keepdims=False):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_all_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1241, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1241, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 1241, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1241, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1240
 *     # TODO(okuta): Implement cumprod
 * 
 *     cpdef ndarray all(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         return _all(self, axis=axis, out=out, keepdims=keepdims)
 * 
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.all", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_75all(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_74all[] = "ndarray.all(self, axis=None, out=None, keepdims=False) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_75all(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("all (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_out,&__pyx_n_s_keepdims,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_False);
    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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "all") < 0)) __PYX_ERR(0, 1240, __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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_axis = values[0];
    __pyx_v_out = values[1];
    __pyx_v_keepdims = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("all", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1240, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.all", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_74all(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_out, __pyx_v_keepdims);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_74all(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_all __pyx_t_2;
  __Pyx_RefNannySetupContext("all", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->all(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.all", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1243
 *         return _all(self, axis=axis, out=out, keepdims=keepdims)
 * 
 *     cpdef ndarray any(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         return _any(self, axis=axis, out=out, keepdims=keepdims)
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_77any(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_any(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("any", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_out = __pyx_optional_args->out;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_keepdims = __pyx_optional_args->keepdims;
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_any); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1243, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_77any)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1243, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_axis, __pyx_v_out, __pyx_v_keepdims};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1243, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1243, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_axis);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_out);
        __Pyx_INCREF(__pyx_v_keepdims);
        __Pyx_GIVEREF(__pyx_v_keepdims);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_keepdims);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1243, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1243, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1244
 * 
 *     cpdef ndarray any(self, axis=None, out=None, keepdims=False):
 *         return _any(self, axis=axis, out=out, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_any_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 1244, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 1244, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 1244, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1244, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1243
 *         return _all(self, axis=axis, out=out, keepdims=keepdims)
 * 
 *     cpdef ndarray any(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         return _any(self, axis=axis, out=out, keepdims=keepdims)
 * 
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.any", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_77any(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_76any[] = "ndarray.any(self, axis=None, out=None, keepdims=False) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_77any(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("any (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_out,&__pyx_n_s_keepdims,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_False);
    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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "any") < 0)) __PYX_ERR(0, 1243, __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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_axis = values[0];
    __pyx_v_out = values[1];
    __pyx_v_keepdims = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("any", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1243, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.any", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_76any(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_out, __pyx_v_keepdims);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_76any(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_out, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any __pyx_t_2;
  __Pyx_RefNannySetupContext("any", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->any(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1243, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.any", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1251
 *     # Comparison operators:
 * 
 *     def __richcmp__(object self, object other, int op):             # <<<<<<<<<<<<<<
 *         if op == 0:
 *             return less(self, other)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_79__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_79__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_78__richcmp__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other), ((int)__pyx_v_op));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_78__richcmp__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__richcmp__", 0);

  /* "cupy/core/core.pyx":1252
 * 
 *     def __richcmp__(object self, object other, int op):
 *         if op == 0:             # <<<<<<<<<<<<<<
 *             return less(self, other)
 *         if op == 1:
 */
  __pyx_t_1 = ((__pyx_v_op == 0) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1253
 *     def __richcmp__(object self, object other, int op):
 *         if op == 0:
 *             return less(self, other)             # <<<<<<<<<<<<<<
 *         if op == 1:
 *             return less_equal(self, other)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_less); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1253, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    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_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1253, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1253, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1253, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1253, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1252
 * 
 *     def __richcmp__(object self, object other, int op):
 *         if op == 0:             # <<<<<<<<<<<<<<
 *             return less(self, other)
 *         if op == 1:
 */
  }

  /* "cupy/core/core.pyx":1254
 *         if op == 0:
 *             return less(self, other)
 *         if op == 1:             # <<<<<<<<<<<<<<
 *             return less_equal(self, other)
 *         if op == 2:
 */
  __pyx_t_1 = ((__pyx_v_op == 1) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1255
 *             return less(self, other)
 *         if op == 1:
 *             return less_equal(self, other)             # <<<<<<<<<<<<<<
 *         if op == 2:
 *             return equal(self, other)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_less_equal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1255, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1255, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1255, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1255, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1255, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1254
 *         if op == 0:
 *             return less(self, other)
 *         if op == 1:             # <<<<<<<<<<<<<<
 *             return less_equal(self, other)
 *         if op == 2:
 */
  }

  /* "cupy/core/core.pyx":1256
 *         if op == 1:
 *             return less_equal(self, other)
 *         if op == 2:             # <<<<<<<<<<<<<<
 *             return equal(self, other)
 *         if op == 3:
 */
  __pyx_t_1 = ((__pyx_v_op == 2) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1257
 *             return less_equal(self, other)
 *         if op == 2:
 *             return equal(self, other)             # <<<<<<<<<<<<<<
 *         if op == 3:
 *             return not_equal(self, other)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_equal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1257, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    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_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1257, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1257, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1257, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1257, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1256
 *         if op == 1:
 *             return less_equal(self, other)
 *         if op == 2:             # <<<<<<<<<<<<<<
 *             return equal(self, other)
 *         if op == 3:
 */
  }

  /* "cupy/core/core.pyx":1258
 *         if op == 2:
 *             return equal(self, other)
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             return not_equal(self, other)
 *         if op == 4:
 */
  __pyx_t_1 = ((__pyx_v_op == 3) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1259
 *             return equal(self, other)
 *         if op == 3:
 *             return not_equal(self, other)             # <<<<<<<<<<<<<<
 *         if op == 4:
 *             return greater(self, other)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_not_equal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1259, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1259, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1259, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1259, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1259, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1258
 *         if op == 2:
 *             return equal(self, other)
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             return not_equal(self, other)
 *         if op == 4:
 */
  }

  /* "cupy/core/core.pyx":1260
 *         if op == 3:
 *             return not_equal(self, other)
 *         if op == 4:             # <<<<<<<<<<<<<<
 *             return greater(self, other)
 *         if op == 5:
 */
  __pyx_t_1 = ((__pyx_v_op == 4) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1261
 *             return not_equal(self, other)
 *         if op == 4:
 *             return greater(self, other)             # <<<<<<<<<<<<<<
 *         if op == 5:
 *             return greater_equal(self, other)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_greater); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1261, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    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_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1261, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1261, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1261, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1261, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1260
 *         if op == 3:
 *             return not_equal(self, other)
 *         if op == 4:             # <<<<<<<<<<<<<<
 *             return greater(self, other)
 *         if op == 5:
 */
  }

  /* "cupy/core/core.pyx":1262
 *         if op == 4:
 *             return greater(self, other)
 *         if op == 5:             # <<<<<<<<<<<<<<
 *             return greater_equal(self, other)
 *         return NotImplemented
 */
  __pyx_t_1 = ((__pyx_v_op == 5) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1263
 *             return greater(self, other)
 *         if op == 5:
 *             return greater_equal(self, other)             # <<<<<<<<<<<<<<
 *         return NotImplemented
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_greater_equal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1263, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1263, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1263, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1263, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1262
 *         if op == 4:
 *             return greater(self, other)
 *         if op == 5:             # <<<<<<<<<<<<<<
 *             return greater_equal(self, other)
 *         return NotImplemented
 */
  }

  /* "cupy/core/core.pyx":1264
 *         if op == 5:
 *             return greater_equal(self, other)
 *         return NotImplemented             # <<<<<<<<<<<<<<
 * 
 *     # Truth value of an array (bool):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_builtin_NotImplemented);
  __pyx_r = __pyx_builtin_NotImplemented;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1251
 *     # Comparison operators:
 * 
 *     def __richcmp__(object self, object other, int op):             # <<<<<<<<<<<<<<
 *         if op == 0:
 *             return less(self, other)
 */

  /* 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_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1268
 *     # Truth value of an array (bool):
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         if self.size == 0:
 *             return False
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_81__nonzero__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_81__nonzero__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__nonzero__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_80__nonzero__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_7ndarray_80__nonzero__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_v_msg = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__nonzero__", 0);

  /* "cupy/core/core.pyx":1269
 * 
 *     def __nonzero__(self):
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return False
 *         elif self.size == 1:
 */
  switch (__pyx_v_self->size) {
    case 0:

    /* "cupy/core/core.pyx":1270
 *     def __nonzero__(self):
 *         if self.size == 0:
 *             return False             # <<<<<<<<<<<<<<
 *         elif self.size == 1:
 *             return bool(self.get())
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1269
 * 
 *     def __nonzero__(self):
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return False
 *         elif self.size == 1:
 */
    break;

    /* "cupy/core/core.pyx":1271
 *         if self.size == 0:
 *             return False
 *         elif self.size == 1:             # <<<<<<<<<<<<<<
 *             return bool(self.get())
 *         else:
 */
    case 1:

    /* "cupy/core/core.pyx":1272
 *             return False
 *         elif self.size == 1:
 *             return bool(self.get())             # <<<<<<<<<<<<<<
 *         else:
 *             msg = ('The truth value of an array with more than one element is '
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1272, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = (!(!__pyx_t_2));
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1271
 *         if self.size == 0:
 *             return False
 *         elif self.size == 1:             # <<<<<<<<<<<<<<
 *             return bool(self.get())
 *         else:
 */
    break;
    default:

    /* "cupy/core/core.pyx":1274
 *             return bool(self.get())
 *         else:
 *             msg = ('The truth value of an array with more than one element is '             # <<<<<<<<<<<<<<
 *                    'ambiguous. Use a.any() or a.all()')
 *             raise ValueError(msg)
 */
    __Pyx_INCREF(__pyx_kp_s_The_truth_value_of_an_array_with);
    __pyx_v_msg = __pyx_kp_s_The_truth_value_of_an_array_with;

    /* "cupy/core/core.pyx":1276
 *             msg = ('The truth value of an array with more than one element is '
 *                    'ambiguous. Use a.any() or a.all()')
 *             raise ValueError(msg)             # <<<<<<<<<<<<<<
 * 
 *     # Unary operations:
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_v_msg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1276, __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(0, 1276, __pyx_L1_error)
    break;
  }

  /* "cupy/core/core.pyx":1268
 *     # Truth value of an array (bool):
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         if self.size == 0:
 *             return False
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__nonzero__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1280
 *     # Unary operations:
 * 
 *     def __neg__(self):             # <<<<<<<<<<<<<<
 *         return negative(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_83__neg__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_83__neg__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__neg__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_82__neg__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_82__neg__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  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;
  __Pyx_RefNannySetupContext("__neg__", 0);

  /* "cupy/core/core.pyx":1281
 * 
 *     def __neg__(self):
 *         return negative(self)             # <<<<<<<<<<<<<<
 * 
 *     def __pos__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_negative); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1281, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(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);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1281, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1281, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1281, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1281, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1280
 *     # Unary operations:
 * 
 *     def __neg__(self):             # <<<<<<<<<<<<<<
 *         return negative(self)
 * 
 */

  /* 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("cupy.core.core.ndarray.__neg__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1283
 *         return negative(self)
 * 
 *     def __pos__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_85__pos__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_85__pos__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pos__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_84__pos__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_84__pos__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pos__", 0);

  /* "cupy/core/core.pyx":1284
 * 
 *     def __pos__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __abs__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1283
 *         return negative(self)
 * 
 *     def __pos__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1286
 *         return self
 * 
 *     def __abs__(self):             # <<<<<<<<<<<<<<
 *         return absolute(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_87__abs__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_87__abs__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__abs__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_86__abs__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_86__abs__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  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;
  __Pyx_RefNannySetupContext("__abs__", 0);

  /* "cupy/core/core.pyx":1287
 * 
 *     def __abs__(self):
 *         return absolute(self)             # <<<<<<<<<<<<<<
 * 
 *     def __invert__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_absolute); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(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);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1287, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1287, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1287, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1287, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1287, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1286
 *         return self
 * 
 *     def __abs__(self):             # <<<<<<<<<<<<<<
 *         return absolute(self)
 * 
 */

  /* 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("cupy.core.core.ndarray.__abs__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1289
 *         return absolute(self)
 * 
 *     def __invert__(self):             # <<<<<<<<<<<<<<
 *         return invert(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_89__invert__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_89__invert__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__invert__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_88__invert__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_88__invert__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  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;
  __Pyx_RefNannySetupContext("__invert__", 0);

  /* "cupy/core/core.pyx":1290
 * 
 *     def __invert__(self):
 *         return invert(self)             # <<<<<<<<<<<<<<
 * 
 *     # Arithmetic:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_invert); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(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);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1290, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1290, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1290, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1290, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1289
 *         return absolute(self)
 * 
 *     def __invert__(self):             # <<<<<<<<<<<<<<
 *         return invert(self)
 * 
 */

  /* 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("cupy.core.core.ndarray.__invert__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1294
 *     # Arithmetic:
 * 
 *     def __add__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__radd__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_91__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_91__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_90__add__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_90__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "cupy/core/core.pyx":1295
 * 
 *     def __add__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__radd__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1295, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1296
 *     def __add__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__radd__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return add(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_radd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1296, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1296, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1296, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1296, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1296, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1295
 * 
 *     def __add__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__radd__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1298
 *             return y.__radd__(x)
 *         else:
 *             return add(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __sub__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_add); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1298, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1298, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1298, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1298, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1294
 *     # Arithmetic:
 * 
 *     def __add__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__radd__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1300
 *             return add(x, y)
 * 
 *     def __sub__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rsub__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_93__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_93__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__sub__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_92__sub__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_92__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__sub__", 0);

  /* "cupy/core/core.pyx":1301
 * 
 *     def __sub__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rsub__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1301, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1302
 *     def __sub__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rsub__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return subtract(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rsub); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1302, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1302, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1302, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1302, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1302, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1302, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1301
 * 
 *     def __sub__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rsub__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1304
 *             return y.__rsub__(x)
 *         else:
 *             return subtract(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __mul__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_subtract); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1304, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1304, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1304, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1304, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1304, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1300
 *             return add(x, y)
 * 
 *     def __sub__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rsub__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__sub__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1306
 *             return subtract(x, y)
 * 
 *     def __mul__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rmul__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_95__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_95__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__mul__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_94__mul__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_94__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__mul__", 0);

  /* "cupy/core/core.pyx":1307
 * 
 *     def __mul__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmul__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1307, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1308
 *     def __mul__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rmul__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return multiply(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rmul); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1308, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1308, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1308, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1308, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1308, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1308, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1307
 * 
 *     def __mul__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmul__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1310
 *             return y.__rmul__(x)
 *         else:
 *             return multiply(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __matmul__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_multiply); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1310, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1310, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1310, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1310, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1306
 *             return subtract(x, y)
 * 
 *     def __mul__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rmul__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__mul__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1312
 *             return multiply(x, y)
 * 
 *     def __matmul__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rmatmul__(x)
 */

/* Python wrapper */
#if PY_VERSION_HEX >= 0x03050000
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_97__matmul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_97__matmul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__matmul__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_96__matmul__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_VERSION_HEX >= 0x03050000)*/

#if PY_VERSION_HEX >= 0x03050000
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_96__matmul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__matmul__", 0);

  /* "cupy/core/core.pyx":1313
 * 
 *     def __matmul__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmatmul__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1313, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1314
 *     def __matmul__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rmatmul__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return matmul(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rmatmul); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1314, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1314, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1314, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1314, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1314, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1314, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1313
 * 
 *     def __matmul__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmatmul__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1316
 *             return y.__rmatmul__(x)
 *         else:
 *             return matmul(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __div__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1316, __pyx_L1_error)
    if (!(likely(((__pyx_v_y) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_y, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1316, __pyx_L1_error)
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_matmul(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_x), ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_y), 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1316, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1312
 *             return multiply(x, y)
 * 
 *     def __matmul__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rmatmul__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__matmul__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_VERSION_HEX >= 0x03050000)*/

/* "cupy/core/core.pyx":1318
 *             return matmul(x, y)
 * 
 *     def __div__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rdiv__(x)
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_99__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_99__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__div__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_98__div__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000))*/

#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_98__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__div__", 0);

  /* "cupy/core/core.pyx":1319
 * 
 *     def __div__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rdiv__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1319, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1320
 *     def __div__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rdiv__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return divide(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rdiv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1320, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1320, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1320, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1320, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1320, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1320, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1319
 * 
 *     def __div__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rdiv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1322
 *             return y.__rdiv__(x)
 *         else:
 *             return divide(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __truediv__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_divide); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1322, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1322, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1322, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1322, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1322, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1318
 *             return matmul(x, y)
 * 
 *     def __div__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rdiv__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__div__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000))*/

/* "cupy/core/core.pyx":1324
 *             return divide(x, y)
 * 
 *     def __truediv__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rtruediv__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_101__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_101__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__truediv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_100__truediv__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_100__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__truediv__", 0);

  /* "cupy/core/core.pyx":1325
 * 
 *     def __truediv__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rtruediv__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1325, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1326
 *     def __truediv__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rtruediv__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return true_divide(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rtruediv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1326, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1326, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1326, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1326, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1326, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1325
 * 
 *     def __truediv__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rtruediv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1328
 *             return y.__rtruediv__(x)
 *         else:
 *             return true_divide(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __floordiv__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_true_divide); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1328, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1328, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1328, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1328, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1328, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1324
 *             return divide(x, y)
 * 
 *     def __truediv__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rtruediv__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__truediv__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1330
 *             return true_divide(x, y)
 * 
 *     def __floordiv__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rfloordiv__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_103__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_103__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__floordiv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_102__floordiv__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_102__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__floordiv__", 0);

  /* "cupy/core/core.pyx":1331
 * 
 *     def __floordiv__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rfloordiv__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1331, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1332
 *     def __floordiv__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rfloordiv__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return floor_divide(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rfloordiv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1332, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1332, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1332, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1332, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1332, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1332, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1331
 * 
 *     def __floordiv__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rfloordiv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1334
 *             return y.__rfloordiv__(x)
 *         else:
 *             return floor_divide(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __mod__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_floor_divide); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1334, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1334, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1334, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1330
 *             return true_divide(x, y)
 * 
 *     def __floordiv__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rfloordiv__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__floordiv__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1336
 *             return floor_divide(x, y)
 * 
 *     def __mod__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rmod__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_105__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_105__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__mod__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_104__mod__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_104__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__mod__", 0);

  /* "cupy/core/core.pyx":1337
 * 
 *     def __mod__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmod__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1337, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1338
 *     def __mod__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rmod__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return remainder(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rmod); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1338, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1338, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1338, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1338, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1338, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1337
 * 
 *     def __mod__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmod__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1340
 *             return y.__rmod__(x)
 *         else:
 *             return remainder(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __divmod__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_remainder); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1340, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1340, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1340, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1340, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1340, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1336
 *             return floor_divide(x, y)
 * 
 *     def __mod__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rmod__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__mod__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1342
 *             return remainder(x, y)
 * 
 *     def __divmod__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rdivmod__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_107__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_107__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__divmod__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_106__divmod__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_106__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__divmod__", 0);

  /* "cupy/core/core.pyx":1343
 * 
 *     def __divmod__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rdivmod__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1343, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1344
 *     def __divmod__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rdivmod__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return divmod(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rdivmod); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1344, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1344, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1344, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1344, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1344, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1343
 * 
 *     def __divmod__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rdivmod__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1346
 *             return y.__rdivmod__(x)
 *         else:
 *             return divmod(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __pow__(x, y, modulo):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_divmod); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1346, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1346, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1346, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1346, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1346, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1342
 *             return remainder(x, y)
 * 
 *     def __divmod__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rdivmod__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__divmod__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1348
 *             return divmod(x, y)
 * 
 *     def __pow__(x, y, modulo):             # <<<<<<<<<<<<<<
 *         # Note that we ignore the modulo argument as well as NumPy.
 *         if _should_use_rop(x, y):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_109__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_modulo); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_109__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_modulo) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pow__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_108__pow__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), ((PyObject *)__pyx_v_modulo));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_108__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, CYTHON_UNUSED PyObject *__pyx_v_modulo) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__pow__", 0);

  /* "cupy/core/core.pyx":1350
 *     def __pow__(x, y, modulo):
 *         # Note that we ignore the modulo argument as well as NumPy.
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rpow__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1350, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1351
 *         # Note that we ignore the modulo argument as well as NumPy.
 *         if _should_use_rop(x, y):
 *             return y.__rpow__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return power(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rpow); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1351, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1351, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1351, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1351, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1351, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1351, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1350
 *     def __pow__(x, y, modulo):
 *         # Note that we ignore the modulo argument as well as NumPy.
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rpow__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1353
 *             return y.__rpow__(x)
 *         else:
 *             return power(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __lshift__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_power); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1353, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1353, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1353, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1353, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1353, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1348
 *             return divmod(x, y)
 * 
 *     def __pow__(x, y, modulo):             # <<<<<<<<<<<<<<
 *         # Note that we ignore the modulo argument as well as NumPy.
 *         if _should_use_rop(x, y):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__pow__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1355
 *             return power(x, y)
 * 
 *     def __lshift__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rlshift__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_111__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_111__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__lshift__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_110__lshift__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_110__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__lshift__", 0);

  /* "cupy/core/core.pyx":1356
 * 
 *     def __lshift__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rlshift__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1356, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1356, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1357
 *     def __lshift__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rlshift__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return left_shift(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rlshift); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1357, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1357, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1357, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1357, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1357, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1357, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1356
 * 
 *     def __lshift__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rlshift__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1359
 *             return y.__rlshift__(x)
 *         else:
 *             return left_shift(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __rshift__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_left_shift); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1359, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1359, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1359, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1359, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1359, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1355
 *             return power(x, y)
 * 
 *     def __lshift__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rlshift__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__lshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1361
 *             return left_shift(x, y)
 * 
 *     def __rshift__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rrshift__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_113__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_113__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__rshift__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_112__rshift__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_112__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__rshift__", 0);

  /* "cupy/core/core.pyx":1362
 * 
 *     def __rshift__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rrshift__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1362, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1362, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1363
 *     def __rshift__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rrshift__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return right_shift(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rrshift); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1363, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1363, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1363, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1363, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1363, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1363, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1362
 * 
 *     def __rshift__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rrshift__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1365
 *             return y.__rrshift__(x)
 *         else:
 *             return right_shift(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __and__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_right_shift); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1365, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1365, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1365, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1365, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1361
 *             return left_shift(x, y)
 * 
 *     def __rshift__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rrshift__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__rshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1367
 *             return right_shift(x, y)
 * 
 *     def __and__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rand__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_115__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_115__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__and__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_114__and__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_114__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__and__", 0);

  /* "cupy/core/core.pyx":1368
 * 
 *     def __and__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rand__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1368, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1368, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1369
 *     def __and__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rand__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return bitwise_and(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rand); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1369, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1369, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1369, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1369, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1369, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1369, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1368
 * 
 *     def __and__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rand__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1371
 *             return y.__rand__(x)
 *         else:
 *             return bitwise_and(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __or__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_bitwise_and); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1371, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1371, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1367
 *             return right_shift(x, y)
 * 
 *     def __and__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rand__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__and__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1373
 *             return bitwise_and(x, y)
 * 
 *     def __or__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__ror__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_117__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_117__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__or__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_116__or__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_116__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__or__", 0);

  /* "cupy/core/core.pyx":1374
 * 
 *     def __or__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__ror__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1374, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1375
 *     def __or__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__ror__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return bitwise_or(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_ror); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1375, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1375, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1375, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1375, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1375, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1375, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1374
 * 
 *     def __or__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__ror__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1377
 *             return y.__ror__(x)
 *         else:
 *             return bitwise_or(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __xor__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_bitwise_or); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1377, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1377, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1377, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1373
 *             return bitwise_and(x, y)
 * 
 *     def __or__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__ror__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__or__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1379
 *             return bitwise_or(x, y)
 * 
 *     def __xor__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rxor__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_119__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_119__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__xor__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_118__xor__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_118__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__xor__", 0);

  /* "cupy/core/core.pyx":1380
 * 
 *     def __xor__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rxor__(x)
 *         else:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__should_use_rop(__pyx_v_x, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1380, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1381
 *     def __xor__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rxor__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return bitwise_xor(x, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_rxor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1381, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1381, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1381, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_x};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1381, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1381, __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 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1381, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1380
 * 
 *     def __xor__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rxor__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1383
 *             return y.__rxor__(x)
 *         else:
 *             return bitwise_xor(x, y)             # <<<<<<<<<<<<<<
 * 
 *     # Arithmetic, in-place:
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_bitwise_xor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1383, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1383, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1383, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1383, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1379
 *             return bitwise_or(x, y)
 * 
 *     def __xor__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rxor__(x)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__xor__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1387
 *     # Arithmetic, in-place:
 * 
 *     def __iadd__(self, other):             # <<<<<<<<<<<<<<
 *         return add(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_121__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_121__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iadd__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_120__iadd__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_120__iadd__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__iadd__", 0);

  /* "cupy/core/core.pyx":1388
 * 
 *     def __iadd__(self, other):
 *         return add(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __isub__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_add); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1388, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1388, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1388, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_other);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1388, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1387
 *     # Arithmetic, in-place:
 * 
 *     def __iadd__(self, other):             # <<<<<<<<<<<<<<
 *         return add(self, other, self)
 * 
 */

  /* 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_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__iadd__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1390
 *         return add(self, other, self)
 * 
 *     def __isub__(self, other):             # <<<<<<<<<<<<<<
 *         return subtract(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_123__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_123__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__isub__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_122__isub__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_122__isub__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__isub__", 0);

  /* "cupy/core/core.pyx":1391
 * 
 *     def __isub__(self, other):
 *         return subtract(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __imul__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_subtract); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1391, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1391, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_other);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1390
 *         return add(self, other, self)
 * 
 *     def __isub__(self, other):             # <<<<<<<<<<<<<<
 *         return subtract(self, other, self)
 * 
 */

  /* 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_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__isub__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1393
 *         return subtract(self, other, self)
 * 
 *     def __imul__(self, other):             # <<<<<<<<<<<<<<
 *         return multiply(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_125__imul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_125__imul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__imul__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_124__imul__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_124__imul__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__imul__", 0);

  /* "cupy/core/core.pyx":1394
 * 
 *     def __imul__(self, other):
 *         return multiply(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __idiv__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_multiply); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1394, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1394, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1394, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_other);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1394, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1393
 *         return subtract(self, other, self)
 * 
 *     def __imul__(self, other):             # <<<<<<<<<<<<<<
 *         return multiply(self, other, self)
 * 
 */

  /* 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_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__imul__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1396
 *         return multiply(self, other, self)
 * 
 *     def __idiv__(self, other):             # <<<<<<<<<<<<<<
 *         return divide(self, other, self)
 * 
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_127__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_127__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__idiv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_126__idiv__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000))*/

#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_126__idiv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__idiv__", 0);

  /* "cupy/core/core.pyx":1397
 * 
 *     def __idiv__(self, other):
 *         return divide(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __itruediv__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_divide); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1397, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1397, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1397, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_other);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1397, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1396
 *         return multiply(self, other, self)
 * 
 *     def __idiv__(self, other):             # <<<<<<<<<<<<<<
 *         return divide(self, other, self)
 * 
 */

  /* 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_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__idiv__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000))*/

/* "cupy/core/core.pyx":1399
 *         return divide(self, other, self)
 * 
 *     def __itruediv__(self, other):             # <<<<<<<<<<<<<<
 *         return true_divide(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_129__itruediv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_129__itruediv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__itruediv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_128__itruediv__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_128__itruediv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__itruediv__", 0);

  /* "cupy/core/core.pyx":1400
 * 
 *     def __itruediv__(self, other):
 *         return true_divide(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __ifloordiv__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_true_divide); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1400, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1400, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1400, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_other);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1400, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1399
 *         return divide(self, other, self)
 * 
 *     def __itruediv__(self, other):             # <<<<<<<<<<<<<<
 *         return true_divide(self, other, self)
 * 
 */

  /* 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_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__itruediv__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1402
 *         return true_divide(self, other, self)
 * 
 *     def __ifloordiv__(self, other):             # <<<<<<<<<<<<<<
 *         return floor_divide(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_131__ifloordiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_131__ifloordiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ifloordiv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_130__ifloordiv__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_130__ifloordiv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ifloordiv__", 0);

  /* "cupy/core/core.pyx":1403
 * 
 *     def __ifloordiv__(self, other):
 *         return floor_divide(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __imod__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_floor_divide); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1403, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1403, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_other);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1402
 *         return true_divide(self, other, self)
 * 
 *     def __ifloordiv__(self, other):             # <<<<<<<<<<<<<<
 *         return floor_divide(self, other, self)
 * 
 */

  /* 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_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__ifloordiv__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1405
 *         return floor_divide(self, other, self)
 * 
 *     def __imod__(self, other):             # <<<<<<<<<<<<<<
 *         return remainder(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_133__imod__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_133__imod__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__imod__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_132__imod__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_132__imod__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__imod__", 0);

  /* "cupy/core/core.pyx":1406
 * 
 *     def __imod__(self, other):
 *         return remainder(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __ipow__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_remainder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1406, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1406, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1406, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_other);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1406, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1405
 *         return floor_divide(self, other, self)
 * 
 *     def __imod__(self, other):             # <<<<<<<<<<<<<<
 *         return remainder(self, other, self)
 * 
 */

  /* 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_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__imod__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1408
 *         return remainder(self, other, self)
 * 
 *     def __ipow__(self, other):             # <<<<<<<<<<<<<<
 *         return power(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_135__ipow__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_135__ipow__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ipow__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_134__ipow__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_134__ipow__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ipow__", 0);

  /* "cupy/core/core.pyx":1409
 * 
 *     def __ipow__(self, other):
 *         return power(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __ilshift__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_power); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1409, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1409, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_other);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1408
 *         return remainder(self, other, self)
 * 
 *     def __ipow__(self, other):             # <<<<<<<<<<<<<<
 *         return power(self, other, self)
 * 
 */

  /* 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_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__ipow__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1411
 *         return power(self, other, self)
 * 
 *     def __ilshift__(self, other):             # <<<<<<<<<<<<<<
 *         return left_shift(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_137__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_137__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ilshift__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_136__ilshift__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_136__ilshift__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ilshift__", 0);

  /* "cupy/core/core.pyx":1412
 * 
 *     def __ilshift__(self, other):
 *         return left_shift(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __irshift__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_left_shift); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1412, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1412, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_other);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1411
 *         return power(self, other, self)
 * 
 *     def __ilshift__(self, other):             # <<<<<<<<<<<<<<
 *         return left_shift(self, other, self)
 * 
 */

  /* 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_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__ilshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1414
 *         return left_shift(self, other, self)
 * 
 *     def __irshift__(self, other):             # <<<<<<<<<<<<<<
 *         return right_shift(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_139__irshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_139__irshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__irshift__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_138__irshift__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_138__irshift__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__irshift__", 0);

  /* "cupy/core/core.pyx":1415
 * 
 *     def __irshift__(self, other):
 *         return right_shift(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __iand__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_right_shift); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1415, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1415, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_other);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1414
 *         return left_shift(self, other, self)
 * 
 *     def __irshift__(self, other):             # <<<<<<<<<<<<<<
 *         return right_shift(self, other, self)
 * 
 */

  /* 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_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__irshift__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1417
 *         return right_shift(self, other, self)
 * 
 *     def __iand__(self, other):             # <<<<<<<<<<<<<<
 *         return bitwise_and(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_141__iand__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_141__iand__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iand__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_140__iand__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_140__iand__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__iand__", 0);

  /* "cupy/core/core.pyx":1418
 * 
 *     def __iand__(self, other):
 *         return bitwise_and(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __ior__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_bitwise_and); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1418, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1418, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1418, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_other);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1418, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1417
 *         return right_shift(self, other, self)
 * 
 *     def __iand__(self, other):             # <<<<<<<<<<<<<<
 *         return bitwise_and(self, other, self)
 * 
 */

  /* 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_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__iand__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1420
 *         return bitwise_and(self, other, self)
 * 
 *     def __ior__(self, other):             # <<<<<<<<<<<<<<
 *         return bitwise_or(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_143__ior__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_143__ior__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ior__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_142__ior__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_142__ior__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ior__", 0);

  /* "cupy/core/core.pyx":1421
 * 
 *     def __ior__(self, other):
 *         return bitwise_or(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __ixor__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_bitwise_or); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1421, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1421, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_other);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1420
 *         return bitwise_and(self, other, self)
 * 
 *     def __ior__(self, other):             # <<<<<<<<<<<<<<
 *         return bitwise_or(self, other, self)
 * 
 */

  /* 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_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__ior__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1423
 *         return bitwise_or(self, other, self)
 * 
 *     def __ixor__(self, other):             # <<<<<<<<<<<<<<
 *         return bitwise_xor(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_145__ixor__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_145__ixor__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ixor__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_144__ixor__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_144__ixor__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__ixor__", 0);

  /* "cupy/core/core.pyx":1424
 * 
 *     def __ixor__(self, other):
 *         return bitwise_xor(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray conj(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_bitwise_xor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1424, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_other, ((PyObject *)__pyx_v_self)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1424, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_other);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1423
 *         return bitwise_or(self, other, self)
 * 
 *     def __ixor__(self, other):             # <<<<<<<<<<<<<<
 *         return bitwise_xor(self, other, self)
 * 
 */

  /* 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_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__ixor__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1426
 *         return bitwise_xor(self, other, self)
 * 
 *     cpdef ndarray conj(self):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             return conj(self)
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_147conj(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_conj(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("conj", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_conj); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1426, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_147conj)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1426, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1426, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1426, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1427
 * 
 *     cpdef ndarray conj(self):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             return conj(self)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1427, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":1428
 *     cpdef ndarray conj(self):
 *         if self.dtype.kind == 'c':
 *             return conj(self)             # <<<<<<<<<<<<<<
 *         else:
 *             return self
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_conj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1428, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1428, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1428, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1428, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1428, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_self));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
        PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1428, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1428, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1427
 * 
 *     cpdef ndarray conj(self):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             return conj(self)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1430
 *             return conj(self)
 *         else:
 *             return self             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1426
 *         return bitwise_xor(self, other, self)
 * 
 *     cpdef ndarray conj(self):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             return conj(self)
 */

  /* 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("cupy.core.core.ndarray.conj", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_147conj(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_146conj[] = "ndarray.conj(self) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_147conj(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("conj (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_146conj(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_146conj(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("conj", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_7ndarray_conj(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.conj", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1433
 * 
 *     @property
 *     def real(self):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             view = ndarray(
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_4real_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_4real_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_4real___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4real___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_view = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  std::vector<Py_ssize_t>  __pyx_t_6;
  std::vector<Py_ssize_t>  __pyx_t_7;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":1434
 *     @property
 *     def real(self):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             view = ndarray(
 *                 shape=(), dtype=get_dtype(self.dtype.char.lower()),
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1434, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1436
 *         if self.dtype.kind == 'c':
 *             view = ndarray(
 *                 shape=(), dtype=get_dtype(self.dtype.char.lower()),             # <<<<<<<<<<<<<<
 *                 memptr=self.data)
 *             view._set_shape_and_strides(self.shape, self.strides)
 */
    __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1436, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_shape, __pyx_empty_tuple) < 0) __PYX_ERR(0, 1436, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_char); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1436, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_lower); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1436, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1436, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1436, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_t_3, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1436, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 1436, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1437
 *             view = ndarray(
 *                 shape=(), dtype=get_dtype(self.dtype.char.lower()),
 *                 memptr=self.data)             # <<<<<<<<<<<<<<
 *             view._set_shape_and_strides(self.shape, self.strides)
 *             view.base = self.base if self.base is not None else self
 */
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_memptr, ((PyObject *)__pyx_v_self->data)) < 0) __PYX_ERR(0, 1436, __pyx_L1_error)

    /* "cupy/core/core.pyx":1435
 *     def real(self):
 *         if self.dtype.kind == 'c':
 *             view = ndarray(             # <<<<<<<<<<<<<<
 *                 shape=(), dtype=get_dtype(self.dtype.char.lower()),
 *                 memptr=self.data)
 */
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1435, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1438
 *                 shape=(), dtype=get_dtype(self.dtype.char.lower()),
 *                 memptr=self.data)
 *             view._set_shape_and_strides(self.shape, self.strides)             # <<<<<<<<<<<<<<
 *             view.base = self.base if self.base is not None else self
 *             return view
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1438, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_strides); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1438, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_t_6, __pyx_t_7, 0, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1439
 *                 memptr=self.data)
 *             view._set_shape_and_strides(self.shape, self.strides)
 *             view.base = self.base if self.base is not None else self             # <<<<<<<<<<<<<<
 *             return view
 *         return self
 */
    __pyx_t_2 = (((PyObject *)__pyx_v_self->base) != Py_None);
    if ((__pyx_t_2 != 0)) {
      __Pyx_INCREF(((PyObject *)__pyx_v_self->base));
      __pyx_t_5 = ((PyObject *)__pyx_v_self->base);
    } else {
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __pyx_t_5 = ((PyObject *)__pyx_v_self);
    }
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_v_view->base);
    __Pyx_DECREF(((PyObject *)__pyx_v_view->base));
    __pyx_v_view->base = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1440
 *             view._set_shape_and_strides(self.shape, self.strides)
 *             view.base = self.base if self.base is not None else self
 *             return view             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_view));
    __pyx_r = ((PyObject *)__pyx_v_view);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1434
 *     @property
 *     def real(self):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             view = ndarray(
 *                 shape=(), dtype=get_dtype(self.dtype.char.lower()),
 */
  }

  /* "cupy/core/core.pyx":1441
 *             view.base = self.base if self.base is not None else self
 *             return view
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     @real.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1433
 * 
 *     @property
 *     def real(self):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             view = ndarray(
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.real.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_view);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1444
 * 
 *     @real.setter
 *     def real(self, value):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             _real_setter(value, self)
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_4real_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_4real_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_4real_2__set__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_7ndarray_4real_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "cupy/core/core.pyx":1445
 *     @real.setter
 *     def real(self, value):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             _real_setter(value, self)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1445, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1446
 *     def real(self, value):
 *         if self.dtype.kind == 'c':
 *             _real_setter(value, self)             # <<<<<<<<<<<<<<
 *         else:
 *             elementwise_copy(value, self)
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_real_setter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1446, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    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_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_value, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1446, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_value, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1446, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1446, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_value);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1446, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1445
 *     @real.setter
 *     def real(self, value):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             _real_setter(value, self)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1448
 *             _real_setter(value, self)
 *         else:
 *             elementwise_copy(value, self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1448, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_value, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1448, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_value, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1448, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1448, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_value);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1448, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1444
 * 
 *     @real.setter
 *     def real(self, value):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             _real_setter(value, self)
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.real.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1451
 * 
 *     @property
 *     def imag(self):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             view = ndarray(
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_4imag_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_4imag_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_4imag___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4imag___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_view = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_new_array = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  std::vector<Py_ssize_t>  __pyx_t_6;
  std::vector<Py_ssize_t>  __pyx_t_7;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":1452
 *     @property
 *     def imag(self):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             view = ndarray(
 *                 shape=(), dtype=get_dtype(self.dtype.char.lower()),
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1452, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1452, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1454
 *         if self.dtype.kind == 'c':
 *             view = ndarray(
 *                 shape=(), dtype=get_dtype(self.dtype.char.lower()),             # <<<<<<<<<<<<<<
 *                 memptr=self.data + self.itemsize // 2)
 *             view._set_shape_and_strides(self.shape, self.strides)
 */
    __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1454, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_shape, __pyx_empty_tuple) < 0) __PYX_ERR(0, 1454, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_char); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1454, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_lower); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1454, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1454, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1454, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_t_3, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1454, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 1454, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1455
 *             view = ndarray(
 *                 shape=(), dtype=get_dtype(self.dtype.char.lower()),
 *                 memptr=self.data + self.itemsize // 2)             # <<<<<<<<<<<<<<
 *             view._set_shape_and_strides(self.shape, self.strides)
 *             view.base = self.base if self.base is not None else self
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1455, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_5, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1455, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_v_self->data), __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1455, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_memptr, __pyx_t_5) < 0) __PYX_ERR(0, 1454, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1453
 *     def imag(self):
 *         if self.dtype.kind == 'c':
 *             view = ndarray(             # <<<<<<<<<<<<<<
 *                 shape=(), dtype=get_dtype(self.dtype.char.lower()),
 *                 memptr=self.data + self.itemsize // 2)
 */
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1453, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1456
 *                 shape=(), dtype=get_dtype(self.dtype.char.lower()),
 *                 memptr=self.data + self.itemsize // 2)
 *             view._set_shape_and_strides(self.shape, self.strides)             # <<<<<<<<<<<<<<
 *             view.base = self.base if self.base is not None else self
 *             return view
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1456, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_strides); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1456, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_t_6, __pyx_t_7, 0, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1457
 *                 memptr=self.data + self.itemsize // 2)
 *             view._set_shape_and_strides(self.shape, self.strides)
 *             view.base = self.base if self.base is not None else self             # <<<<<<<<<<<<<<
 *             return view
 *         new_array = ndarray(self.shape, dtype=self.dtype)
 */
    __pyx_t_2 = (((PyObject *)__pyx_v_self->base) != Py_None);
    if ((__pyx_t_2 != 0)) {
      __Pyx_INCREF(((PyObject *)__pyx_v_self->base));
      __pyx_t_5 = ((PyObject *)__pyx_v_self->base);
    } else {
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __pyx_t_5 = ((PyObject *)__pyx_v_self);
    }
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_v_view->base);
    __Pyx_DECREF(((PyObject *)__pyx_v_view->base));
    __pyx_v_view->base = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1458
 *             view._set_shape_and_strides(self.shape, self.strides)
 *             view.base = self.base if self.base is not None else self
 *             return view             # <<<<<<<<<<<<<<
 *         new_array = ndarray(self.shape, dtype=self.dtype)
 *         new_array.fill(0)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_view));
    __pyx_r = ((PyObject *)__pyx_v_view);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1452
 *     @property
 *     def imag(self):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             view = ndarray(
 *                 shape=(), dtype=get_dtype(self.dtype.char.lower()),
 */
  }

  /* "cupy/core/core.pyx":1459
 *             view.base = self.base if self.base is not None else self
 *             return view
 *         new_array = ndarray(self.shape, dtype=self.dtype)             # <<<<<<<<<<<<<<
 *         new_array.fill(0)
 *         return new_array
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_v_self->dtype) < 0) __PYX_ERR(0, 1459, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_new_array = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1460
 *             return view
 *         new_array = ndarray(self.shape, dtype=self.dtype)
 *         new_array.fill(0)             # <<<<<<<<<<<<<<
 *         return new_array
 * 
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_new_array->__pyx_vtab)->fill(__pyx_v_new_array, __pyx_int_0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1461
 *         new_array = ndarray(self.shape, dtype=self.dtype)
 *         new_array.fill(0)
 *         return new_array             # <<<<<<<<<<<<<<
 * 
 *     @imag.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_new_array));
  __pyx_r = ((PyObject *)__pyx_v_new_array);
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1451
 * 
 *     @property
 *     def imag(self):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             view = ndarray(
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.imag.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_view);
  __Pyx_XDECREF((PyObject *)__pyx_v_new_array);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1464
 * 
 *     @imag.setter
 *     def imag(self, value):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             _imag_setter(value, self)
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_4imag_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_4imag_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_4imag_2__set__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_7ndarray_4imag_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "cupy/core/core.pyx":1465
 *     @imag.setter
 *     def imag(self, value):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             _imag_setter(value, self)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1465, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1465, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_2)) {

    /* "cupy/core/core.pyx":1466
 *     def imag(self, value):
 *         if self.dtype.kind == 'c':
 *             _imag_setter(value, self)             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError('cupy.ndarray does not have imaginary part to set')
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_imag_setter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1466, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    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_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_value, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_value, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_value);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, ((PyObject *)__pyx_v_self));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1465
 *     @imag.setter
 *     def imag(self, value):
 *         if self.dtype.kind == 'c':             # <<<<<<<<<<<<<<
 *             _imag_setter(value, self)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1468
 *             _imag_setter(value, self)
 *         else:
 *             raise TypeError('cupy.ndarray does not have imaginary part to set')             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1468, __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(0, 1468, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1464
 * 
 *     @imag.setter
 *     def imag(self, value):             # <<<<<<<<<<<<<<
 *         if self.dtype.kind == 'c':
 *             _imag_setter(value, self)
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.ndarray.imag.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1475
 *     # For standard library functions:
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         return self.copy()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_149__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_148__copy__[] = "ndarray.__copy__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_149__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__copy__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_148__copy__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_148__copy__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__copy__", 0);

  /* "cupy/core/core.pyx":1476
 * 
 *     def __copy__(self):
 *         return self.copy()             # <<<<<<<<<<<<<<
 * 
 *     def __deepcopy__(self, memo):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->copy(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1476, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1475
 *     # For standard library functions:
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         return self.copy()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__copy__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1478
 *         return self.copy()
 * 
 *     def __deepcopy__(self, memo):             # <<<<<<<<<<<<<<
 *         if self.device is not None:
 *             with self.device:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_151__deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_150__deepcopy__[] = "ndarray.__deepcopy__(self, memo)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_151__deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__deepcopy__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_150__deepcopy__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_memo));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_150__deepcopy__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_memo) {
  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;
  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;
  __Pyx_RefNannySetupContext("__deepcopy__", 0);

  /* "cupy/core/core.pyx":1479
 * 
 *     def __deepcopy__(self, memo):
 *         if self.device is not None:             # <<<<<<<<<<<<<<
 *             with self.device:
 *                 return self.copy()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1479, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__pyx_t_1 != Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":1480
 *     def __deepcopy__(self, memo):
 *         if self.device is not None:
 *             with self.device:             # <<<<<<<<<<<<<<
 *                 return self.copy()
 *         else:
 */
    /*with:*/ {
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1480, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1480, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1480, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (__pyx_t_7) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1480, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1480, __pyx_L4_error)
      }
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      /*try:*/ {
        {
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_8);
          __Pyx_XGOTREF(__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_10);
          /*try:*/ {

            /* "cupy/core/core.pyx":1481
 *         if self.device is not None:
 *             with self.device:
 *                 return self.copy()             # <<<<<<<<<<<<<<
 *         else:
 *             return self.copy()
 */
            __Pyx_XDECREF(__pyx_r);
            __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->copy(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1481, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_r = __pyx_t_1;
            __pyx_t_1 = 0;
            goto __pyx_L12_try_return;

            /* "cupy/core/core.pyx":1480
 *     def __deepcopy__(self, memo):
 *         if self.device is not None:
 *             with self.device:             # <<<<<<<<<<<<<<
 *                 return self.copy()
 *         else:
 */
          }
          __pyx_L8_error:;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          /*except:*/ {
            __Pyx_AddTraceback("cupy.core.core.ndarray.__deepcopy__", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 1480, __pyx_L10_except_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_7 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1480, __pyx_L10_except_error)
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1480, __pyx_L10_except_error)
            __Pyx_GOTREF(__pyx_t_11);
            __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            if (__pyx_t_3 < 0) __PYX_ERR(0, 1480, __pyx_L10_except_error)
            __pyx_t_2 = ((!(__pyx_t_3 != 0)) != 0);
            if (__pyx_t_2) {
              __Pyx_GIVEREF(__pyx_t_1);
              __Pyx_GIVEREF(__pyx_t_5);
              __Pyx_XGIVEREF(__pyx_t_6);
              __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_5, __pyx_t_6);
              __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; 
              __PYX_ERR(0, 1480, __pyx_L10_except_error)
            }
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            goto __pyx_L9_exception_handled;
          }
          __pyx_L10_except_error:;
          __Pyx_XGIVEREF(__pyx_t_8);
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
          goto __pyx_L1_error;
          __pyx_L12_try_return:;
          __Pyx_XGIVEREF(__pyx_t_8);
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
          goto __pyx_L5_return;
          __pyx_L9_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_8);
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        }
      }
      /*finally:*/ {
        /*normal exit:*/{
          if (__pyx_t_4) {
            __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__41, NULL);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1480, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          }
          goto __pyx_L7;
        }
        __pyx_L5_return: {
          __pyx_t_10 = __pyx_r;
          __pyx_r = 0;
          if (__pyx_t_4) {
            __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__42, NULL);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1480, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
          __pyx_r = __pyx_t_10;
          __pyx_t_10 = 0;
          goto __pyx_L0;
        }
        __pyx_L7:;
      }
      goto __pyx_L17;
      __pyx_L4_error:;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L1_error;
      __pyx_L17:;
    }

    /* "cupy/core/core.pyx":1479
 * 
 *     def __deepcopy__(self, memo):
 *         if self.device is not None:             # <<<<<<<<<<<<<<
 *             with self.device:
 *                 return self.copy()
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1483
 *                 return self.copy()
 *         else:
 *             return self.copy()             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->copy(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1483, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1478
 *         return self.copy()
 * 
 *     def __deepcopy__(self, memo):             # <<<<<<<<<<<<<<
 *         if self.device is not None:
 *             with self.device:
 */

  /* 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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__deepcopy__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1485
 *             return self.copy()
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return array, (self.get(),)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_153__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_152__reduce__[] = "ndarray.__reduce__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_153__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_152__reduce__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_152__reduce__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "cupy/core/core.pyx":1486
 * 
 *     def __reduce__(self):
 *         return array, (self.get(),)             # <<<<<<<<<<<<<<
 * 
 *     # Basic customization:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1485
 *             return self.copy()
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return array, (self.get(),)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1492
 *     # cupy.ndarray does not define __new__
 * 
 *     def __array__(self, dtype=None):             # <<<<<<<<<<<<<<
 *         if dtype is None or self.dtype == dtype:
 *             return self
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_155__array__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_154__array__[] = "ndarray.__array__(self, dtype=None)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_155__array__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__array__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dtype,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__array__") < 0)) __PYX_ERR(0, 1492, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_dtype = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__array__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1492, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.__array__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_154__array__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_dtype);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_154__array__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__array__", 0);

  /* "cupy/core/core.pyx":1493
 * 
 *     def __array__(self, dtype=None):
 *         if dtype is None or self.dtype == dtype:             # <<<<<<<<<<<<<<
 *             return self
 *         else:
 */
  __pyx_t_2 = (__pyx_v_dtype == Py_None);
  __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_4 = PyObject_RichCompare(__pyx_v_self->dtype, __pyx_v_dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1493, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1493, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1494
 *     def __array__(self, dtype=None):
 *         if dtype is None or self.dtype == dtype:
 *             return self             # <<<<<<<<<<<<<<
 *         else:
 *             return self.astype(dtype)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = ((PyObject *)__pyx_v_self);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1493
 * 
 *     def __array__(self, dtype=None):
 *         if dtype is None or self.dtype == dtype:             # <<<<<<<<<<<<<<
 *             return self
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1496
 *             return self
 *         else:
 *             return self.astype(dtype)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement __array_wrap__
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->astype(__pyx_v_self, __pyx_v_dtype, 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1492
 *     # cupy.ndarray does not define __new__
 * 
 *     def __array__(self, dtype=None):             # <<<<<<<<<<<<<<
 *         if dtype is None or self.dtype == dtype:
 *             return self
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__array__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1502
 *     # Container customization:
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         if self._shape.size() == 0:
 *             raise TypeError('len() of unsized object')
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_4cupy_4core_4core_7ndarray_157__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_4cupy_4core_4core_7ndarray_157__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_156__len__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_4cupy_4core_4core_7ndarray_156__len__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "cupy/core/core.pyx":1503
 * 
 *     def __len__(self):
 *         if self._shape.size() == 0:             # <<<<<<<<<<<<<<
 *             raise TypeError('len() of unsized object')
 *         return self._shape[0]
 */
  __pyx_t_1 = ((__pyx_v_self->_shape.size() == 0) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cupy/core/core.pyx":1504
 *     def __len__(self):
 *         if self._shape.size() == 0:
 *             raise TypeError('len() of unsized object')             # <<<<<<<<<<<<<<
 *         return self._shape[0]
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1504, __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(0, 1504, __pyx_L1_error)

    /* "cupy/core/core.pyx":1503
 * 
 *     def __len__(self):
 *         if self._shape.size() == 0:             # <<<<<<<<<<<<<<
 *             raise TypeError('len() of unsized object')
 *         return self._shape[0]
 */
  }

  /* "cupy/core/core.pyx":1505
 *         if self._shape.size() == 0:
 *             raise TypeError('len() of unsized object')
 *         return self._shape[0]             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, slices):
 */
  __pyx_r = (__pyx_v_self->_shape[0]);
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1502
 *     # Container customization:
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         if self._shape.size() == 0:
 *             raise TypeError('len() of unsized object')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1507
 *         return self._shape[0]
 * 
 *     def __getitem__(self, slices):             # <<<<<<<<<<<<<<
 *         """x.__getitem__(y) <==> x[y]
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_159__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_slices); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_158__getitem__[] = "x.__getitem__(y) <==> x[y]\n\n        Supports both basic and advanced indexing.\n\n        .. note::\n\n            Currently, it does not support ``slices`` that consists of more\n            than one boolean arrays\n\n        .. note::\n\n           CuPy handles out-of-bounds indices differently from NumPy.\n           NumPy handles them by raising an error, but CuPy wraps around them.\n\n        Example:\n\n            >>> a = cupy.arange(3)\n            >>> a[[1, 3]]\n            array([1, 0])\n\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_4cupy_4core_4core_7ndarray_158__getitem__;
#endif
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_159__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_slices) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_158__getitem__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_slices));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_158__getitem__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices) {
  Py_ssize_t __pyx_v_mask_i;
  PyObject *__pyx_v_slice_list = 0;
  PyObject *__pyx_v_adv_mask = 0;
  PyObject *__pyx_v_adv_slices = 0;
  int __pyx_v_advanced;
  int __pyx_v_mask_exists;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_axis = 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)(PyObject *);
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "cupy/core/core.pyx":1536
 *         cdef bint advanced, mask_exists
 * 
 *         slice_list, advanced, mask_exists = _prepare_slice_list(             # <<<<<<<<<<<<<<
 *             slices, self._shape.size())
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__prepare_slice_list(__pyx_v_slices, __pyx_v_self->_shape.size(), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1536, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1536, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1536, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1536, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1536, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 2; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 3) < 0) __PYX_ERR(0, 1536, __pyx_L1_error)
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1536, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 1536, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1536, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1536, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_slice_list = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_advanced = __pyx_t_7;
  __pyx_v_mask_exists = __pyx_t_8;

  /* "cupy/core/core.pyx":1539
 *             slices, self._shape.size())
 * 
 *         if mask_exists:             # <<<<<<<<<<<<<<
 *             mask_i = _get_mask_index(slice_list)
 *             return _getitem_mask_single(self, slice_list[mask_i], mask_i)
 */
  __pyx_t_8 = (__pyx_v_mask_exists != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1540
 * 
 *         if mask_exists:
 *             mask_i = _get_mask_index(slice_list)             # <<<<<<<<<<<<<<
 *             return _getitem_mask_single(self, slice_list[mask_i], mask_i)
 * 
 */
    __pyx_t_9 = __pyx_f_4cupy_4core_4core__get_mask_index(__pyx_v_slice_list); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1540, __pyx_L1_error)
    __pyx_v_mask_i = __pyx_t_9;

    /* "cupy/core/core.pyx":1541
 *         if mask_exists:
 *             mask_i = _get_mask_index(slice_list)
 *             return _getitem_mask_single(self, slice_list[mask_i], mask_i)             # <<<<<<<<<<<<<<
 * 
 *         if advanced:
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_slice_list == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1541, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_slice_list, __pyx_v_mask_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1541, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1541, __pyx_L1_error)
    __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core__getitem_mask_single(__pyx_v_self, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1), __pyx_v_mask_i, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1541, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1539
 *             slices, self._shape.size())
 * 
 *         if mask_exists:             # <<<<<<<<<<<<<<
 *             mask_i = _get_mask_index(slice_list)
 *             return _getitem_mask_single(self, slice_list[mask_i], mask_i)
 */
  }

  /* "cupy/core/core.pyx":1543
 *             return _getitem_mask_single(self, slice_list[mask_i], mask_i)
 * 
 *         if advanced:             # <<<<<<<<<<<<<<
 *             a, adv_slices, adv_mask = _prepare_advanced_indexing(
 *                 self, slice_list)
 */
  __pyx_t_8 = (__pyx_v_advanced != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1544
 * 
 *         if advanced:
 *             a, adv_slices, adv_mask = _prepare_advanced_indexing(             # <<<<<<<<<<<<<<
 *                 self, slice_list)
 *             if sum(adv_mask) == 1:
 */
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__prepare_advanced_indexing(__pyx_v_self, __pyx_v_slice_list); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1544, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (likely(__pyx_t_4 != Py_None)) {
      PyObject* sequence = __pyx_t_4;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 1544, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); 
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1544, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1544, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1544, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 1544, __pyx_L1_error)
    }
    if (!(likely(PyList_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 1544, __pyx_L1_error)
    if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 1544, __pyx_L1_error)
    __pyx_v_a = __pyx_t_1;
    __pyx_t_1 = 0;
    __pyx_v_adv_slices = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_v_adv_mask = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":1546
 *             a, adv_slices, adv_mask = _prepare_advanced_indexing(
 *                 self, slice_list)
 *             if sum(adv_mask) == 1:             # <<<<<<<<<<<<<<
 *                 axis = adv_mask.index(True)
 *                 return a.take(adv_slices[axis], axis)
 */
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_sum, __pyx_v_adv_mask); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1546, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_4, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1546, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1546, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1547
 *                 self, slice_list)
 *             if sum(adv_mask) == 1:
 *                 axis = adv_mask.index(True)             # <<<<<<<<<<<<<<
 *                 return a.take(adv_slices[axis], axis)
 *             return _getitem_multiple(a, adv_slices)
 */
      __pyx_t_2 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyList_Type_index, __pyx_v_adv_mask, Py_True); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1547, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_axis = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":1548
 *             if sum(adv_mask) == 1:
 *                 axis = adv_mask.index(True)
 *                 return a.take(adv_slices[axis], axis)             # <<<<<<<<<<<<<<
 *             return _getitem_multiple(a, adv_slices)
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_take); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1548, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (unlikely(__pyx_v_adv_slices == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 1548, __pyx_L1_error)
      }
      __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_adv_slices, __pyx_v_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1548, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_t_3, __pyx_v_axis};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1548, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_t_3, __pyx_v_axis};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1548, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1548, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (__pyx_t_1) {
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_10, __pyx_t_3);
        __Pyx_INCREF(__pyx_v_axis);
        __Pyx_GIVEREF(__pyx_v_axis);
        PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_10, __pyx_v_axis);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1548, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":1546
 *             a, adv_slices, adv_mask = _prepare_advanced_indexing(
 *                 self, slice_list)
 *             if sum(adv_mask) == 1:             # <<<<<<<<<<<<<<
 *                 axis = adv_mask.index(True)
 *                 return a.take(adv_slices[axis], axis)
 */
    }

    /* "cupy/core/core.pyx":1549
 *                 axis = adv_mask.index(True)
 *                 return a.take(adv_slices[axis], axis)
 *             return _getitem_multiple(a, adv_slices)             # <<<<<<<<<<<<<<
 * 
 *         return _simple_getitem(self, slice_list)
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(((__pyx_v_a) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1549, __pyx_L1_error)
    __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__getitem_multiple(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_a), __pyx_v_adv_slices, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1543
 *             return _getitem_mask_single(self, slice_list[mask_i], mask_i)
 * 
 *         if advanced:             # <<<<<<<<<<<<<<
 *             a, adv_slices, adv_mask = _prepare_advanced_indexing(
 *                 self, slice_list)
 */
  }

  /* "cupy/core/core.pyx":1551
 *             return _getitem_multiple(a, adv_slices)
 * 
 *         return _simple_getitem(self, slice_list)             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, slices, value):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__simple_getitem(__pyx_v_self, __pyx_v_slice_list)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1507
 *         return self._shape[0]
 * 
 *     def __getitem__(self, slices):             # <<<<<<<<<<<<<<
 *         """x.__getitem__(y) <==> x[y]
 * 
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_slice_list);
  __Pyx_XDECREF(__pyx_v_adv_mask);
  __Pyx_XDECREF(__pyx_v_adv_slices);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1553
 *         return _simple_getitem(self, slice_list)
 * 
 *     def __setitem__(self, slices, value):             # <<<<<<<<<<<<<<
 *         """x.__setitem__(slices, y) <==> x[slices] = y
 * 
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_161__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_160__setitem__[] = "x.__setitem__(slices, y) <==> x[slices] = y\n\n        Supports both basic and advanced indexing.\n\n        .. note::\n\n            Currently, it does not support ``slices`` that consists of more\n            than one boolean arrays\n\n        .. note::\n\n            CuPy handles out-of-bounds indices differently from NumPy when\n            using integer array indexing.\n            NumPy handles them by raising an error, but CuPy wraps around them.\n\n            >>> import cupy\n            >>> x = cupy.arange(3)\n            >>> x[[1, 3]] = 10\n            >>> x\n            array([10, 10,  2])\n\n        .. note::\n\n            The behavior differs from NumPy when integer arrays in ``slices``\n            reference the same location multiple times.\n            In that case, the value that is actually stored is undefined.\n\n            >>> import cupy\n            >>> a = cupy.zeros((2,))\n            >>> i = cupy.arange(10000) % 2\n            >>> v = cupy.arange(10000).astype(cupy.float)\n            >>> a[i] = v\n            >>> a  # doctest: +SKIP\n            array([9150., 9151.])\n\n            On the other hand, NumPy stores the value corresponding to the\n            last index among the indices referencing duplicate locations.\n\n            >>> import numpy\n            >>> a_cpu = numpy.zeros((2,))\n            >>> i_cpu = numpy.arange(10000) % 2\n            >>> v_cpu = numpy.arange(10000).astype(numpy.float)\n            >>> a_cpu[i_cpu] = v_cpu\n            >>> a_cpu\n            array([9998., 9999.])\n\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_4cupy_4core_4core_7ndarray_160__setitem__;
#endif
static int __pyx_pw_4cupy_4core_4core_7ndarray_161__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_160__setitem__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_slices), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_7ndarray_160__setitem__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setitem__", 0);

  /* "cupy/core/core.pyx":1601
 * 
 *         """
 *         _scatter_op(self, slices, value, 'update')             # <<<<<<<<<<<<<<
 * 
 *     def scatter_add(self, slices, value):
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__scatter_op(__pyx_v_self, __pyx_v_slices, __pyx_v_value, __pyx_n_s_update, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1601, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1553
 *         return _simple_getitem(self, slice_list)
 * 
 *     def __setitem__(self, slices, value):             # <<<<<<<<<<<<<<
 *         """x.__setitem__(slices, y) <==> x[slices] = y
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1603
 *         _scatter_op(self, slices, value, 'update')
 * 
 *     def scatter_add(self, slices, value):             # <<<<<<<<<<<<<<
 *         """Adds given values to specified elements of an array.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_163scatter_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_162scatter_add[] = "ndarray.scatter_add(self, slices, value)\nAdds given values to specified elements of an array.\n\n        .. seealso::\n            :func:`cupyx.scatter_add` for full documentation.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_163scatter_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_slices = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("scatter_add (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_slices,&__pyx_n_s_value,0};
    PyObject* values[2] = {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  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_slices)) != 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_value)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("scatter_add", 1, 2, 2, 1); __PYX_ERR(0, 1603, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scatter_add") < 0)) __PYX_ERR(0, 1603, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_slices = values[0];
    __pyx_v_value = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("scatter_add", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1603, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.scatter_add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_162scatter_add(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_slices, __pyx_v_value);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_162scatter_add(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("scatter_add", 0);

  /* "cupy/core/core.pyx":1610
 * 
 *         """
 *         _scatter_op(self, slices, value, 'add')             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement __getslice__
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__scatter_op(__pyx_v_self, __pyx_v_slices, __pyx_v_value, __pyx_n_s_add, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1610, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1603
 *         _scatter_op(self, slices, value, 'update')
 * 
 *     def scatter_add(self, slices, value):             # <<<<<<<<<<<<<<
 *         """Adds given values to specified elements of an array.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.scatter_add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1618
 *     # Conversion:
 * 
 *     def __int__(self):             # <<<<<<<<<<<<<<
 *         return int(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_165__int__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_165__int__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__int__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_164__int__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_164__int__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__int__", 0);

  /* "cupy/core/core.pyx":1619
 * 
 *     def __int__(self):
 *         return int(self.get())             # <<<<<<<<<<<<<<
 * 
 *     if sys.version_info < (3,):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1619, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1619, __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;

  /* "cupy/core/core.pyx":1618
 *     # Conversion:
 * 
 *     def __int__(self):             # <<<<<<<<<<<<<<
 *         return int(self.get())
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__int__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1622
 * 
 *     if sys.version_info < (3,):
 *         def __long__(self):             # <<<<<<<<<<<<<<
 *             # Avoid using long() for flake8
 *             return self.get().__long__()
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_167__long__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_167__long__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__long__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_166__long__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

#if PY_MAJOR_VERSION < 3
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_166__long__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__long__", 0);

  /* "cupy/core/core.pyx":1624
 *         def __long__(self):
 *             # Avoid using long() for flake8
 *             return self.get().__long__()             # <<<<<<<<<<<<<<
 * 
 *     def __float__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1624, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_long); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1624, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1624, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1624, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1622
 * 
 *     if sys.version_info < (3,):
 *         def __long__(self):             # <<<<<<<<<<<<<<
 *             # Avoid using long() for flake8
 *             return self.get().__long__()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__long__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

/* "cupy/core/core.pyx":1626
 *             return self.get().__long__()
 * 
 *     def __float__(self):             # <<<<<<<<<<<<<<
 *         return float(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_169__float__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_169__float__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__float__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_168__float__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_168__float__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__float__", 0);

  /* "cupy/core/core.pyx":1627
 * 
 *     def __float__(self):
 *         return float(self.get())             # <<<<<<<<<<<<<<
 * 
 *     def __complex__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1627, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyNumber_Float(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1627, __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;

  /* "cupy/core/core.pyx":1626
 *             return self.get().__long__()
 * 
 *     def __float__(self):             # <<<<<<<<<<<<<<
 *         return float(self.get())
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__float__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1629
 *         return float(self.get())
 * 
 *     def __complex__(self):             # <<<<<<<<<<<<<<
 *         return complex(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_171__complex__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_170__complex__[] = "ndarray.__complex__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_171__complex__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__complex__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_170__complex__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_170__complex__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__complex__", 0);

  /* "cupy/core/core.pyx":1630
 * 
 *     def __complex__(self):
 *         return complex(self.get())             # <<<<<<<<<<<<<<
 * 
 *     def __oct__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyComplex_Type)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1630, __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;

  /* "cupy/core/core.pyx":1629
 *         return float(self.get())
 * 
 *     def __complex__(self):             # <<<<<<<<<<<<<<
 *         return complex(self.get())
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__complex__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1632
 *         return complex(self.get())
 * 
 *     def __oct__(self):             # <<<<<<<<<<<<<<
 *         return oct(self.get())
 * 
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_173__oct__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_173__oct__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__oct__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_172__oct__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000))*/

#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_172__oct__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__oct__", 0);

  /* "cupy/core/core.pyx":1633
 * 
 *     def __oct__(self):
 *         return oct(self.get())             # <<<<<<<<<<<<<<
 * 
 *     def __hex__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_oct, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1633, __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;

  /* "cupy/core/core.pyx":1632
 *         return complex(self.get())
 * 
 *     def __oct__(self):             # <<<<<<<<<<<<<<
 *         return oct(self.get())
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__oct__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000))*/

/* "cupy/core/core.pyx":1635
 *         return oct(self.get())
 * 
 *     def __hex__(self):             # <<<<<<<<<<<<<<
 *         return hex(self.get())
 * 
 */

/* Python wrapper */
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_175__hex__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_175__hex__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__hex__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_174__hex__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000))*/

#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_174__hex__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__hex__", 0);

  /* "cupy/core/core.pyx":1636
 * 
 *     def __hex__(self):
 *         return hex(self.get())             # <<<<<<<<<<<<<<
 * 
 *     # String representations:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_hex, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1636, __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;

  /* "cupy/core/core.pyx":1635
 *         return oct(self.get())
 * 
 *     def __hex__(self):             # <<<<<<<<<<<<<<
 *         return hex(self.get())
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__hex__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000))*/

/* "cupy/core/core.pyx":1640
 *     # String representations:
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return repr(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_177__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_177__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_176__repr__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_176__repr__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "cupy/core/core.pyx":1641
 * 
 *     def __repr__(self):
 *         return repr(self.get())             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1641, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1641, __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;

  /* "cupy/core/core.pyx":1640
 *     # String representations:
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return repr(self.get())
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1643
 *         return repr(self.get())
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return str(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_179__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_179__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_178__str__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_178__str__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "cupy/core/core.pyx":1644
 * 
 *     def __str__(self):
 *         return str(self.get())             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1644, __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;

  /* "cupy/core/core.pyx":1643
 *         return repr(self.get())
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return str(self.get())
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1649
 *     # Methods outside of the ndarray main documentation
 *     # -------------------------------------------------------------------------
 *     def dot(self, ndarray b, ndarray out=None):             # <<<<<<<<<<<<<<
 *         """Returns the dot product with given array.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_181dot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_180dot[] = "ndarray.dot(self, ndarray b, ndarray out=None)\nReturns the dot product with given array.\n\n        .. seealso::\n           :func:`cupy.dot` for full documentation,\n           :meth:`numpy.ndarray.dot`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_181dot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dot (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_b,&__pyx_n_s_out,0};
    PyObject* values[2] = {0,0};
    values[1] = (PyObject *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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_b)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "dot") < 0)) __PYX_ERR(0, 1649, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_b = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("dot", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1649, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.dot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(0, 1649, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 1649, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_180dot(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_b, __pyx_v_out);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_180dot(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_dot __pyx_t_2;
  __Pyx_RefNannySetupContext("dot", 0);

  /* "cupy/core/core.pyx":1657
 * 
 *         """
 *         return dot(self, b, out)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_dot(__pyx_v_self, __pyx_v_b, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1657, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1649
 *     # Methods outside of the ndarray main documentation
 *     # -------------------------------------------------------------------------
 *     def dot(self, ndarray b, ndarray out=None):             # <<<<<<<<<<<<<<
 *         """Returns the dot product with given array.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.dot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1663
 *     # -------------------------------------------------------------------------
 *     @property
 *     def device(self):             # <<<<<<<<<<<<<<
 *         """CUDA device on which this array resides."""
 *         return self.data.device
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_6device_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_6device_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_6device___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_6device___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":1665
 *     def device(self):
 *         """CUDA device on which this array resides."""
 *         return self.data.device             # <<<<<<<<<<<<<<
 * 
 *     cpdef get(self, stream=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->data->device));
  __pyx_r = ((PyObject *)__pyx_v_self->data->device);
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1663
 *     # -------------------------------------------------------------------------
 *     @property
 *     def device(self):             # <<<<<<<<<<<<<<
 *         """CUDA device on which this array resides."""
 *         return self.data.device
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1667
 *         return self.data.device
 * 
 *     cpdef get(self, stream=None):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array on host memory.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_183get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_get(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_get *__pyx_optional_args) {
  PyObject *__pyx_v_stream = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a_gpu = NULL;
  PyObject *__pyx_v_a_cpu = NULL;
  PyObject *__pyx_v_ptr = NULL;
  size_t __pyx_v_stream_ptr;
  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;
  int __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;
  int __pyx_t_12;
  size_t __pyx_t_13;
  struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_to_host_async __pyx_t_14;
  __Pyx_RefNannySetupContext("get", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_stream = __pyx_optional_args->stream;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1667, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_183get)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_stream); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1667, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_stream};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1667, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_stream};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1667, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1667, __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 = NULL;
          __Pyx_INCREF(__pyx_v_stream);
          __Pyx_GIVEREF(__pyx_v_stream);
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_stream);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1667, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1679
 * 
 *         """
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return numpy.ndarray(self._shape, dtype=self.dtype)
 * 
 */
  __pyx_t_6 = ((__pyx_v_self->size == 0) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":1680
 *         """
 *         if self.size == 0:
 *             return numpy.ndarray(self._shape, dtype=self.dtype)             # <<<<<<<<<<<<<<
 * 
 *         with self.device:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1680, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1680, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1680, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1680, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1680, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_self->dtype) < 0) __PYX_ERR(0, 1680, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1680, __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_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1679
 * 
 *         """
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return numpy.ndarray(self._shape, dtype=self.dtype)
 * 
 */
  }

  /* "cupy/core/core.pyx":1682
 *             return numpy.ndarray(self._shape, dtype=self.dtype)
 * 
 *         with self.device:             # <<<<<<<<<<<<<<
 *             a_gpu = ascontiguousarray(self)
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 */
  /*with:*/ {
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_device); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_5, __pyx_n_s_exit); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_5, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1682, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (__pyx_t_2) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1682, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1682, __pyx_L4_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    /*try:*/ {
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_10);
        /*try:*/ {

          /* "cupy/core/core.pyx":1683
 * 
 *         with self.device:
 *             a_gpu = ascontiguousarray(self)             # <<<<<<<<<<<<<<
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 *         ptr = a_cpu.ctypes.get_as_parameter()
 */
          __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_ascontiguousarray(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1683, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_v_a_gpu = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
          __pyx_t_5 = 0;

          /* "cupy/core/core.pyx":1682
 *             return numpy.ndarray(self._shape, dtype=self.dtype)
 * 
 *         with self.device:             # <<<<<<<<<<<<<<
 *             a_gpu = ascontiguousarray(self)
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 */
        }
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L13_try_end;
        __pyx_L8_error:;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("cupy.core.core.ndarray.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 1682, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_2 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1682, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_2, NULL);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1682, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (__pyx_t_6 < 0) __PYX_ERR(0, 1682, __pyx_L10_except_error)
          __pyx_t_12 = ((!(__pyx_t_6 != 0)) != 0);
          if (__pyx_t_12) {
            __Pyx_GIVEREF(__pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_XGIVEREF(__pyx_t_3);
            __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_1, __pyx_t_3);
            __pyx_t_5 = 0; __pyx_t_1 = 0; __pyx_t_3 = 0; 
            __PYX_ERR(0, 1682, __pyx_L10_except_error)
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L9_exception_handled;
        }
        __pyx_L10_except_error:;
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        goto __pyx_L1_error;
        __pyx_L9_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        __pyx_L13_try_end:;
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_7) {
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__44, NULL);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1682, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    goto __pyx_L17;
    __pyx_L4_error:;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L1_error;
    __pyx_L17:;
  }

  /* "cupy/core/core.pyx":1684
 *         with self.device:
 *             a_gpu = ascontiguousarray(self)
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)             # <<<<<<<<<<<<<<
 *         ptr = a_cpu.ctypes.get_as_parameter()
 *         if stream is not None:
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_self->dtype) < 0) __PYX_ERR(0, 1684, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_a_cpu = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":1685
 *             a_gpu = ascontiguousarray(self)
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 *         ptr = a_cpu.ctypes.get_as_parameter()             # <<<<<<<<<<<<<<
 *         if stream is not None:
 *             a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes, stream)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_ctypes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1685, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_as_parameter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1685, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1685, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1685, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_ptr = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":1686
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 *         ptr = a_cpu.ctypes.get_as_parameter()
 *         if stream is not None:             # <<<<<<<<<<<<<<
 *             a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes, stream)
 *         else:
 */
  __pyx_t_12 = (__pyx_v_stream != Py_None);
  __pyx_t_6 = (__pyx_t_12 != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":1687
 *         ptr = a_cpu.ctypes.get_as_parameter()
 *         if stream is not None:
 *             a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes, stream)             # <<<<<<<<<<<<<<
 *         else:
 *             stream_ptr = stream_module.get_current_stream_ptr()
 */
    if (unlikely(!__pyx_v_a_gpu)) { __Pyx_RaiseUnboundLocalError("a_gpu"); __PYX_ERR(0, 1687, __pyx_L1_error) }
    if (unlikely(!__pyx_v_a_gpu)) { __Pyx_RaiseUnboundLocalError("a_gpu"); __PYX_ERR(0, 1687, __pyx_L1_error) }
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a_gpu), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1687, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_13 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_13 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1687, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_14.__pyx_n = 1;
    __pyx_t_14.stream = __pyx_v_stream;
    __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_a_gpu->data->__pyx_vtab)->copy_to_host_async(__pyx_v_a_gpu->data, __pyx_v_ptr, __pyx_t_13, 0, &__pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1687, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":1686
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 *         ptr = a_cpu.ctypes.get_as_parameter()
 *         if stream is not None:             # <<<<<<<<<<<<<<
 *             a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes, stream)
 *         else:
 */
    goto __pyx_L18;
  }

  /* "cupy/core/core.pyx":1689
 *             a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes, stream)
 *         else:
 *             stream_ptr = stream_module.get_current_stream_ptr()             # <<<<<<<<<<<<<<
 *             if stream_ptr == 0:
 *                 a_gpu.data.copy_to_host(ptr, a_gpu.nbytes)
 */
  /*else*/ {
    __pyx_v_stream_ptr = __pyx_f_4cupy_4cuda_6stream_get_current_stream_ptr();

    /* "cupy/core/core.pyx":1690
 *         else:
 *             stream_ptr = stream_module.get_current_stream_ptr()
 *             if stream_ptr == 0:             # <<<<<<<<<<<<<<
 *                 a_gpu.data.copy_to_host(ptr, a_gpu.nbytes)
 *             else:
 */
    __pyx_t_6 = ((__pyx_v_stream_ptr == 0) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":1691
 *             stream_ptr = stream_module.get_current_stream_ptr()
 *             if stream_ptr == 0:
 *                 a_gpu.data.copy_to_host(ptr, a_gpu.nbytes)             # <<<<<<<<<<<<<<
 *             else:
 *                 a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes)
 */
      if (unlikely(!__pyx_v_a_gpu)) { __Pyx_RaiseUnboundLocalError("a_gpu"); __PYX_ERR(0, 1691, __pyx_L1_error) }
      if (unlikely(!__pyx_v_a_gpu)) { __Pyx_RaiseUnboundLocalError("a_gpu"); __PYX_ERR(0, 1691, __pyx_L1_error) }
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a_gpu), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1691, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_13 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_13 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1691, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_a_gpu->data->__pyx_vtab)->copy_to_host(__pyx_v_a_gpu->data, __pyx_v_ptr, __pyx_t_13, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1691, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":1690
 *         else:
 *             stream_ptr = stream_module.get_current_stream_ptr()
 *             if stream_ptr == 0:             # <<<<<<<<<<<<<<
 *                 a_gpu.data.copy_to_host(ptr, a_gpu.nbytes)
 *             else:
 */
      goto __pyx_L19;
    }

    /* "cupy/core/core.pyx":1693
 *                 a_gpu.data.copy_to_host(ptr, a_gpu.nbytes)
 *             else:
 *                 a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes)             # <<<<<<<<<<<<<<
 *         return a_cpu
 * 
 */
    /*else*/ {
      if (unlikely(!__pyx_v_a_gpu)) { __Pyx_RaiseUnboundLocalError("a_gpu"); __PYX_ERR(0, 1693, __pyx_L1_error) }
      if (unlikely(!__pyx_v_a_gpu)) { __Pyx_RaiseUnboundLocalError("a_gpu"); __PYX_ERR(0, 1693, __pyx_L1_error) }
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a_gpu), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1693, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_13 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_13 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1693, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_a_gpu->data->__pyx_vtab)->copy_to_host_async(__pyx_v_a_gpu->data, __pyx_v_ptr, __pyx_t_13, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1693, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __pyx_L19:;
  }
  __pyx_L18:;

  /* "cupy/core/core.pyx":1694
 *             else:
 *                 a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes)
 *         return a_cpu             # <<<<<<<<<<<<<<
 * 
 *     cpdef set(self, arr, stream=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_a_cpu);
  __pyx_r = __pyx_v_a_cpu;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1667
 *         return self.data.device
 * 
 *     cpdef get(self, stream=None):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array on host memory.
 * 
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a_gpu);
  __Pyx_XDECREF(__pyx_v_a_cpu);
  __Pyx_XDECREF(__pyx_v_ptr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_183get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_182get[] = "ndarray.get(self, stream=None)\nReturns a copy of the array on host memory.\n\n        Args:\n            stream (cupy.cuda.Stream): CUDA stream object. If it is given, the\n                copy runs asynchronously. Otherwise, the copy is synchronous.\n                The default uses CUDA stream object of the current context.\n\n        Returns:\n            numpy.ndarray: Copy of the array on host memory.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_183get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_stream = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_stream,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stream);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 1667, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_stream = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1667, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_182get(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_stream);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_182get(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_stream) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_get __pyx_t_2;
  __Pyx_RefNannySetupContext("get", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.stream = __pyx_v_stream;
  __pyx_t_1 = __pyx_vtabptr_4cupy_4core_4core_ndarray->get(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1667, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1696
 *         return a_cpu
 * 
 *     cpdef set(self, arr, stream=None):             # <<<<<<<<<<<<<<
 *         """Copies an array on the host memory to :class:`cupy.ndarray`.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_185set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_set(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_arr, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set *__pyx_optional_args) {
  PyObject *__pyx_v_stream = ((PyObject *)Py_None);
  PyObject *__pyx_v_ptr = NULL;
  size_t __pyx_v_stream_ptr;
  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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  size_t __pyx_t_10;
  struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_host_async __pyx_t_11;
  __Pyx_RefNannySetupContext("set", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_stream = __pyx_optional_args->stream;
    }
  }
  __Pyx_INCREF(__pyx_v_arr);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1696, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_185set)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_arr, __pyx_v_stream};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1696, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_arr, __pyx_v_stream};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1696, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1696, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_arr);
        __Pyx_GIVEREF(__pyx_v_arr);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_arr);
        __Pyx_INCREF(__pyx_v_stream);
        __Pyx_GIVEREF(__pyx_v_stream);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_stream);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1696, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1706
 * 
 *         """
 *         if not isinstance(arr, numpy.ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError('Only numpy.ndarray can be set to cupy.ndarray')
 *         if self.dtype != arr.dtype:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1706, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1706, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = PyObject_IsInstance(__pyx_v_arr, __pyx_t_2); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 1706, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = ((!(__pyx_t_7 != 0)) != 0);
  if (unlikely(__pyx_t_8)) {

    /* "cupy/core/core.pyx":1707
 *         """
 *         if not isinstance(arr, numpy.ndarray):
 *             raise TypeError('Only numpy.ndarray can be set to cupy.ndarray')             # <<<<<<<<<<<<<<
 *         if self.dtype != arr.dtype:
 *             raise TypeError('{} array cannot be set to {} array'.format(
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1707, __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(0, 1707, __pyx_L1_error)

    /* "cupy/core/core.pyx":1706
 * 
 *         """
 *         if not isinstance(arr, numpy.ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError('Only numpy.ndarray can be set to cupy.ndarray')
 *         if self.dtype != arr.dtype:
 */
  }

  /* "cupy/core/core.pyx":1708
 *         if not isinstance(arr, numpy.ndarray):
 *             raise TypeError('Only numpy.ndarray can be set to cupy.ndarray')
 *         if self.dtype != arr.dtype:             # <<<<<<<<<<<<<<
 *             raise TypeError('{} array cannot be set to {} array'.format(
 *                 arr.dtype, self.dtype))
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1708, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_self->dtype, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1708, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1708, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_t_8)) {

    /* "cupy/core/core.pyx":1709
 *             raise TypeError('Only numpy.ndarray can be set to cupy.ndarray')
 *         if self.dtype != arr.dtype:
 *             raise TypeError('{} array cannot be set to {} array'.format(             # <<<<<<<<<<<<<<
 *                 arr.dtype, self.dtype))
 *         if self.shape != arr.shape:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_array_cannot_be_set_to_array, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "cupy/core/core.pyx":1710
 *         if self.dtype != arr.dtype:
 *             raise TypeError('{} array cannot be set to {} array'.format(
 *                 arr.dtype, self.dtype))             # <<<<<<<<<<<<<<
 *         if self.shape != arr.shape:
 *             raise ValueError(
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_self->dtype};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1709, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_self->dtype};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1709, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1709, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_t_3);
      __Pyx_INCREF(__pyx_v_self->dtype);
      __Pyx_GIVEREF(__pyx_v_self->dtype);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_self->dtype);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1709, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":1709
 *             raise TypeError('Only numpy.ndarray can be set to cupy.ndarray')
 *         if self.dtype != arr.dtype:
 *             raise TypeError('{} array cannot be set to {} array'.format(             # <<<<<<<<<<<<<<
 *                 arr.dtype, self.dtype))
 *         if self.shape != arr.shape:
 */
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 1709, __pyx_L1_error)

    /* "cupy/core/core.pyx":1708
 *         if not isinstance(arr, numpy.ndarray):
 *             raise TypeError('Only numpy.ndarray can be set to cupy.ndarray')
 *         if self.dtype != arr.dtype:             # <<<<<<<<<<<<<<
 *             raise TypeError('{} array cannot be set to {} array'.format(
 *                 arr.dtype, self.dtype))
 */
  }

  /* "cupy/core/core.pyx":1711
 *             raise TypeError('{} array cannot be set to {} array'.format(
 *                 arr.dtype, self.dtype))
 *         if self.shape != arr.shape:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'Shape mismatch. Old shape: {}, new shape: {}'.format(
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1711, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1711, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1711, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1711, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(__pyx_t_8)) {

    /* "cupy/core/core.pyx":1713
 *         if self.shape != arr.shape:
 *             raise ValueError(
 *                 'Shape mismatch. Old shape: {}, new shape: {}'.format(             # <<<<<<<<<<<<<<
 *                     self.shape, arr.shape))
 *         if self._c_contiguous:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Shape_mismatch_Old_shape_new_sha, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1713, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "cupy/core/core.pyx":1714
 *             raise ValueError(
 *                 'Shape mismatch. Old shape: {}, new shape: {}'.format(
 *                     self.shape, arr.shape))             # <<<<<<<<<<<<<<
 *         if self._c_contiguous:
 *             arr = numpy.ascontiguousarray(arr)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1714, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1714, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && likely(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_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_2, __pyx_t_3};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1713, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_2, __pyx_t_3};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1713, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1713, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_5, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_5, __pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1713, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1712
 *                 arr.dtype, self.dtype))
 *         if self.shape != arr.shape:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'Shape mismatch. Old shape: {}, new shape: {}'.format(
 *                     self.shape, arr.shape))
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1712, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 1712, __pyx_L1_error)

    /* "cupy/core/core.pyx":1711
 *             raise TypeError('{} array cannot be set to {} array'.format(
 *                 arr.dtype, self.dtype))
 *         if self.shape != arr.shape:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'Shape mismatch. Old shape: {}, new shape: {}'.format(
 */
  }

  /* "cupy/core/core.pyx":1715
 *                 'Shape mismatch. Old shape: {}, new shape: {}'.format(
 *                     self.shape, arr.shape))
 *         if self._c_contiguous:             # <<<<<<<<<<<<<<
 *             arr = numpy.ascontiguousarray(arr)
 *         elif self._f_contiguous:
 */
  __pyx_t_8 = (__pyx_v_self->_c_contiguous != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1716
 *                     self.shape, arr.shape))
 *         if self._c_contiguous:
 *             arr = numpy.ascontiguousarray(arr)             # <<<<<<<<<<<<<<
 *         elif self._f_contiguous:
 *             arr = numpy.asfortranarray(arr)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1716, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1716, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_arr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1716, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_arr};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1716, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_arr};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1716, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1716, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(__pyx_v_arr);
        __Pyx_GIVEREF(__pyx_v_arr);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_arr);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1716, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF_SET(__pyx_v_arr, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1715
 *                 'Shape mismatch. Old shape: {}, new shape: {}'.format(
 *                     self.shape, arr.shape))
 *         if self._c_contiguous:             # <<<<<<<<<<<<<<
 *             arr = numpy.ascontiguousarray(arr)
 *         elif self._f_contiguous:
 */
    goto __pyx_L6;
  }

  /* "cupy/core/core.pyx":1717
 *         if self._c_contiguous:
 *             arr = numpy.ascontiguousarray(arr)
 *         elif self._f_contiguous:             # <<<<<<<<<<<<<<
 *             arr = numpy.asfortranarray(arr)
 *         else:
 */
  __pyx_t_8 = (__pyx_v_self->_f_contiguous != 0);
  if (likely(__pyx_t_8)) {

    /* "cupy/core/core.pyx":1718
 *             arr = numpy.ascontiguousarray(arr)
 *         elif self._f_contiguous:
 *             arr = numpy.asfortranarray(arr)             # <<<<<<<<<<<<<<
 *         else:
 *             raise RuntimeError('Cannot set to non-contiguous array')
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_arr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1718, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_arr};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1718, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_arr};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1718, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1718, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_INCREF(__pyx_v_arr);
        __Pyx_GIVEREF(__pyx_v_arr);
        PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_arr);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1718, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_arr, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1717
 *         if self._c_contiguous:
 *             arr = numpy.ascontiguousarray(arr)
 *         elif self._f_contiguous:             # <<<<<<<<<<<<<<
 *             arr = numpy.asfortranarray(arr)
 *         else:
 */
    goto __pyx_L6;
  }

  /* "cupy/core/core.pyx":1720
 *             arr = numpy.asfortranarray(arr)
 *         else:
 *             raise RuntimeError('Cannot set to non-contiguous array')             # <<<<<<<<<<<<<<
 * 
 *         ptr = arr.ctypes.get_as_parameter()
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1720, __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(0, 1720, __pyx_L1_error)
  }
  __pyx_L6:;

  /* "cupy/core/core.pyx":1722
 *             raise RuntimeError('Cannot set to non-contiguous array')
 * 
 *         ptr = arr.ctypes.get_as_parameter()             # <<<<<<<<<<<<<<
 *         if stream is not None:
 *             self.data.copy_from_host_async(ptr, self.nbytes, stream)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_ctypes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_as_parameter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1722, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1722, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_ptr = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1723
 * 
 *         ptr = arr.ctypes.get_as_parameter()
 *         if stream is not None:             # <<<<<<<<<<<<<<
 *             self.data.copy_from_host_async(ptr, self.nbytes, stream)
 *         else:
 */
  __pyx_t_8 = (__pyx_v_stream != Py_None);
  __pyx_t_7 = (__pyx_t_8 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":1724
 *         ptr = arr.ctypes.get_as_parameter()
 *         if stream is not None:
 *             self.data.copy_from_host_async(ptr, self.nbytes, stream)             # <<<<<<<<<<<<<<
 *         else:
 *             stream_ptr = stream_module.get_current_stream_ptr()
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_10 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1724, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11.__pyx_n = 1;
    __pyx_t_11.stream = __pyx_v_stream;
    __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_self->data->__pyx_vtab)->copy_from_host_async(__pyx_v_self->data, __pyx_v_ptr, __pyx_t_10, 0, &__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1723
 * 
 *         ptr = arr.ctypes.get_as_parameter()
 *         if stream is not None:             # <<<<<<<<<<<<<<
 *             self.data.copy_from_host_async(ptr, self.nbytes, stream)
 *         else:
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":1726
 *             self.data.copy_from_host_async(ptr, self.nbytes, stream)
 *         else:
 *             stream_ptr = stream_module.get_current_stream_ptr()             # <<<<<<<<<<<<<<
 *             if stream_ptr == 0:
 *                 self.data.copy_from_host(ptr, self.nbytes)
 */
  /*else*/ {
    __pyx_v_stream_ptr = __pyx_f_4cupy_4cuda_6stream_get_current_stream_ptr();

    /* "cupy/core/core.pyx":1727
 *         else:
 *             stream_ptr = stream_module.get_current_stream_ptr()
 *             if stream_ptr == 0:             # <<<<<<<<<<<<<<
 *                 self.data.copy_from_host(ptr, self.nbytes)
 *             else:
 */
    __pyx_t_7 = ((__pyx_v_stream_ptr == 0) != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":1728
 *             stream_ptr = stream_module.get_current_stream_ptr()
 *             if stream_ptr == 0:
 *                 self.data.copy_from_host(ptr, self.nbytes)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.data.copy_from_host_async(ptr, self.nbytes)
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1728, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_10 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1728, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_self->data->__pyx_vtab)->copy_from_host(__pyx_v_self->data, __pyx_v_ptr, __pyx_t_10, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1728, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":1727
 *         else:
 *             stream_ptr = stream_module.get_current_stream_ptr()
 *             if stream_ptr == 0:             # <<<<<<<<<<<<<<
 *                 self.data.copy_from_host(ptr, self.nbytes)
 *             else:
 */
      goto __pyx_L8;
    }

    /* "cupy/core/core.pyx":1730
 *                 self.data.copy_from_host(ptr, self.nbytes)
 *             else:
 *                 self.data.copy_from_host_async(ptr, self.nbytes)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray reduced_view(self, dtype=None):
 */
    /*else*/ {
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1730, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_10 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1730, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_self->data->__pyx_vtab)->copy_from_host_async(__pyx_v_self->data, __pyx_v_ptr, __pyx_t_10, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1730, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L8:;
  }
  __pyx_L7:;

  /* "cupy/core/core.pyx":1696
 *         return a_cpu
 * 
 *     cpdef set(self, arr, stream=None):             # <<<<<<<<<<<<<<
 *         """Copies an array on the host memory to :class:`cupy.ndarray`.
 * 
 */

  /* 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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core.ndarray.set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ptr);
  __Pyx_XDECREF(__pyx_v_arr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_185set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_184set[] = "ndarray.set(self, arr, stream=None)\nCopies an array on the host memory to :class:`cupy.ndarray`.\n\n        Args:\n            arr (numpy.ndarray): The source array on the host memory.\n            stream (cupy.cuda.Stream): CUDA stream object. If it is given, the\n                copy runs asynchronously. Otherwise, the copy is synchronous.\n                The default uses CUDA stream object of the current context.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_185set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_arr = 0;
  PyObject *__pyx_v_stream = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_stream,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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_arr)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stream);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set") < 0)) __PYX_ERR(0, 1696, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_arr = values[0];
    __pyx_v_stream = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1696, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_184set(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_arr, __pyx_v_stream);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_184set(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_stream) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set __pyx_t_2;
  __Pyx_RefNannySetupContext("set", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.stream = __pyx_v_stream;
  __pyx_t_1 = __pyx_vtabptr_4cupy_4core_4core_ndarray->set(__pyx_v_self, __pyx_v_arr, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1696, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1732
 *                 self.data.copy_from_host_async(ptr, self.nbytes)
 * 
 *     cpdef ndarray reduced_view(self, dtype=None):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array with minimum number of dimensions.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_187reduced_view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_reduced_view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_reduced_view *__pyx_optional_args) {
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  std::vector<Py_ssize_t>  __pyx_v_shape;
  std::vector<Py_ssize_t>  __pyx_v_strides;
  Py_ssize_t __pyx_v_ndim;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_view = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view __pyx_t_8;
  __Pyx_RefNannySetupContext("reduced_view", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_dtype = __pyx_optional_args->dtype;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reduced_view); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1732, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_187reduced_view)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1732, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_dtype};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1732, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_dtype};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1732, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1732, __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 = NULL;
          __Pyx_INCREF(__pyx_v_dtype);
          __Pyx_GIVEREF(__pyx_v_dtype);
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_dtype);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1732, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1732, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1745
 *         cdef vector.vector[Py_ssize_t] shape, strides
 *         cdef Py_ssize_t ndim
 *         ndim = self._shape.size()             # <<<<<<<<<<<<<<
 *         if ndim <= 1:
 *             return self
 */
  __pyx_v_ndim = __pyx_v_self->_shape.size();

  /* "cupy/core/core.pyx":1746
 *         cdef Py_ssize_t ndim
 *         ndim = self._shape.size()
 *         if ndim <= 1:             # <<<<<<<<<<<<<<
 *             return self
 *         internal.get_reduced_dims(
 */
  __pyx_t_6 = ((__pyx_v_ndim <= 1) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":1747
 *         ndim = self._shape.size()
 *         if ndim <= 1:
 *             return self             # <<<<<<<<<<<<<<
 *         internal.get_reduced_dims(
 *             self._shape, self._strides, self.itemsize, shape, strides)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1746
 *         cdef Py_ssize_t ndim
 *         ndim = self._shape.size()
 *         if ndim <= 1:             # <<<<<<<<<<<<<<
 *             return self
 *         internal.get_reduced_dims(
 */
  }

  /* "cupy/core/core.pyx":1749
 *             return self
 *         internal.get_reduced_dims(
 *             self._shape, self._strides, self.itemsize, shape, strides)             # <<<<<<<<<<<<<<
 *         if ndim == <Py_ssize_t>shape.size():
 *             return self
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1749, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1749, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1748
 *         if ndim <= 1:
 *             return self
 *         internal.get_reduced_dims(             # <<<<<<<<<<<<<<
 *             self._shape, self._strides, self.itemsize, shape, strides)
 *         if ndim == <Py_ssize_t>shape.size():
 */
  __pyx_f_4cupy_4core_8internal_get_reduced_dims(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_t_7, __pyx_v_shape, __pyx_v_strides);

  /* "cupy/core/core.pyx":1750
 *         internal.get_reduced_dims(
 *             self._shape, self._strides, self.itemsize, shape, strides)
 *         if ndim == <Py_ssize_t>shape.size():             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  __pyx_t_6 = ((__pyx_v_ndim == ((Py_ssize_t)__pyx_v_shape.size())) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":1751
 *             self._shape, self._strides, self.itemsize, shape, strides)
 *         if ndim == <Py_ssize_t>shape.size():
 *             return self             # <<<<<<<<<<<<<<
 * 
 *         view = self.view(dtype=dtype)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1750
 *         internal.get_reduced_dims(
 *             self._shape, self._strides, self.itemsize, shape, strides)
 *         if ndim == <Py_ssize_t>shape.size():             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  }

  /* "cupy/core/core.pyx":1753
 *             return self
 * 
 *         view = self.view(dtype=dtype)             # <<<<<<<<<<<<<<
 *         view._set_shape_and_strides(shape, strides)
 *         return view
 */
  __pyx_t_8.__pyx_n = 1;
  __pyx_t_8.dtype = __pyx_v_dtype;
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, &__pyx_t_8)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1753, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1754
 * 
 *         view = self.view(dtype=dtype)
 *         view._set_shape_and_strides(shape, strides)             # <<<<<<<<<<<<<<
 *         return view
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_v_shape, __pyx_v_strides, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1754, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1755
 *         view = self.view(dtype=dtype)
 *         view._set_shape_and_strides(shape, strides)
 *         return view             # <<<<<<<<<<<<<<
 * 
 *     cpdef _update_c_contiguity(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_view));
  __pyx_r = __pyx_v_view;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1732
 *                 self.data.copy_from_host_async(ptr, self.nbytes)
 * 
 *     cpdef ndarray reduced_view(self, dtype=None):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array with minimum number of dimensions.
 * 
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.reduced_view", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_view);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_187reduced_view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_186reduced_view[] = "ndarray.reduced_view(self, dtype=None) -> ndarray\nReturns a view of the array with minimum number of dimensions.\n\n        Args:\n            dtype: Data type specifier. If it is given, then the memory\n                sequence is reinterpreted as the new type.\n\n        Returns:\n            cupy.ndarray: A view of the array with reduced dimensions.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_187reduced_view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reduced_view (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dtype,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reduced_view") < 0)) __PYX_ERR(0, 1732, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_dtype = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("reduced_view", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1732, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.reduced_view", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_186reduced_view(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_dtype);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_186reduced_view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_reduced_view __pyx_t_2;
  __Pyx_RefNannySetupContext("reduced_view", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->reduced_view(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.reduced_view", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1757
 *         return view
 * 
 *     cpdef _update_c_contiguity(self):             # <<<<<<<<<<<<<<
 *         if self.size == 0:
 *             self._c_contiguous = True
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_189_update_c_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__update_c_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  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;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("_update_c_contiguity", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_update_c_contiguity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1757, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_189_update_c_contiguity)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1757, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1757, __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;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1758
 * 
 *     cpdef _update_c_contiguity(self):
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             self._c_contiguous = True
 *             return
 */
  __pyx_t_5 = ((__pyx_v_self->size == 0) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":1759
 *     cpdef _update_c_contiguity(self):
 *         if self.size == 0:
 *             self._c_contiguous = True             # <<<<<<<<<<<<<<
 *             return
 *         self._c_contiguous = internal.get_c_contiguity(
 */
    __pyx_v_self->_c_contiguous = 1;

    /* "cupy/core/core.pyx":1760
 *         if self.size == 0:
 *             self._c_contiguous = True
 *             return             # <<<<<<<<<<<<<<
 *         self._c_contiguous = internal.get_c_contiguity(
 *             self._shape, self._strides, self.itemsize)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1758
 * 
 *     cpdef _update_c_contiguity(self):
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             self._c_contiguous = True
 *             return
 */
  }

  /* "cupy/core/core.pyx":1762
 *             return
 *         self._c_contiguous = internal.get_c_contiguity(
 *             self._shape, self._strides, self.itemsize)             # <<<<<<<<<<<<<<
 * 
 *     cpdef _update_f_contiguity(self):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1762, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1761
 *             self._c_contiguous = True
 *             return
 *         self._c_contiguous = internal.get_c_contiguity(             # <<<<<<<<<<<<<<
 *             self._shape, self._strides, self.itemsize)
 * 
 */
  __pyx_t_5 = __pyx_f_4cupy_4core_8internal_get_c_contiguity(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_t_6, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1761, __pyx_L1_error)
  __pyx_v_self->_c_contiguous = __pyx_t_5;

  /* "cupy/core/core.pyx":1757
 *         return view
 * 
 *     cpdef _update_c_contiguity(self):             # <<<<<<<<<<<<<<
 *         if self.size == 0:
 *             self._c_contiguous = True
 */

  /* 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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.ndarray._update_c_contiguity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_189_update_c_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_188_update_c_contiguity[] = "ndarray._update_c_contiguity(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_189_update_c_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_update_c_contiguity (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_188_update_c_contiguity(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_188_update_c_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_update_c_contiguity", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray__update_c_contiguity(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray._update_c_contiguity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1764
 *             self._shape, self._strides, self.itemsize)
 * 
 *     cpdef _update_f_contiguity(self):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i, count
 *         cdef vector.vector[Py_ssize_t] rev_shape, rev_strides
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_191_update_f_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__update_f_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_count;
  std::vector<Py_ssize_t>  __pyx_v_rev_shape;
  std::vector<Py_ssize_t>  __pyx_v_rev_strides;
  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;
  int __pyx_t_5;
  std::vector<Py_ssize_t> ::iterator __pyx_t_6;
  std::vector<Py_ssize_t>  *__pyx_t_7;
  Py_ssize_t __pyx_t_8;
  __Pyx_RefNannySetupContext("_update_f_contiguity", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_update_f_contiguity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_191_update_f_contiguity)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1764, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1764, __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;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1767
 *         cdef Py_ssize_t i, count
 *         cdef vector.vector[Py_ssize_t] rev_shape, rev_strides
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             self._f_contiguous = True
 *             return
 */
  __pyx_t_5 = ((__pyx_v_self->size == 0) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":1768
 *         cdef vector.vector[Py_ssize_t] rev_shape, rev_strides
 *         if self.size == 0:
 *             self._f_contiguous = True             # <<<<<<<<<<<<<<
 *             return
 *         if self._c_contiguous:
 */
    __pyx_v_self->_f_contiguous = 1;

    /* "cupy/core/core.pyx":1769
 *         if self.size == 0:
 *             self._f_contiguous = True
 *             return             # <<<<<<<<<<<<<<
 *         if self._c_contiguous:
 *             count = 0
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1767
 *         cdef Py_ssize_t i, count
 *         cdef vector.vector[Py_ssize_t] rev_shape, rev_strides
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             self._f_contiguous = True
 *             return
 */
  }

  /* "cupy/core/core.pyx":1770
 *             self._f_contiguous = True
 *             return
 *         if self._c_contiguous:             # <<<<<<<<<<<<<<
 *             count = 0
 *             for i in self._shape:
 */
  __pyx_t_5 = (__pyx_v_self->_c_contiguous != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":1771
 *             return
 *         if self._c_contiguous:
 *             count = 0             # <<<<<<<<<<<<<<
 *             for i in self._shape:
 *                 if i == 1:
 */
    __pyx_v_count = 0;

    /* "cupy/core/core.pyx":1772
 *         if self._c_contiguous:
 *             count = 0
 *             for i in self._shape:             # <<<<<<<<<<<<<<
 *                 if i == 1:
 *                     count += 1
 */
    __pyx_t_7 = &__pyx_v_self->_shape;
    __pyx_t_6 = __pyx_t_7->begin();
    for (;;) {
      if (!(__pyx_t_6 != __pyx_t_7->end())) break;
      __pyx_t_8 = *__pyx_t_6;
      ++__pyx_t_6;
      __pyx_v_i = __pyx_t_8;

      /* "cupy/core/core.pyx":1773
 *             count = 0
 *             for i in self._shape:
 *                 if i == 1:             # <<<<<<<<<<<<<<
 *                     count += 1
 *             self._f_contiguous = (<Py_ssize_t>self._shape.size()) - count <= 1
 */
      __pyx_t_5 = ((__pyx_v_i == 1) != 0);
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":1774
 *             for i in self._shape:
 *                 if i == 1:
 *                     count += 1             # <<<<<<<<<<<<<<
 *             self._f_contiguous = (<Py_ssize_t>self._shape.size()) - count <= 1
 *             return
 */
        __pyx_v_count = (__pyx_v_count + 1);

        /* "cupy/core/core.pyx":1773
 *             count = 0
 *             for i in self._shape:
 *                 if i == 1:             # <<<<<<<<<<<<<<
 *                     count += 1
 *             self._f_contiguous = (<Py_ssize_t>self._shape.size()) - count <= 1
 */
      }

      /* "cupy/core/core.pyx":1772
 *         if self._c_contiguous:
 *             count = 0
 *             for i in self._shape:             # <<<<<<<<<<<<<<
 *                 if i == 1:
 *                     count += 1
 */
    }

    /* "cupy/core/core.pyx":1775
 *                 if i == 1:
 *                     count += 1
 *             self._f_contiguous = (<Py_ssize_t>self._shape.size()) - count <= 1             # <<<<<<<<<<<<<<
 *             return
 *         rev_shape.assign(self._shape.rbegin(), self._shape.rend())
 */
    __pyx_v_self->_f_contiguous = ((((Py_ssize_t)__pyx_v_self->_shape.size()) - __pyx_v_count) <= 1);

    /* "cupy/core/core.pyx":1776
 *                     count += 1
 *             self._f_contiguous = (<Py_ssize_t>self._shape.size()) - count <= 1
 *             return             # <<<<<<<<<<<<<<
 *         rev_shape.assign(self._shape.rbegin(), self._shape.rend())
 *         rev_strides.assign(self._strides.rbegin(), self._strides.rend())
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1770
 *             self._f_contiguous = True
 *             return
 *         if self._c_contiguous:             # <<<<<<<<<<<<<<
 *             count = 0
 *             for i in self._shape:
 */
  }

  /* "cupy/core/core.pyx":1777
 *             self._f_contiguous = (<Py_ssize_t>self._shape.size()) - count <= 1
 *             return
 *         rev_shape.assign(self._shape.rbegin(), self._shape.rend())             # <<<<<<<<<<<<<<
 *         rev_strides.assign(self._strides.rbegin(), self._strides.rend())
 *         self._f_contiguous = internal.get_c_contiguity(
 */
  try {
    __pyx_v_rev_shape.assign(__pyx_v_self->_shape.rbegin(), __pyx_v_self->_shape.rend());
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 1777, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":1778
 *             return
 *         rev_shape.assign(self._shape.rbegin(), self._shape.rend())
 *         rev_strides.assign(self._strides.rbegin(), self._strides.rend())             # <<<<<<<<<<<<<<
 *         self._f_contiguous = internal.get_c_contiguity(
 *             rev_shape, rev_strides, self.itemsize)
 */
  try {
    __pyx_v_rev_strides.assign(__pyx_v_self->_strides.rbegin(), __pyx_v_self->_strides.rend());
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 1778, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":1780
 *         rev_strides.assign(self._strides.rbegin(), self._strides.rend())
 *         self._f_contiguous = internal.get_c_contiguity(
 *             rev_shape, rev_strides, self.itemsize)             # <<<<<<<<<<<<<<
 * 
 *     cpdef _update_contiguity(self):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1780, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1779
 *         rev_shape.assign(self._shape.rbegin(), self._shape.rend())
 *         rev_strides.assign(self._strides.rbegin(), self._strides.rend())
 *         self._f_contiguous = internal.get_c_contiguity(             # <<<<<<<<<<<<<<
 *             rev_shape, rev_strides, self.itemsize)
 * 
 */
  __pyx_t_5 = __pyx_f_4cupy_4core_8internal_get_c_contiguity(__pyx_v_rev_shape, __pyx_v_rev_strides, __pyx_t_8, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1779, __pyx_L1_error)
  __pyx_v_self->_f_contiguous = __pyx_t_5;

  /* "cupy/core/core.pyx":1764
 *             self._shape, self._strides, self.itemsize)
 * 
 *     cpdef _update_f_contiguity(self):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i, count
 *         cdef vector.vector[Py_ssize_t] rev_shape, rev_strides
 */

  /* 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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.ndarray._update_f_contiguity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_191_update_f_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_190_update_f_contiguity[] = "ndarray._update_f_contiguity(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_191_update_f_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_update_f_contiguity (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_190_update_f_contiguity(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_190_update_f_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_update_f_contiguity", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray__update_f_contiguity(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1764, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray._update_f_contiguity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1782
 *             rev_shape, rev_strides, self.itemsize)
 * 
 *     cpdef _update_contiguity(self):             # <<<<<<<<<<<<<<
 *         self._update_c_contiguity()
 *         self._update_f_contiguity()
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_193_update_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__update_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch) {
  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;
  __Pyx_RefNannySetupContext("_update_contiguity", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_update_contiguity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_193_update_contiguity)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __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);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1782, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1782, __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;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1783
 * 
 *     cpdef _update_contiguity(self):
 *         self._update_c_contiguity()             # <<<<<<<<<<<<<<
 *         self._update_f_contiguity()
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_update_c_contiguity(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1784
 *     cpdef _update_contiguity(self):
 *         self._update_c_contiguity()
 *         self._update_f_contiguity()             # <<<<<<<<<<<<<<
 * 
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t] & shape,
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_update_f_contiguity(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1784, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1782
 *             rev_shape, rev_strides, self.itemsize)
 * 
 *     cpdef _update_contiguity(self):             # <<<<<<<<<<<<<<
 *         self._update_c_contiguity()
 *         self._update_f_contiguity()
 */

  /* 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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.ndarray._update_contiguity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_193_update_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_192_update_contiguity[] = "ndarray._update_contiguity(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_193_update_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_update_contiguity (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_192_update_contiguity(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_192_update_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_update_contiguity", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray__update_contiguity(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1782, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray._update_contiguity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1786
 *         self._update_f_contiguity()
 * 
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t] & shape,             # <<<<<<<<<<<<<<
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_195_set_shape_and_strides(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__set_shape_and_strides(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  &__pyx_v_shape, std::vector<Py_ssize_t>  &__pyx_v_strides, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides *__pyx_optional_args) {

  /* "cupy/core/core.pyx":1788
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t] & shape,
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):             # <<<<<<<<<<<<<<
 *         if shape.size() != strides.size():
 *             raise ValueError('len(shape) != len(strides)')
 */
  int __pyx_v_update_c_contiguity = ((int)1);
  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;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("_set_shape_and_strides", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_update_c_contiguity = __pyx_optional_args->update_c_contiguity;
    }
  }

  /* "cupy/core/core.pyx":1786
 *         self._update_f_contiguity()
 * 
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t] & shape,             # <<<<<<<<<<<<<<
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_shape_and_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_195_set_shape_and_strides)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1786, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_strides); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1786, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_update_c_contiguity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1786, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_6 = __pyx_t_1; __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1786, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1786, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1786, __pyx_L1_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_3);
        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_5);
        __pyx_t_3 = 0;
        __pyx_t_4 = 0;
        __pyx_t_5 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1786, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":1789
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):
 *         if shape.size() != strides.size():             # <<<<<<<<<<<<<<
 *             raise ValueError('len(shape) != len(strides)')
 *         self._shape = shape
 */
  __pyx_t_10 = ((__pyx_v_shape.size() != __pyx_v_strides.size()) != 0);
  if (unlikely(__pyx_t_10)) {

    /* "cupy/core/core.pyx":1790
 *                                  bint update_c_contiguity=True):
 *         if shape.size() != strides.size():
 *             raise ValueError('len(shape) != len(strides)')             # <<<<<<<<<<<<<<
 *         self._shape = shape
 *         self._strides = strides
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1790, __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(0, 1790, __pyx_L1_error)

    /* "cupy/core/core.pyx":1789
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):
 *         if shape.size() != strides.size():             # <<<<<<<<<<<<<<
 *             raise ValueError('len(shape) != len(strides)')
 *         self._shape = shape
 */
  }

  /* "cupy/core/core.pyx":1791
 *         if shape.size() != strides.size():
 *             raise ValueError('len(shape) != len(strides)')
 *         self._shape = shape             # <<<<<<<<<<<<<<
 *         self._strides = strides
 *         self.size = internal.prod_ssize_t(shape)
 */
  __pyx_v_self->_shape = __pyx_v_shape;

  /* "cupy/core/core.pyx":1792
 *             raise ValueError('len(shape) != len(strides)')
 *         self._shape = shape
 *         self._strides = strides             # <<<<<<<<<<<<<<
 *         self.size = internal.prod_ssize_t(shape)
 *         if update_c_contiguity:
 */
  __pyx_v_self->_strides = __pyx_v_strides;

  /* "cupy/core/core.pyx":1793
 *         self._shape = shape
 *         self._strides = strides
 *         self.size = internal.prod_ssize_t(shape)             # <<<<<<<<<<<<<<
 *         if update_c_contiguity:
 *             self._update_contiguity()
 */
  __pyx_v_self->size = __pyx_f_4cupy_4core_8internal_prod_ssize_t(__pyx_v_shape, 0, NULL);

  /* "cupy/core/core.pyx":1794
 *         self._strides = strides
 *         self.size = internal.prod_ssize_t(shape)
 *         if update_c_contiguity:             # <<<<<<<<<<<<<<
 *             self._update_contiguity()
 *         else:
 */
  __pyx_t_10 = (__pyx_v_update_c_contiguity != 0);
  if (__pyx_t_10) {

    /* "cupy/core/core.pyx":1795
 *         self.size = internal.prod_ssize_t(shape)
 *         if update_c_contiguity:
 *             self._update_contiguity()             # <<<<<<<<<<<<<<
 *         else:
 *             self._update_f_contiguity()
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_update_contiguity(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1795, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1794
 *         self._strides = strides
 *         self.size = internal.prod_ssize_t(shape)
 *         if update_c_contiguity:             # <<<<<<<<<<<<<<
 *             self._update_contiguity()
 *         else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":1797
 *             self._update_contiguity()
 *         else:
 *             self._update_f_contiguity()             # <<<<<<<<<<<<<<
 * 
 *     cdef function.CPointer get_pointer(self):
 */
  /*else*/ {
    __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_update_f_contiguity(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1797, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":1786
 *         self._update_f_contiguity()
 * 
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t] & shape,             # <<<<<<<<<<<<<<
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):
 */

  /* 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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core.ndarray._set_shape_and_strides", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_195_set_shape_and_strides(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_194_set_shape_and_strides[] = "ndarray._set_shape_and_strides(self, vector[Py_ssize_t] shape, vector[Py_ssize_t] strides, bool update_c_contiguity=True)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_195_set_shape_and_strides(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  std::vector<Py_ssize_t>  __pyx_v_shape;
  std::vector<Py_ssize_t>  __pyx_v_strides;
  int __pyx_v_update_c_contiguity;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_set_shape_and_strides (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_strides,&__pyx_n_s_update_c_contiguity_2,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_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_strides)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_set_shape_and_strides", 0, 2, 3, 1); __PYX_ERR(0, 1786, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_update_c_contiguity_2);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_set_shape_and_strides") < 0)) __PYX_ERR(0, 1786, __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_shape = __pyx_convert_vector_from_py_Py_ssize_t(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1786, __pyx_L3_error)
    __pyx_v_strides = __pyx_convert_vector_from_py_Py_ssize_t(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1787, __pyx_L3_error)
    if (values[2]) {
      __pyx_v_update_c_contiguity = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_update_c_contiguity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1788, __pyx_L3_error)
    } else {

      /* "cupy/core/core.pyx":1788
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t] & shape,
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):             # <<<<<<<<<<<<<<
 *         if shape.size() != strides.size():
 *             raise ValueError('len(shape) != len(strides)')
 */
      __pyx_v_update_c_contiguity = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_set_shape_and_strides", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1786, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray._set_shape_and_strides", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_194_set_shape_and_strides(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_shape, __pyx_v_strides, __pyx_v_update_c_contiguity);

  /* "cupy/core/core.pyx":1786
 *         self._update_f_contiguity()
 * 
 *     cpdef _set_shape_and_strides(self, vector.vector[Py_ssize_t] & shape,             # <<<<<<<<<<<<<<
 *                                  vector.vector[Py_ssize_t] & strides,
 *                                  bint update_c_contiguity=True):
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_194_set_shape_and_strides(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  __pyx_v_shape, std::vector<Py_ssize_t>  __pyx_v_strides, int __pyx_v_update_c_contiguity) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides __pyx_t_2;
  __Pyx_RefNannySetupContext("_set_shape_and_strides", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.update_c_contiguity = __pyx_v_update_c_contiguity;
  __pyx_t_1 = __pyx_vtabptr_4cupy_4core_4core_ndarray->_set_shape_and_strides(__pyx_v_self, __pyx_v_shape, __pyx_v_strides, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray._set_shape_and_strides", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1799
 *             self._update_f_contiguity()
 * 
 *     cdef function.CPointer get_pointer(self):             # <<<<<<<<<<<<<<
 *         return CArray(self)
 * 
 */

static struct __pyx_obj_4cupy_4cuda_8function_CPointer *__pyx_f_4cupy_4core_4core_7ndarray_get_pointer(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  struct __pyx_obj_4cupy_4cuda_8function_CPointer *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_pointer", 0);

  /* "cupy/core/core.pyx":1800
 * 
 *     cdef function.CPointer get_pointer(self):
 *         return CArray(self)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4cupy_4core_4core_CArray), ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1800, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_4cupy_4cuda_8function_CPointer *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1799
 *             self._update_f_contiguity()
 * 
 *     cdef function.CPointer get_pointer(self):             # <<<<<<<<<<<<<<
 *         return CArray(self)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.get_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pxd":10
 *     cdef:
 *         object __weakref__
 *         readonly Py_ssize_t size             # <<<<<<<<<<<<<<
 *         public vector.vector[Py_ssize_t] _shape
 *         public vector.vector[Py_ssize_t] _strides
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_4size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_4size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_4size___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4size___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pxd":11
 *         object __weakref__
 *         readonly Py_ssize_t size
 *         public vector.vector[Py_ssize_t] _shape             # <<<<<<<<<<<<<<
 *         public vector.vector[Py_ssize_t] _strides
 *         readonly bint _c_contiguous
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_6_shape_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_6_shape_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_6_shape___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_6_shape___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray._shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_6_shape_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_6_shape_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_6_shape_2__set__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_7ndarray_6_shape_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  std::vector<Py_ssize_t>  __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_value); if (unlikely(PyErr_Occurred())) __PYX_ERR(3, 11, __pyx_L1_error)
  __pyx_v_self->_shape = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray._shape.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pxd":12
 *         readonly Py_ssize_t size
 *         public vector.vector[Py_ssize_t] _shape
 *         public vector.vector[Py_ssize_t] _strides             # <<<<<<<<<<<<<<
 *         readonly bint _c_contiguous
 *         readonly bint _f_contiguous
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_8_strides_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_8_strides_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_8_strides___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_8_strides___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray._strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_8_strides_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_8_strides_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_8_strides_2__set__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_7ndarray_8_strides_2__set__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  std::vector<Py_ssize_t>  __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_value); if (unlikely(PyErr_Occurred())) __PYX_ERR(3, 12, __pyx_L1_error)
  __pyx_v_self->_strides = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray._strides.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pxd":13
 *         public vector.vector[Py_ssize_t] _shape
 *         public vector.vector[Py_ssize_t] _strides
 *         readonly bint _c_contiguous             # <<<<<<<<<<<<<<
 *         readonly bint _f_contiguous
 *         readonly object dtype
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_13_c_contiguous_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_13_c_contiguous_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_13_c_contiguous___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_13_c_contiguous___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_c_contiguous); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 13, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray._c_contiguous.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pxd":14
 *         public vector.vector[Py_ssize_t] _strides
 *         readonly bint _c_contiguous
 *         readonly bint _f_contiguous             # <<<<<<<<<<<<<<
 *         readonly object dtype
 *         readonly memory.MemoryPointer data
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_13_f_contiguous_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_13_f_contiguous_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_13_f_contiguous___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_13_f_contiguous___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_f_contiguous); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray._f_contiguous.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pxd":15
 *         readonly bint _c_contiguous
 *         readonly bint _f_contiguous
 *         readonly object dtype             # <<<<<<<<<<<<<<
 *         readonly memory.MemoryPointer data
 *         readonly ndarray base
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_5dtype_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_5dtype_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_5dtype___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_5dtype___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->dtype);
  __pyx_r = __pyx_v_self->dtype;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pxd":16
 *         readonly bint _f_contiguous
 *         readonly object dtype
 *         readonly memory.MemoryPointer data             # <<<<<<<<<<<<<<
 *         readonly ndarray base
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_4data_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_4data_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_4data___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4data___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->data));
  __pyx_r = ((PyObject *)__pyx_v_self->data);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pxd":17
 *         readonly object dtype
 *         readonly memory.MemoryPointer data
 *         readonly ndarray base             # <<<<<<<<<<<<<<
 * 
 *     cpdef tolist(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_4base_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_4base_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_4base___get__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4base___get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->base));
  __pyx_r = ((PyObject *)__pyx_v_self->base);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1803
 * 
 * 
 * cpdef vector.vector[Py_ssize_t] _get_strides_for_nocopy_reshape(             # <<<<<<<<<<<<<<
 *         ndarray a, vector.vector[Py_ssize_t] & newshape) except *:
 *     cdef vector.vector[Py_ssize_t] newstrides
 */

static PyObject *__pyx_pw_4cupy_4core_4core_1_get_strides_for_nocopy_reshape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static std::vector<Py_ssize_t>  __pyx_f_4cupy_4core_4core__get_strides_for_nocopy_reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, std::vector<Py_ssize_t>  &__pyx_v_newshape, CYTHON_UNUSED int __pyx_skip_dispatch) {
  std::vector<Py_ssize_t>  __pyx_v_newstrides;
  Py_ssize_t __pyx_v_size;
  Py_ssize_t __pyx_v_itemsize;
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_dim;
  Py_ssize_t __pyx_v_last_stride;
  std::vector<Py_ssize_t>  __pyx_v_shape;
  std::vector<Py_ssize_t>  __pyx_v_strides;
  CYTHON_UNUSED Py_ssize_t __pyx_v_sh;
  CYTHON_UNUSED Py_ssize_t __pyx_v_st;
  std::vector<Py_ssize_t>  __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  std::vector<Py_ssize_t> ::iterator __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("_get_strides_for_nocopy_reshape", 0);

  /* "cupy/core/core.pyx":1807
 *     cdef vector.vector[Py_ssize_t] newstrides
 *     cdef Py_ssize_t size, itemsize, ndim, dim, last_stride
 *     size = a.size             # <<<<<<<<<<<<<<
 *     if size != internal.prod_ssize_t(newshape):
 *         return newstrides
 */
  __pyx_t_1 = __pyx_v_a->size;
  __pyx_v_size = __pyx_t_1;

  /* "cupy/core/core.pyx":1808
 *     cdef Py_ssize_t size, itemsize, ndim, dim, last_stride
 *     size = a.size
 *     if size != internal.prod_ssize_t(newshape):             # <<<<<<<<<<<<<<
 *         return newstrides
 * 
 */
  __pyx_t_2 = ((__pyx_v_size != __pyx_f_4cupy_4core_8internal_prod_ssize_t(__pyx_v_newshape, 0, NULL)) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1809
 *     size = a.size
 *     if size != internal.prod_ssize_t(newshape):
 *         return newstrides             # <<<<<<<<<<<<<<
 * 
 *     itemsize = a.itemsize
 */
    __pyx_r = __pyx_v_newstrides;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1808
 *     cdef Py_ssize_t size, itemsize, ndim, dim, last_stride
 *     size = a.size
 *     if size != internal.prod_ssize_t(newshape):             # <<<<<<<<<<<<<<
 *         return newstrides
 * 
 */
  }

  /* "cupy/core/core.pyx":1811
 *         return newstrides
 * 
 *     itemsize = a.itemsize             # <<<<<<<<<<<<<<
 *     if size == 1:
 *         newstrides.assign(<Py_ssize_t>newshape.size(), itemsize)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1811, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_itemsize = __pyx_t_1;

  /* "cupy/core/core.pyx":1812
 * 
 *     itemsize = a.itemsize
 *     if size == 1:             # <<<<<<<<<<<<<<
 *         newstrides.assign(<Py_ssize_t>newshape.size(), itemsize)
 *         return newstrides
 */
  __pyx_t_2 = ((__pyx_v_size == 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1813
 *     itemsize = a.itemsize
 *     if size == 1:
 *         newstrides.assign(<Py_ssize_t>newshape.size(), itemsize)             # <<<<<<<<<<<<<<
 *         return newstrides
 * 
 */
    try {
      __pyx_v_newstrides.assign(((Py_ssize_t)__pyx_v_newshape.size()), __pyx_v_itemsize);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 1813, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":1814
 *     if size == 1:
 *         newstrides.assign(<Py_ssize_t>newshape.size(), itemsize)
 *         return newstrides             # <<<<<<<<<<<<<<
 * 
 *     cdef vector.vector[Py_ssize_t] shape, strides
 */
    __pyx_r = __pyx_v_newstrides;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1812
 * 
 *     itemsize = a.itemsize
 *     if size == 1:             # <<<<<<<<<<<<<<
 *         newstrides.assign(<Py_ssize_t>newshape.size(), itemsize)
 *         return newstrides
 */
  }

  /* "cupy/core/core.pyx":1817
 * 
 *     cdef vector.vector[Py_ssize_t] shape, strides
 *     internal.get_reduced_dims(a._shape, a._strides, itemsize, shape, strides)             # <<<<<<<<<<<<<<
 * 
 *     ndim = shape.size()
 */
  __pyx_f_4cupy_4core_8internal_get_reduced_dims(__pyx_v_a->_shape, __pyx_v_a->_strides, __pyx_v_itemsize, __pyx_v_shape, __pyx_v_strides);

  /* "cupy/core/core.pyx":1819
 *     internal.get_reduced_dims(a._shape, a._strides, itemsize, shape, strides)
 * 
 *     ndim = shape.size()             # <<<<<<<<<<<<<<
 *     dim = 0
 *     sh = shape[0]
 */
  __pyx_v_ndim = __pyx_v_shape.size();

  /* "cupy/core/core.pyx":1820
 * 
 *     ndim = shape.size()
 *     dim = 0             # <<<<<<<<<<<<<<
 *     sh = shape[0]
 *     st = strides[0]
 */
  __pyx_v_dim = 0;

  /* "cupy/core/core.pyx":1821
 *     ndim = shape.size()
 *     dim = 0
 *     sh = shape[0]             # <<<<<<<<<<<<<<
 *     st = strides[0]
 *     last_stride = shape[0] * strides[0]
 */
  __pyx_v_sh = (__pyx_v_shape[0]);

  /* "cupy/core/core.pyx":1822
 *     dim = 0
 *     sh = shape[0]
 *     st = strides[0]             # <<<<<<<<<<<<<<
 *     last_stride = shape[0] * strides[0]
 *     for size in newshape:
 */
  __pyx_v_st = (__pyx_v_strides[0]);

  /* "cupy/core/core.pyx":1823
 *     sh = shape[0]
 *     st = strides[0]
 *     last_stride = shape[0] * strides[0]             # <<<<<<<<<<<<<<
 *     for size in newshape:
 *         if size <= 1:
 */
  __pyx_v_last_stride = ((__pyx_v_shape[0]) * (__pyx_v_strides[0]));

  /* "cupy/core/core.pyx":1824
 *     st = strides[0]
 *     last_stride = shape[0] * strides[0]
 *     for size in newshape:             # <<<<<<<<<<<<<<
 *         if size <= 1:
 *             newstrides.push_back(last_stride)
 */
  __pyx_t_4 = __pyx_v_newshape.begin();
  for (;;) {
    if (!(__pyx_t_4 != __pyx_v_newshape.end())) break;
    __pyx_t_1 = *__pyx_t_4;
    ++__pyx_t_4;
    __pyx_v_size = __pyx_t_1;

    /* "cupy/core/core.pyx":1825
 *     last_stride = shape[0] * strides[0]
 *     for size in newshape:
 *         if size <= 1:             # <<<<<<<<<<<<<<
 *             newstrides.push_back(last_stride)
 *             continue
 */
    __pyx_t_2 = ((__pyx_v_size <= 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1826
 *     for size in newshape:
 *         if size <= 1:
 *             newstrides.push_back(last_stride)             # <<<<<<<<<<<<<<
 *             continue
 *         if dim >= ndim or shape[dim] % size != 0:
 */
      try {
        __pyx_v_newstrides.push_back(__pyx_v_last_stride);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 1826, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":1827
 *         if size <= 1:
 *             newstrides.push_back(last_stride)
 *             continue             # <<<<<<<<<<<<<<
 *         if dim >= ndim or shape[dim] % size != 0:
 *             newstrides.clear()
 */
      goto __pyx_L5_continue;

      /* "cupy/core/core.pyx":1825
 *     last_stride = shape[0] * strides[0]
 *     for size in newshape:
 *         if size <= 1:             # <<<<<<<<<<<<<<
 *             newstrides.push_back(last_stride)
 *             continue
 */
    }

    /* "cupy/core/core.pyx":1828
 *             newstrides.push_back(last_stride)
 *             continue
 *         if dim >= ndim or shape[dim] % size != 0:             # <<<<<<<<<<<<<<
 *             newstrides.clear()
 *             break
 */
    __pyx_t_5 = ((__pyx_v_dim >= __pyx_v_ndim) != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_2 = __pyx_t_5;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_1 = (__pyx_v_shape[__pyx_v_dim]);
    if (unlikely(__pyx_v_size == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(0, 1828, __pyx_L1_error)
    }
    __pyx_t_5 = ((__Pyx_mod_Py_ssize_t(__pyx_t_1, __pyx_v_size) != 0) != 0);
    __pyx_t_2 = __pyx_t_5;
    __pyx_L9_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1829
 *             continue
 *         if dim >= ndim or shape[dim] % size != 0:
 *             newstrides.clear()             # <<<<<<<<<<<<<<
 *             break
 *         shape[dim] //= size
 */
      __pyx_v_newstrides.clear();

      /* "cupy/core/core.pyx":1830
 *         if dim >= ndim or shape[dim] % size != 0:
 *             newstrides.clear()
 *             break             # <<<<<<<<<<<<<<
 *         shape[dim] //= size
 *         last_stride = shape[dim] * strides[dim]
 */
      goto __pyx_L6_break;

      /* "cupy/core/core.pyx":1828
 *             newstrides.push_back(last_stride)
 *             continue
 *         if dim >= ndim or shape[dim] % size != 0:             # <<<<<<<<<<<<<<
 *             newstrides.clear()
 *             break
 */
    }

    /* "cupy/core/core.pyx":1831
 *             newstrides.clear()
 *             break
 *         shape[dim] //= size             # <<<<<<<<<<<<<<
 *         last_stride = shape[dim] * strides[dim]
 *         newstrides.push_back(last_stride)
 */
    __pyx_t_1 = __pyx_v_dim;
    __pyx_t_6 = (__pyx_v_shape[__pyx_t_1]);
    if (unlikely(__pyx_v_size == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(0, 1831, __pyx_L1_error)
    }
    else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_size == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_6))) {
      PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
      __PYX_ERR(0, 1831, __pyx_L1_error)
    }
    (__pyx_v_shape[__pyx_t_1]) = __Pyx_div_Py_ssize_t(__pyx_t_6, __pyx_v_size);

    /* "cupy/core/core.pyx":1832
 *             break
 *         shape[dim] //= size
 *         last_stride = shape[dim] * strides[dim]             # <<<<<<<<<<<<<<
 *         newstrides.push_back(last_stride)
 *         if shape[dim] == 1:
 */
    __pyx_v_last_stride = ((__pyx_v_shape[__pyx_v_dim]) * (__pyx_v_strides[__pyx_v_dim]));

    /* "cupy/core/core.pyx":1833
 *         shape[dim] //= size
 *         last_stride = shape[dim] * strides[dim]
 *         newstrides.push_back(last_stride)             # <<<<<<<<<<<<<<
 *         if shape[dim] == 1:
 *             dim += 1
 */
    try {
      __pyx_v_newstrides.push_back(__pyx_v_last_stride);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 1833, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":1834
 *         last_stride = shape[dim] * strides[dim]
 *         newstrides.push_back(last_stride)
 *         if shape[dim] == 1:             # <<<<<<<<<<<<<<
 *             dim += 1
 *     return newstrides
 */
    __pyx_t_2 = (((__pyx_v_shape[__pyx_v_dim]) == 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1835
 *         newstrides.push_back(last_stride)
 *         if shape[dim] == 1:
 *             dim += 1             # <<<<<<<<<<<<<<
 *     return newstrides
 * 
 */
      __pyx_v_dim = (__pyx_v_dim + 1);

      /* "cupy/core/core.pyx":1834
 *         last_stride = shape[dim] * strides[dim]
 *         newstrides.push_back(last_stride)
 *         if shape[dim] == 1:             # <<<<<<<<<<<<<<
 *             dim += 1
 *     return newstrides
 */
    }

    /* "cupy/core/core.pyx":1824
 *     st = strides[0]
 *     last_stride = shape[0] * strides[0]
 *     for size in newshape:             # <<<<<<<<<<<<<<
 *         if size <= 1:
 *             newstrides.push_back(last_stride)
 */
    __pyx_L5_continue:;
  }
  __pyx_L6_break:;

  /* "cupy/core/core.pyx":1836
 *         if shape[dim] == 1:
 *             dim += 1
 *     return newstrides             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_newstrides;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1803
 * 
 * 
 * cpdef vector.vector[Py_ssize_t] _get_strides_for_nocopy_reshape(             # <<<<<<<<<<<<<<
 *         ndarray a, vector.vector[Py_ssize_t] & newshape) except *:
 *     cdef vector.vector[Py_ssize_t] newstrides
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core._get_strides_for_nocopy_reshape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_1_get_strides_for_nocopy_reshape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core__get_strides_for_nocopy_reshape[] = "_get_strides_for_nocopy_reshape(ndarray a, vector[Py_ssize_t] newshape) -> vector[Py_ssize_t]";
static PyObject *__pyx_pw_4cupy_4core_4core_1_get_strides_for_nocopy_reshape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  std::vector<Py_ssize_t>  __pyx_v_newshape;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_strides_for_nocopy_reshape (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_newshape,0};
    PyObject* values[2] = {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  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_a)) != 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_newshape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_strides_for_nocopy_reshape", 1, 2, 2, 1); __PYX_ERR(0, 1803, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_strides_for_nocopy_reshape") < 0)) __PYX_ERR(0, 1803, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_newshape = __pyx_convert_vector_from_py_Py_ssize_t(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1804, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_strides_for_nocopy_reshape", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1803, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_strides_for_nocopy_reshape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 1804, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core__get_strides_for_nocopy_reshape(__pyx_self, __pyx_v_a, __pyx_v_newshape);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core__get_strides_for_nocopy_reshape(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, std::vector<Py_ssize_t>  __pyx_v_newshape) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  std::vector<Py_ssize_t>  __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("_get_strides_for_nocopy_reshape", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_strides_for_nocopy_reshape(__pyx_v_a, __pyx_v_newshape, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1803, __pyx_L1_error)
  __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core._get_strides_for_nocopy_reshape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/carray.pxi":22
 *         _CArray val
 * 
 *     def __init__(self, ndarray arr):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i
 *         cdef int ndim = arr._shape.size()
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_6CArray_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_4core_4core_6CArray_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,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_arr)) != 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(2, 22, __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_arr = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)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(2, 22, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.CArray.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "arr", 0))) __PYX_ERR(2, 22, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_6CArray___init__(((struct __pyx_obj_4cupy_4core_4core_CArray *)__pyx_v_self), __pyx_v_arr);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_6CArray___init__(struct __pyx_obj_4cupy_4core_4core_CArray *__pyx_v_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr) {
  Py_ssize_t __pyx_v_i;
  int __pyx_v_ndim;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/carray.pxi":24
 *     def __init__(self, ndarray arr):
 *         cdef Py_ssize_t i
 *         cdef int ndim = arr._shape.size()             # <<<<<<<<<<<<<<
 *         self.val.data = <void*>arr.data.ptr
 *         self.val.size = arr.size
 */
  __pyx_v_ndim = __pyx_v_arr->_shape.size();

  /* "cupy/core/carray.pxi":25
 *         cdef Py_ssize_t i
 *         cdef int ndim = arr._shape.size()
 *         self.val.data = <void*>arr.data.ptr             # <<<<<<<<<<<<<<
 *         self.val.size = arr.size
 *         for i in range(ndim):
 */
  __pyx_v_self->val.data = ((void *)__pyx_v_arr->data->ptr);

  /* "cupy/core/carray.pxi":26
 *         cdef int ndim = arr._shape.size()
 *         self.val.data = <void*>arr.data.ptr
 *         self.val.size = arr.size             # <<<<<<<<<<<<<<
 *         for i in range(ndim):
 *             self.val.shape_and_strides[i] = arr._shape[i]
 */
  __pyx_t_1 = __pyx_v_arr->size;
  __pyx_v_self->val.size = __pyx_t_1;

  /* "cupy/core/carray.pxi":27
 *         self.val.data = <void*>arr.data.ptr
 *         self.val.size = arr.size
 *         for i in range(ndim):             # <<<<<<<<<<<<<<
 *             self.val.shape_and_strides[i] = arr._shape[i]
 *             self.val.shape_and_strides[i + ndim] = arr._strides[i]
 */
  __pyx_t_2 = __pyx_v_ndim;
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "cupy/core/carray.pxi":28
 *         self.val.size = arr.size
 *         for i in range(ndim):
 *             self.val.shape_and_strides[i] = arr._shape[i]             # <<<<<<<<<<<<<<
 *             self.val.shape_and_strides[i + ndim] = arr._strides[i]
 *         self.ptr = <void*>&self.val
 */
    (__pyx_v_self->val.shape_and_strides[__pyx_v_i]) = (__pyx_v_arr->_shape[__pyx_v_i]);

    /* "cupy/core/carray.pxi":29
 *         for i in range(ndim):
 *             self.val.shape_and_strides[i] = arr._shape[i]
 *             self.val.shape_and_strides[i + ndim] = arr._strides[i]             # <<<<<<<<<<<<<<
 *         self.ptr = <void*>&self.val
 * 
 */
    (__pyx_v_self->val.shape_and_strides[(__pyx_v_i + __pyx_v_ndim)]) = (__pyx_v_arr->_strides[__pyx_v_i]);
  }

  /* "cupy/core/carray.pxi":30
 *             self.val.shape_and_strides[i] = arr._shape[i]
 *             self.val.shape_and_strides[i + ndim] = arr._strides[i]
 *         self.ptr = <void*>&self.val             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_self->__pyx_base.ptr = ((void *)(&__pyx_v_self->val));

  /* "cupy/core/carray.pxi":22
 *         _CArray val
 * 
 *     def __init__(self, ndarray arr):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i
 *         cdef int ndim = arr._shape.size()
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_6CArray_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_6CArray_2__reduce_cython__[] = "CArray.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_6CArray_3__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_4cupy_4core_4core_6CArray_2__reduce_cython__(((struct __pyx_obj_4cupy_4core_4core_CArray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_6CArray_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_CArray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 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(4, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.CArray.__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("self.ptr,self.val cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_6CArray_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_4core_4core_6CArray_4__setstate_cython__[] = "CArray.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_4core_4core_6CArray_5__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_4cupy_4core_4core_6CArray_4__setstate_cython__(((struct __pyx_obj_4cupy_4core_4core_CArray *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_6CArray_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_CArray *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 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(4, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.CArray.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/carray.pxi":42
 *         _CIndexer val
 * 
 *     def __init__(self, Py_ssize_t size, tuple shape):             # <<<<<<<<<<<<<<
 *         self.val.size = size
 *         cdef Py_ssize_t i
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_8CIndexer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_4core_4core_8CIndexer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  Py_ssize_t __pyx_v_size;
  PyObject *__pyx_v_shape = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_size,&__pyx_n_s_shape,0};
    PyObject* values[2] = {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  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_size)) != 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_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(2, 42, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(2, 42, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_size = __Pyx_PyIndex_AsSsize_t(values[0]); if (unlikely((__pyx_v_size == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 42, __pyx_L3_error)
    __pyx_v_shape = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 42, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.CIndexer.__init__", __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(2, 42, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_8CIndexer___init__(((struct __pyx_obj_4cupy_4core_4core_CIndexer *)__pyx_v_self), __pyx_v_size, __pyx_v_shape);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_8CIndexer___init__(struct __pyx_obj_4cupy_4core_4core_CIndexer *__pyx_v_self, Py_ssize_t __pyx_v_size, PyObject *__pyx_v_shape) {
  Py_ssize_t __pyx_v_i;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/carray.pxi":43
 * 
 *     def __init__(self, Py_ssize_t size, tuple shape):
 *         self.val.size = size             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i
 *         for i in range(len(shape)):
 */
  __pyx_v_self->val.size = __pyx_v_size;

  /* "cupy/core/carray.pxi":45
 *         self.val.size = size
 *         cdef Py_ssize_t i
 *         for i in range(len(shape)):             # <<<<<<<<<<<<<<
 *             self.val.shape_and_index[i] = shape[i]
 *         self.ptr = <void*>&self.val
 */
  if (unlikely(__pyx_v_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 45, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(2, 45, __pyx_L1_error)
  __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;

    /* "cupy/core/carray.pxi":46
 *         cdef Py_ssize_t i
 *         for i in range(len(shape)):
 *             self.val.shape_and_index[i] = shape[i]             # <<<<<<<<<<<<<<
 *         self.ptr = <void*>&self.val
 * 
 */
    if (unlikely(__pyx_v_shape == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 46, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 46, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 46, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    (__pyx_v_self->val.shape_and_index[__pyx_v_i]) = __pyx_t_5;
  }

  /* "cupy/core/carray.pxi":47
 *         for i in range(len(shape)):
 *             self.val.shape_and_index[i] = shape[i]
 *         self.ptr = <void*>&self.val             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_self->__pyx_base.ptr = ((void *)(&__pyx_v_self->val));

  /* "cupy/core/carray.pxi":42
 *         _CIndexer val
 * 
 *     def __init__(self, Py_ssize_t size, tuple shape):             # <<<<<<<<<<<<<<
 *         self.val.size = size
 *         cdef Py_ssize_t i
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.CIndexer.__init__", __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("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_8CIndexer_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_8CIndexer_2__reduce_cython__[] = "CIndexer.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_8CIndexer_3__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_4cupy_4core_4core_8CIndexer_2__reduce_cython__(((struct __pyx_obj_4cupy_4core_4core_CIndexer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_8CIndexer_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_CIndexer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 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(4, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.CIndexer.__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("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_8CIndexer_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_4core_4core_8CIndexer_4__setstate_cython__[] = "CIndexer.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_4core_4core_8CIndexer_5__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_4cupy_4core_4core_8CIndexer_4__setstate_cython__(((struct __pyx_obj_4cupy_4core_4core_CIndexer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_8CIndexer_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_CIndexer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 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(4, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.CIndexer.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/carray.pxi":51
 * 
 * cdef class Indexer:
 *     def __init__(self, tuple shape):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t size = 1
 *         for s in shape:
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7Indexer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7Indexer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_shape = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,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_shape)) != 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(2, 51, __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_shape = ((PyObject*)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(2, 51, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.Indexer.__init__", __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(2, 51, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_7Indexer___init__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self), __pyx_v_shape);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_7Indexer___init__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self, PyObject *__pyx_v_shape) {
  Py_ssize_t __pyx_v_size;
  PyObject *__pyx_v_s = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/carray.pxi":52
 * cdef class Indexer:
 *     def __init__(self, tuple shape):
 *         cdef Py_ssize_t size = 1             # <<<<<<<<<<<<<<
 *         for s in shape:
 *             size *= s
 */
  __pyx_v_size = 1;

  /* "cupy/core/carray.pxi":53
 *     def __init__(self, tuple shape):
 *         cdef Py_ssize_t size = 1
 *         for s in shape:             # <<<<<<<<<<<<<<
 *             size *= s
 *         self.shape = shape
 */
  if (unlikely(__pyx_v_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(2, 53, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 53, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 53, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/carray.pxi":54
 *         cdef Py_ssize_t size = 1
 *         for s in shape:
 *             size *= s             # <<<<<<<<<<<<<<
 *         self.shape = shape
 *         self.size = size
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 54, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_InPlaceMultiply(__pyx_t_3, __pyx_v_s); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 54, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 54, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_size = __pyx_t_5;

    /* "cupy/core/carray.pxi":53
 *     def __init__(self, tuple shape):
 *         cdef Py_ssize_t size = 1
 *         for s in shape:             # <<<<<<<<<<<<<<
 *             size *= s
 *         self.shape = shape
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/carray.pxi":55
 *         for s in shape:
 *             size *= s
 *         self.shape = shape             # <<<<<<<<<<<<<<
 *         self.size = size
 * 
 */
  __Pyx_INCREF(__pyx_v_shape);
  __Pyx_GIVEREF(__pyx_v_shape);
  __Pyx_GOTREF(__pyx_v_self->shape);
  __Pyx_DECREF(__pyx_v_self->shape);
  __pyx_v_self->shape = __pyx_v_shape;

  /* "cupy/core/carray.pxi":56
 *             size *= s
 *         self.shape = shape
 *         self.size = size             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_v_self->size = __pyx_v_size;

  /* "cupy/core/carray.pxi":51
 * 
 * cdef class Indexer:
 *     def __init__(self, tuple shape):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t size = 1
 *         for s in shape:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.Indexer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/carray.pxi":59
 * 
 *     @property
 *     def ndim(self):             # <<<<<<<<<<<<<<
 *         return len(self.shape)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_4ndim_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_4ndim_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7Indexer_4ndim___get__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_4ndim___get__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/carray.pxi":60
 *     @property
 *     def ndim(self):
 *         return len(self.shape)             # <<<<<<<<<<<<<<
 * 
 *     cdef CPointer get_pointer(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_v_self->shape;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 60, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(2, 60, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/carray.pxi":59
 * 
 *     @property
 *     def ndim(self):             # <<<<<<<<<<<<<<
 *         return len(self.shape)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.Indexer.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/carray.pxi":62
 *         return len(self.shape)
 * 
 *     cdef CPointer get_pointer(self):             # <<<<<<<<<<<<<<
 *         return CIndexer(self.size, self.shape)
 * 
 */

static struct __pyx_obj_4cupy_4cuda_8function_CPointer *__pyx_f_4cupy_4core_4core_7Indexer_get_pointer(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self) {
  struct __pyx_obj_4cupy_4cuda_8function_CPointer *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("get_pointer", 0);

  /* "cupy/core/carray.pxi":63
 * 
 *     cdef CPointer get_pointer(self):
 *         return CIndexer(self.size, self.shape)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->shape);
  __Pyx_GIVEREF(__pyx_v_self->shape);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->shape);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_CIndexer), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = ((struct __pyx_obj_4cupy_4cuda_8function_CPointer *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/carray.pxi":62
 *         return len(self.shape)
 * 
 *     cdef CPointer get_pointer(self):             # <<<<<<<<<<<<<<
 *         return CIndexer(self.size, self.shape)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.Indexer.get_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pxd":72
 * cdef class Indexer:
 *     cdef:
 *         readonly Py_ssize_t size             # <<<<<<<<<<<<<<
 *         readonly tuple shape
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_4size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_4size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7Indexer_4size___get__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_4size___get__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.Indexer.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pxd":73
 *     cdef:
 *         readonly Py_ssize_t size
 *         readonly tuple shape             # <<<<<<<<<<<<<<
 * 
 *     cdef CPointer get_pointer(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_5shape_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7Indexer_5shape___get__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_5shape___get__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->shape);
  __pyx_r = __pyx_v_self->shape;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.shape, self.size)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7Indexer_2__reduce_cython__[] = "Indexer.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_3__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_4cupy_4core_4core_7Indexer_2__reduce_cython__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_2__reduce_cython__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.shape, self.size)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->shape);
  __Pyx_GIVEREF(__pyx_v_self->shape);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->shape);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.shape, self.size)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__dict = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "(tree fragment)":5
 *     state = (self.shape, self.size)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_3 = (__pyx_v__dict != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.shape is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.shape, self.size)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.shape is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, None), state
 */
  /*else*/ {
    __pyx_t_4 = (__pyx_v_self->shape != ((PyObject*)Py_None));
    __pyx_v_use_setstate = __pyx_t_4;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.shape is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, None), state
 *     else:
 */
  __pyx_t_4 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":11
 *         use_setstate = self.shape is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_Indexer); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_114586425);
    __Pyx_GIVEREF(__pyx_int_114586425);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_114586425);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.shape is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, None), state
 *     else:
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Indexer__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_Indexer); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_114586425);
    __Pyx_GIVEREF(__pyx_int_114586425);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_114586425);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.shape, self.size)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.Indexer.__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)":14
 *     else:
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Indexer__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7Indexer_4__setstate_cython__[] = "Indexer.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_5__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_4cupy_4core_4core_7Indexer_4__setstate_cython__(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_4__setstate_cython__(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Indexer__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(4, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core___pyx_unpickle_Indexer__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_Indexer, (type(self), 0x6d47339, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Indexer__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("cupy.core.core.Indexer.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/carray.pxi":103
 * 
 * 
 * cpdef str _get_header_dir_path():             # <<<<<<<<<<<<<<
 *     global _header_path_cache
 *     if _header_path_cache is None:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_3_get_header_dir_path(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_header_dir_path(CYTHON_UNUSED int __pyx_skip_dispatch) {
  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;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("_get_header_dir_path", 0);

  /* "cupy/core/carray.pxi":105
 * cpdef str _get_header_dir_path():
 *     global _header_path_cache
 *     if _header_path_cache is None:             # <<<<<<<<<<<<<<
 *         # Cython cannot use __file__ in global scope
 *         _header_path_cache = os.path.abspath(
 */
  __pyx_t_1 = (__pyx_v_4cupy_4core_4core__header_path_cache == ((PyObject*)Py_None));
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/carray.pxi":107
 *     if _header_path_cache is None:
 *         # Cython cannot use __file__ in global scope
 *         _header_path_cache = os.path.abspath(             # <<<<<<<<<<<<<<
 *             os.path.join(os.path.dirname(__file__), 'include'))
 *     return _header_path_cache
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_path); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_abspath); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/carray.pxi":108
 *         # Cython cannot use __file__ in global scope
 *         _header_path_cache = os.path.abspath(
 *             os.path.join(os.path.dirname(__file__), 'include'))             # <<<<<<<<<<<<<<
 *     return _header_path_cache
 * 
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_join); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_path); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dirname); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_file); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 108, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_7);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 108, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 108, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 108, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 108, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    __pyx_t_12 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_12 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_7, __pyx_n_s_include};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 108, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_7, __pyx_n_s_include};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 108, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 108, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_12, __pyx_t_7);
      __Pyx_INCREF(__pyx_n_s_include);
      __Pyx_GIVEREF(__pyx_n_s_include);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_12, __pyx_n_s_include);
      __pyx_t_7 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 108, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 107, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 107, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 107, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 107, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 107, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/carray.pxi":107
 *     if _header_path_cache is None:
 *         # Cython cannot use __file__ in global scope
 *         _header_path_cache = os.path.abspath(             # <<<<<<<<<<<<<<
 *             os.path.join(os.path.dirname(__file__), 'include'))
 *     return _header_path_cache
 */
    if (!(likely(PyString_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(2, 107, __pyx_L1_error)
    __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__header_path_cache);
    __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__header_path_cache, ((PyObject*)__pyx_t_3));
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/carray.pxi":105
 * cpdef str _get_header_dir_path():
 *     global _header_path_cache
 *     if _header_path_cache is None:             # <<<<<<<<<<<<<<
 *         # Cython cannot use __file__ in global scope
 *         _header_path_cache = os.path.abspath(
 */
  }

  /* "cupy/core/carray.pxi":109
 *         _header_path_cache = os.path.abspath(
 *             os.path.join(os.path.dirname(__file__), 'include'))
 *     return _header_path_cache             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__header_path_cache);
  __pyx_r = __pyx_v_4cupy_4core_4core__header_path_cache;
  goto __pyx_L0;

  /* "cupy/core/carray.pxi":103
 * 
 * 
 * cpdef str _get_header_dir_path():             # <<<<<<<<<<<<<<
 *     global _header_path_cache
 *     if _header_path_cache is None:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core._get_header_dir_path", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_3_get_header_dir_path(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_2_get_header_dir_path[] = "_get_header_dir_path() -> str";
static PyObject *__pyx_pw_4cupy_4core_4core_3_get_header_dir_path(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_header_dir_path (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_2_get_header_dir_path(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_2_get_header_dir_path(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_header_dir_path", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_header_dir_path(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 103, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_header_dir_path", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/carray.pxi":112
 * 
 * 
 * cpdef str _get_header_source():             # <<<<<<<<<<<<<<
 *     global _header_source
 *     if _header_source is None:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_5_get_header_source(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_header_source(CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_source = NULL;
  PyObject *__pyx_v_base_path = NULL;
  PyObject *__pyx_v_file_path = NULL;
  PyObject *__pyx_v_header_path = NULL;
  PyObject *__pyx_v_header_file = NULL;
  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 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  __Pyx_RefNannySetupContext("_get_header_source", 0);

  /* "cupy/core/carray.pxi":114
 * cpdef str _get_header_source():
 *     global _header_source
 *     if _header_source is None:             # <<<<<<<<<<<<<<
 *         source = []
 *         base_path = _get_header_dir_path()
 */
  __pyx_t_1 = (__pyx_v_4cupy_4core_4core__header_source == ((PyObject*)Py_None));
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/carray.pxi":115
 *     global _header_source
 *     if _header_source is None:
 *         source = []             # <<<<<<<<<<<<<<
 *         base_path = _get_header_dir_path()
 *         for file_path in _cupy_header_list + _cupy_extra_header_list:
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 115, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_source = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/carray.pxi":116
 *     if _header_source is None:
 *         source = []
 *         base_path = _get_header_dir_path()             # <<<<<<<<<<<<<<
 *         for file_path in _cupy_header_list + _cupy_extra_header_list:
 *             header_path = os.path.join(base_path, file_path)
 */
    __pyx_t_3 = __pyx_f_4cupy_4core_4core__get_header_dir_path(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 116, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_base_path = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/carray.pxi":117
 *         source = []
 *         base_path = _get_header_dir_path()
 *         for file_path in _cupy_header_list + _cupy_extra_header_list:             # <<<<<<<<<<<<<<
 *             header_path = os.path.join(base_path, file_path)
 *             with open(header_path) as header_file:
 */
    __pyx_t_3 = PyNumber_Add(__pyx_v_4cupy_4core_4core__cupy_header_list, __pyx_v_4cupy_4core_4core__cupy_extra_header_list); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(2, 117, __pyx_L1_error)
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 117, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_file_path, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/carray.pxi":118
 *         base_path = _get_header_dir_path()
 *         for file_path in _cupy_header_list + _cupy_extra_header_list:
 *             header_path = os.path.join(base_path, file_path)             # <<<<<<<<<<<<<<
 *             with open(header_path) as header_file:
 *                 source.append(header_file.read())
 */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 118, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 118, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_join); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 118, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_base_path, __pyx_v_file_path};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 118, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_base_path, __pyx_v_file_path};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 118, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 118, __pyx_L1_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_INCREF(__pyx_v_base_path);
        __Pyx_GIVEREF(__pyx_v_base_path);
        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_base_path);
        __Pyx_INCREF(__pyx_v_file_path);
        __Pyx_GIVEREF(__pyx_v_file_path);
        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_file_path);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 118, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_v_header_path, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/carray.pxi":119
 *         for file_path in _cupy_header_list + _cupy_extra_header_list:
 *             header_path = os.path.join(base_path, file_path)
 *             with open(header_path) as header_file:             # <<<<<<<<<<<<<<
 *                 source.append(header_file.read())
 *         _header_source = '\n'.join(source)
 */
      /*with:*/ {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_open, __pyx_v_header_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 119, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_exit); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 119, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_enter); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 119, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_7 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
          if (likely(__pyx_t_7)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_9, function);
          }
        }
        if (__pyx_t_7) {
          __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 119, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        } else {
          __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 119, __pyx_L6_error)
        }
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = __pyx_t_6;
        __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        /*try:*/ {
          {
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_13);
            /*try:*/ {
              __Pyx_XDECREF_SET(__pyx_v_header_file, __pyx_t_9);
              __pyx_t_9 = 0;

              /* "cupy/core/carray.pxi":120
 *             header_path = os.path.join(base_path, file_path)
 *             with open(header_path) as header_file:
 *                 source.append(header_file.read())             # <<<<<<<<<<<<<<
 *         _header_source = '\n'.join(source)
 *     return _header_source
 */
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_header_file, __pyx_n_s_read); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 120, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_6 = NULL;
              if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
                __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
                if (likely(__pyx_t_6)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                  __Pyx_INCREF(__pyx_t_6);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_3, function);
                }
              }
              if (__pyx_t_6) {
                __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 120, __pyx_L12_error)
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              } else {
                __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 120, __pyx_L12_error)
              }
              __Pyx_GOTREF(__pyx_t_9);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_source, __pyx_t_9); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(2, 120, __pyx_L12_error)
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

              /* "cupy/core/carray.pxi":119
 *         for file_path in _cupy_header_list + _cupy_extra_header_list:
 *             header_path = os.path.join(base_path, file_path)
 *             with open(header_path) as header_file:             # <<<<<<<<<<<<<<
 *                 source.append(header_file.read())
 *         _header_source = '\n'.join(source)
 */
            }
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            goto __pyx_L19_try_end;
            __pyx_L12_error:;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("cupy.core.core._get_header_source", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_3, &__pyx_t_6) < 0) __PYX_ERR(2, 119, __pyx_L14_except_error)
              __Pyx_GOTREF(__pyx_t_9);
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_7 = PyTuple_Pack(3, __pyx_t_9, __pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 119, __pyx_L14_except_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_7, NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 119, __pyx_L14_except_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_15);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_t_2 < 0) __PYX_ERR(2, 119, __pyx_L14_except_error)
              __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
              if (__pyx_t_1) {
                __Pyx_GIVEREF(__pyx_t_9);
                __Pyx_GIVEREF(__pyx_t_3);
                __Pyx_XGIVEREF(__pyx_t_6);
                __Pyx_ErrRestoreWithState(__pyx_t_9, __pyx_t_3, __pyx_t_6);
                __pyx_t_9 = 0; __pyx_t_3 = 0; __pyx_t_6 = 0; 
                __PYX_ERR(2, 119, __pyx_L14_except_error)
              }
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              goto __pyx_L13_exception_handled;
            }
            __pyx_L14_except_error:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            goto __pyx_L1_error;
            __pyx_L13_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            __pyx_L19_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_10) {
              __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__52, NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 119, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            }
            goto __pyx_L11;
          }
          __pyx_L11:;
        }
        goto __pyx_L23;
        __pyx_L6_error:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L1_error;
        __pyx_L23:;
      }

      /* "cupy/core/carray.pxi":117
 *         source = []
 *         base_path = _get_header_dir_path()
 *         for file_path in _cupy_header_list + _cupy_extra_header_list:             # <<<<<<<<<<<<<<
 *             header_path = os.path.join(base_path, file_path)
 *             with open(header_path) as header_file:
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/carray.pxi":121
 *             with open(header_path) as header_file:
 *                 source.append(header_file.read())
 *         _header_source = '\n'.join(source)             # <<<<<<<<<<<<<<
 *     return _header_source
 * 
 */
    __pyx_t_4 = __Pyx_PyString_Join(__pyx_kp_s__53, __pyx_v_source); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(2, 121, __pyx_L1_error)
    __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__header_source);
    __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__header_source, ((PyObject*)__pyx_t_4));
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/carray.pxi":114
 * cpdef str _get_header_source():
 *     global _header_source
 *     if _header_source is None:             # <<<<<<<<<<<<<<
 *         source = []
 *         base_path = _get_header_dir_path()
 */
  }

  /* "cupy/core/carray.pxi":122
 *                 source.append(header_file.read())
 *         _header_source = '\n'.join(source)
 *     return _header_source             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__header_source);
  __pyx_r = __pyx_v_4cupy_4core_4core__header_source;
  goto __pyx_L0;

  /* "cupy/core/carray.pxi":112
 * 
 * 
 * cpdef str _get_header_source():             # <<<<<<<<<<<<<<
 *     global _header_source
 *     if _header_source is None:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core._get_header_source", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF(__pyx_v_base_path);
  __Pyx_XDECREF(__pyx_v_file_path);
  __Pyx_XDECREF(__pyx_v_header_path);
  __Pyx_XDECREF(__pyx_v_header_file);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_5_get_header_source(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_4_get_header_source[] = "_get_header_source() -> str";
static PyObject *__pyx_pw_4cupy_4core_4core_5_get_header_source(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_header_source (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_4_get_header_source(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_4_get_header_source(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_header_source", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_header_source(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_header_source", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/carray.pxi":125
 * 
 * 
 * cpdef function.Module compile_with_cache(             # <<<<<<<<<<<<<<
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _cupy_header + source
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7compile_with_cache(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_f_4cupy_4core_4core_compile_with_cache(PyObject *__pyx_v_source, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache *__pyx_optional_args) {

  /* "cupy/core/carray.pxi":126
 * 
 * cpdef function.Module compile_with_cache(
 *         str source, tuple options=(), arch=None, cachd_dir=None):             # <<<<<<<<<<<<<<
 *     source = _cupy_header + source
 *     extra_source = _get_header_source()
 */
  PyObject *__pyx_v_options = ((PyObject*)__pyx_empty_tuple);
  PyObject *__pyx_v_arch = ((PyObject *)Py_None);
  PyObject *__pyx_v_cachd_dir = ((PyObject *)Py_None);
  PyObject *__pyx_v_extra_source = NULL;
  PyObject *__pyx_v_cuda_path = NULL;
  PyObject *__pyx_v_path = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __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;
  __Pyx_RefNannySetupContext("compile_with_cache", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_options = __pyx_optional_args->options;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_arch = __pyx_optional_args->arch;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_cachd_dir = __pyx_optional_args->cachd_dir;
        }
      }
    }
  }
  __Pyx_INCREF(__pyx_v_source);
  __Pyx_INCREF(__pyx_v_options);

  /* "cupy/core/carray.pxi":127
 * cpdef function.Module compile_with_cache(
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _cupy_header + source             # <<<<<<<<<<<<<<
 *     extra_source = _get_header_source()
 *     options += ('-I%s' % _get_header_dir_path(),)
 */
  __pyx_t_1 = PyNumber_Add(__pyx_v_4cupy_4core_4core__cupy_header, __pyx_v_source); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_source, ((PyObject*)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/core/carray.pxi":128
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _cupy_header + source
 *     extra_source = _get_header_source()             # <<<<<<<<<<<<<<
 *     options += ('-I%s' % _get_header_dir_path(),)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_header_source(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_extra_source = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/carray.pxi":129
 *     source = _cupy_header + source
 *     extra_source = _get_header_source()
 *     options += ('-I%s' % _get_header_dir_path(),)             # <<<<<<<<<<<<<<
 * 
 *     # The variable _cuda_runtime_version is declared in cupy/core/core.pyx,
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_header_dir_path(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_I_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_options, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_options, ((PyObject*)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/core/carray.pxi":134
 *     # but it might not have been set appropriately before coming here.
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  __pyx_t_3 = (__pyx_v_4cupy_4core_4core__cuda_runtime_version == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/carray.pxi":135
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:
 *         _cuda_runtime_version = runtime.runtimeGetVersion()             # <<<<<<<<<<<<<<
 * 
 *     if _cuda_runtime_version >= 9000:
 */
    __pyx_t_5 = __pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 135, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cuda_runtime_version);
    __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cuda_runtime_version, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/carray.pxi":134
 *     # but it might not have been set appropriately before coming here.
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  }

  /* "cupy/core/carray.pxi":137
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 *     if _cuda_runtime_version >= 9000:             # <<<<<<<<<<<<<<
 *         cuda_path = cuda.get_cuda_path()
 *         if cuda_path is None:
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_4cupy_4core_4core__cuda_runtime_version, __pyx_int_9000, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 137, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 137, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/carray.pxi":138
 * 
 *     if _cuda_runtime_version >= 9000:
 *         cuda_path = cuda.get_cuda_path()             # <<<<<<<<<<<<<<
 *         if cuda_path is None:
 *             warnings.warn('Please set the CUDA path ' +
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get_cuda_path); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_1) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 138, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 138, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_cuda_path = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "cupy/core/carray.pxi":139
 *     if _cuda_runtime_version >= 9000:
 *         cuda_path = cuda.get_cuda_path()
 *         if cuda_path is None:             # <<<<<<<<<<<<<<
 *             warnings.warn('Please set the CUDA path ' +
 *                           'to environment variable `CUDA_PATH`')
 */
    __pyx_t_4 = (__pyx_v_cuda_path == Py_None);
    __pyx_t_3 = (__pyx_t_4 != 0);
    if (__pyx_t_3) {

      /* "cupy/core/carray.pxi":140
 *         cuda_path = cuda.get_cuda_path()
 *         if cuda_path is None:
 *             warnings.warn('Please set the CUDA path ' +             # <<<<<<<<<<<<<<
 *                           'to environment variable `CUDA_PATH`')
 *         else:
 */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_warnings); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 140, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_warn); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 140, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyNumber_Add(__pyx_kp_s_Please_set_the_CUDA_path, __pyx_kp_s_to_environment_variable_CUDA_PAT); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 140, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (!__pyx_t_7) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 140, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_1)) {
          PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 140, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
          PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 140, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        } else
        #endif
        {
          __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 140, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
          __Pyx_GIVEREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
          __pyx_t_6 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 140, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/core/carray.pxi":139
 *     if _cuda_runtime_version >= 9000:
 *         cuda_path = cuda.get_cuda_path()
 *         if cuda_path is None:             # <<<<<<<<<<<<<<
 *             warnings.warn('Please set the CUDA path ' +
 *                           'to environment variable `CUDA_PATH`')
 */
      goto __pyx_L5;
    }

    /* "cupy/core/carray.pxi":143
 *                           'to environment variable `CUDA_PATH`')
 *         else:
 *             path = os.path.join(cuda_path, 'include')             # <<<<<<<<<<<<<<
 *             options += ('-I ' + path,)
 * 
 */
    /*else*/ {
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_path); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_join); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_cuda_path, __pyx_n_s_include};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 143, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_cuda_path, __pyx_n_s_include};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 143, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 143, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_8) {
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL;
        }
        __Pyx_INCREF(__pyx_v_cuda_path);
        __Pyx_GIVEREF(__pyx_v_cuda_path);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_cuda_path);
        __Pyx_INCREF(__pyx_n_s_include);
        __Pyx_GIVEREF(__pyx_n_s_include);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_n_s_include);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 143, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_path = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "cupy/core/carray.pxi":144
 *         else:
 *             path = os.path.join(cuda_path, 'include')
 *             options += ('-I ' + path,)             # <<<<<<<<<<<<<<
 * 
 *     return cuda.compile_with_cache(source, options, arch, cachd_dir,
 */
      __pyx_t_2 = PyNumber_Add(__pyx_kp_s_I, __pyx_v_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 144, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 144, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_options, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 144, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_options, ((PyObject*)__pyx_t_2));
      __pyx_t_2 = 0;
    }
    __pyx_L5:;

    /* "cupy/core/carray.pxi":137
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 *     if _cuda_runtime_version >= 9000:             # <<<<<<<<<<<<<<
 *         cuda_path = cuda.get_cuda_path()
 *         if cuda_path is None:
 */
  }

  /* "cupy/core/carray.pxi":146
 *             options += ('-I ' + path,)
 * 
 *     return cuda.compile_with_cache(source, options, arch, cachd_dir,             # <<<<<<<<<<<<<<
 *                                    extra_source)
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile_with_cache); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/carray.pxi":147
 * 
 *     return cuda.compile_with_cache(source, options, arch, cachd_dir,
 *                                    extra_source)             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_v_source, __pyx_v_options, __pyx_v_arch, __pyx_v_cachd_dir, __pyx_v_extra_source};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 146, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_v_source, __pyx_v_options, __pyx_v_arch, __pyx_v_cachd_dir, __pyx_v_extra_source};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 146, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(__pyx_v_source);
    __Pyx_GIVEREF(__pyx_v_source);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_5, __pyx_v_source);
    __Pyx_INCREF(__pyx_v_options);
    __Pyx_GIVEREF(__pyx_v_options);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_5, __pyx_v_options);
    __Pyx_INCREF(__pyx_v_arch);
    __Pyx_GIVEREF(__pyx_v_arch);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_5, __pyx_v_arch);
    __Pyx_INCREF(__pyx_v_cachd_dir);
    __Pyx_GIVEREF(__pyx_v_cachd_dir);
    PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_5, __pyx_v_cachd_dir);
    __Pyx_INCREF(__pyx_v_extra_source);
    __Pyx_GIVEREF(__pyx_v_extra_source);
    PyTuple_SET_ITEM(__pyx_t_8, 4+__pyx_t_5, __pyx_v_extra_source);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/carray.pxi":146
 *             options += ('-I ' + path,)
 * 
 *     return cuda.compile_with_cache(source, options, arch, cachd_dir,             # <<<<<<<<<<<<<<
 *                                    extra_source)
 */
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4cuda_8function_Module))))) __PYX_ERR(2, 146, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/carray.pxi":125
 * 
 * 
 * cpdef function.Module compile_with_cache(             # <<<<<<<<<<<<<<
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _cupy_header + source
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.core.core.compile_with_cache", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_extra_source);
  __Pyx_XDECREF(__pyx_v_cuda_path);
  __Pyx_XDECREF(__pyx_v_path);
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF(__pyx_v_options);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7compile_with_cache(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_6compile_with_cache[] = "compile_with_cache(str source, tuple options=(), arch=None, cachd_dir=None) -> Module";
static PyObject *__pyx_pw_4cupy_4core_4core_7compile_with_cache(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_source = 0;
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_v_arch = 0;
  PyObject *__pyx_v_cachd_dir = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compile_with_cache (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,&__pyx_n_s_options,&__pyx_n_s_arch,&__pyx_n_s_cachd_dir,0};
    PyObject* values[4] = {0,0,0,0};

    /* "cupy/core/carray.pxi":126
 * 
 * cpdef function.Module compile_with_cache(
 *         str source, tuple options=(), arch=None, cachd_dir=None):             # <<<<<<<<<<<<<<
 *     source = _cupy_header + source
 *     extra_source = _get_header_source()
 */
    values[1] = ((PyObject*)__pyx_empty_tuple);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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_source)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_options);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arch);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cachd_dir);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compile_with_cache") < 0)) __PYX_ERR(2, 125, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_source = ((PyObject*)values[0]);
    __pyx_v_options = ((PyObject*)values[1]);
    __pyx_v_arch = values[2];
    __pyx_v_cachd_dir = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("compile_with_cache", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 125, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.compile_with_cache", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_source), (&PyString_Type), 1, "source", 1))) __PYX_ERR(2, 126, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_options), (&PyTuple_Type), 1, "options", 1))) __PYX_ERR(2, 126, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_6compile_with_cache(__pyx_self, __pyx_v_source, __pyx_v_options, __pyx_v_arch, __pyx_v_cachd_dir);

  /* "cupy/core/carray.pxi":125
 * 
 * 
 * cpdef function.Module compile_with_cache(             # <<<<<<<<<<<<<<
 *         str source, tuple options=(), arch=None, cachd_dir=None):
 *     source = _cupy_header + source
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_6compile_with_cache(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_source, PyObject *__pyx_v_options, PyObject *__pyx_v_arch, PyObject *__pyx_v_cachd_dir) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache __pyx_t_2;
  __Pyx_RefNannySetupContext("compile_with_cache", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.options = __pyx_v_options;
  __pyx_t_2.arch = __pyx_v_arch;
  __pyx_t_2.cachd_dir = __pyx_v_cachd_dir;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(__pyx_v_source, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.compile_with_cache", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":14
 * 
 * 
 * cpdef _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_9_get_simple_elementwise_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_simple_elementwise_kernel(PyObject *__pyx_v_params, PyObject *__pyx_v_operation, PyObject *__pyx_v_name, PyObject *__pyx_v_preamble, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__get_simple_elementwise_kernel *__pyx_optional_args) {
  PyObject *__pyx_v_loop_prep = ((PyObject *)__pyx_kp_s__6);
  PyObject *__pyx_v_after_loop = ((PyObject *)__pyx_kp_s__6);

  /* "cupy/core/elementwise.pxi":16
 * cpdef _get_simple_elementwise_kernel(
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):             # <<<<<<<<<<<<<<
 *     module_code = string.Template('''
 *     ${preamble}
 */
  PyObject *__pyx_v_options = ((PyObject *)__pyx_empty_tuple);
  PyObject *__pyx_v_module_code = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_v_module = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache __pyx_t_4;
  __Pyx_RefNannySetupContext("_get_simple_elementwise_kernel", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_loop_prep = __pyx_optional_args->loop_prep;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_after_loop = __pyx_optional_args->after_loop;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_options = __pyx_optional_args->options;
        }
      }
    }
  }

  /* "cupy/core/elementwise.pxi":17
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):
 *     module_code = string.Template('''             # <<<<<<<<<<<<<<
 *     ${preamble}
 *     extern "C" __global__ void ${name}(${params}) {
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Template); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":27
 *       ${after_loop};
 *     }
 *     ''').substitute(             # <<<<<<<<<<<<<<
 *         params=params,
 *         operation=operation,
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_substitute); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":28
 *     }
 *     ''').substitute(
 *         params=params,             # <<<<<<<<<<<<<<
 *         operation=operation,
 *         name=name,
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_params, __pyx_v_params) < 0) __PYX_ERR(1, 28, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":29
 *     ''').substitute(
 *         params=params,
 *         operation=operation,             # <<<<<<<<<<<<<<
 *         name=name,
 *         preamble=preamble,
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_operation, __pyx_v_operation) < 0) __PYX_ERR(1, 28, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":30
 *         params=params,
 *         operation=operation,
 *         name=name,             # <<<<<<<<<<<<<<
 *         preamble=preamble,
 *         loop_prep=loop_prep,
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(1, 28, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":31
 *         operation=operation,
 *         name=name,
 *         preamble=preamble,             # <<<<<<<<<<<<<<
 *         loop_prep=loop_prep,
 *         after_loop=after_loop)
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_preamble, __pyx_v_preamble) < 0) __PYX_ERR(1, 28, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":32
 *         name=name,
 *         preamble=preamble,
 *         loop_prep=loop_prep,             # <<<<<<<<<<<<<<
 *         after_loop=after_loop)
 *     module = compile_with_cache(module_code, options)
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_loop_prep, __pyx_v_loop_prep) < 0) __PYX_ERR(1, 28, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":33
 *         preamble=preamble,
 *         loop_prep=loop_prep,
 *         after_loop=after_loop)             # <<<<<<<<<<<<<<
 *     module = compile_with_cache(module_code, options)
 *     return module.get_function(name)
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_after_loop, __pyx_v_after_loop) < 0) __PYX_ERR(1, 28, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":27
 *       ${after_loop};
 *     }
 *     ''').substitute(             # <<<<<<<<<<<<<<
 *         params=params,
 *         operation=operation,
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_module_code = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":34
 *         loop_prep=loop_prep,
 *         after_loop=after_loop)
 *     module = compile_with_cache(module_code, options)             # <<<<<<<<<<<<<<
 *     return module.get_function(name)
 * 
 */
  if (!(likely(PyString_CheckExact(__pyx_v_module_code))||((__pyx_v_module_code) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_module_code)->tp_name), 0))) __PYX_ERR(1, 34, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_options))||((__pyx_v_options) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_options)->tp_name), 0))) __PYX_ERR(1, 34, __pyx_L1_error)
  __pyx_t_4.__pyx_n = 1;
  __pyx_t_4.options = ((PyObject*)__pyx_v_options);
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(((PyObject*)__pyx_v_module_code), 0, &__pyx_t_4)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 34, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_module = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":35
 *         after_loop=after_loop)
 *     module = compile_with_cache(module_code, options)
 *     return module.get_function(name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(1, 35, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *)__pyx_v_module->__pyx_vtab)->get_function(__pyx_v_module, ((PyObject*)__pyx_v_name), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":14
 * 
 * 
 * cpdef _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core._get_simple_elementwise_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_module_code);
  __Pyx_XDECREF((PyObject *)__pyx_v_module);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9_get_simple_elementwise_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_8_get_simple_elementwise_kernel[] = "_get_simple_elementwise_kernel(params, operation, name, preamble, loop_prep='', after_loop='', options=())";
static PyObject *__pyx_pw_4cupy_4core_4core_9_get_simple_elementwise_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_operation = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_loop_prep = 0;
  PyObject *__pyx_v_after_loop = 0;
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_simple_elementwise_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_params,&__pyx_n_s_operation,&__pyx_n_s_name,&__pyx_n_s_preamble,&__pyx_n_s_loop_prep,&__pyx_n_s_after_loop,&__pyx_n_s_options,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    values[4] = ((PyObject *)__pyx_kp_s__6);
    values[5] = ((PyObject *)__pyx_kp_s__6);

    /* "cupy/core/elementwise.pxi":16
 * cpdef _get_simple_elementwise_kernel(
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):             # <<<<<<<<<<<<<<
 *     module_code = string.Template('''
 *     ${preamble}
 */
    values[6] = ((PyObject *)__pyx_empty_tuple);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_params)) != 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_operation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_elementwise_kernel", 0, 4, 7, 1); __PYX_ERR(1, 14, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_elementwise_kernel", 0, 4, 7, 2); __PYX_ERR(1, 14, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_preamble)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_elementwise_kernel", 0, 4, 7, 3); __PYX_ERR(1, 14, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_loop_prep);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_after_loop);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_options);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_simple_elementwise_kernel") < 0)) __PYX_ERR(1, 14, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 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_params = values[0];
    __pyx_v_operation = values[1];
    __pyx_v_name = values[2];
    __pyx_v_preamble = values[3];
    __pyx_v_loop_prep = values[4];
    __pyx_v_after_loop = values[5];
    __pyx_v_options = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_simple_elementwise_kernel", 0, 4, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 14, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_simple_elementwise_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_8_get_simple_elementwise_kernel(__pyx_self, __pyx_v_params, __pyx_v_operation, __pyx_v_name, __pyx_v_preamble, __pyx_v_loop_prep, __pyx_v_after_loop, __pyx_v_options);

  /* "cupy/core/elementwise.pxi":14
 * 
 * 
 * cpdef _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_8_get_simple_elementwise_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_params, PyObject *__pyx_v_operation, PyObject *__pyx_v_name, PyObject *__pyx_v_preamble, PyObject *__pyx_v_loop_prep, PyObject *__pyx_v_after_loop, PyObject *__pyx_v_options) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__get_simple_elementwise_kernel __pyx_t_2;
  __Pyx_RefNannySetupContext("_get_simple_elementwise_kernel", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.loop_prep = __pyx_v_loop_prep;
  __pyx_t_2.after_loop = __pyx_v_after_loop;
  __pyx_t_2.options = __pyx_v_options;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_simple_elementwise_kernel(__pyx_v_params, __pyx_v_operation, __pyx_v_name, __pyx_v_preamble, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_simple_elementwise_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":88
 * 
 * 
 * cpdef _python_scalar_to_numpy_scalar(x):             # <<<<<<<<<<<<<<
 *     # Note that isinstance(x, six_integer_types) matches with bool.
 *     if isinstance(x, bool):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_11_python_scalar_to_numpy_scalar(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__python_scalar_to_numpy_scalar(PyObject *__pyx_v_x, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_numpy_type = NULL;
  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;
  __Pyx_RefNannySetupContext("_python_scalar_to_numpy_scalar", 0);

  /* "cupy/core/elementwise.pxi":90
 * cpdef _python_scalar_to_numpy_scalar(x):
 *     # Note that isinstance(x, six_integer_types) matches with bool.
 *     if isinstance(x, bool):             # <<<<<<<<<<<<<<
 *         numpy_type = numpy.bool_
 *     elif isinstance(x, six.integer_types):
 */
  __pyx_t_1 = ((PyObject*)&PyBool_Type);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_x, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(1, 90, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":91
 *     # Note that isinstance(x, six_integer_types) matches with bool.
 *     if isinstance(x, bool):
 *         numpy_type = numpy.bool_             # <<<<<<<<<<<<<<
 *     elif isinstance(x, six.integer_types):
 *         if 0x8000000000000000 <= x:
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 91, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_bool); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 91, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_numpy_type = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/elementwise.pxi":90
 * cpdef _python_scalar_to_numpy_scalar(x):
 *     # Note that isinstance(x, six_integer_types) matches with bool.
 *     if isinstance(x, bool):             # <<<<<<<<<<<<<<
 *         numpy_type = numpy.bool_
 *     elif isinstance(x, six.integer_types):
 */
    goto __pyx_L3;
  }

  /* "cupy/core/elementwise.pxi":92
 *     if isinstance(x, bool):
 *         numpy_type = numpy.bool_
 *     elif isinstance(x, six.integer_types):             # <<<<<<<<<<<<<<
 *         if 0x8000000000000000 <= x:
 *             numpy_type = numpy.uint64
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 92, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_integer_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 92, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_x, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 92, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":93
 *         numpy_type = numpy.bool_
 *     elif isinstance(x, six.integer_types):
 *         if 0x8000000000000000 <= x:             # <<<<<<<<<<<<<<
 *             numpy_type = numpy.uint64
 *         elif x < _int_min or _int_max < x:
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_int_9223372036854775808, __pyx_v_x, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 93, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 93, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":94
 *     elif isinstance(x, six.integer_types):
 *         if 0x8000000000000000 <= x:
 *             numpy_type = numpy.uint64             # <<<<<<<<<<<<<<
 *         elif x < _int_min or _int_max < x:
 *             numpy_type = numpy.int64
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 94, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint64); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 94, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_numpy_type = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "cupy/core/elementwise.pxi":93
 *         numpy_type = numpy.bool_
 *     elif isinstance(x, six.integer_types):
 *         if 0x8000000000000000 <= x:             # <<<<<<<<<<<<<<
 *             numpy_type = numpy.uint64
 *         elif x < _int_min or _int_max < x:
 */
      goto __pyx_L4;
    }

    /* "cupy/core/elementwise.pxi":95
 *         if 0x8000000000000000 <= x:
 *             numpy_type = numpy.uint64
 *         elif x < _int_min or _int_max < x:             # <<<<<<<<<<<<<<
 *             numpy_type = numpy.int64
 *         else:
 */
    __pyx_t_4 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_4cupy_4core_4core__int_min); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 95, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_x, __pyx_t_4, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 95, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 95, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_1 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_4cupy_4core_4core__int_max); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 95, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_v_x, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 95, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 95, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":96
 *             numpy_type = numpy.uint64
 *         elif x < _int_min or _int_max < x:
 *             numpy_type = numpy.int64             # <<<<<<<<<<<<<<
 *         else:
 *             # Generally `_int_type` is `numpy.int64`.
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 96, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int64); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 96, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_numpy_type = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "cupy/core/elementwise.pxi":95
 *         if 0x8000000000000000 <= x:
 *             numpy_type = numpy.uint64
 *         elif x < _int_min or _int_max < x:             # <<<<<<<<<<<<<<
 *             numpy_type = numpy.int64
 *         else:
 */
      goto __pyx_L4;
    }

    /* "cupy/core/elementwise.pxi":100
 *             # Generally `_int_type` is `numpy.int64`.
 *             # On Windows, it is `numpy.int32`.
 *             numpy_type = _int_type             # <<<<<<<<<<<<<<
 *     else:
 *         numpy_type = _python_type_to_numpy_type[type(x)]
 */
    /*else*/ {
      __Pyx_INCREF(__pyx_v_4cupy_4core_4core__int_type);
      __pyx_v_numpy_type = __pyx_v_4cupy_4core_4core__int_type;
    }
    __pyx_L4:;

    /* "cupy/core/elementwise.pxi":92
 *     if isinstance(x, bool):
 *         numpy_type = numpy.bool_
 *     elif isinstance(x, six.integer_types):             # <<<<<<<<<<<<<<
 *         if 0x8000000000000000 <= x:
 *             numpy_type = numpy.uint64
 */
    goto __pyx_L3;
  }

  /* "cupy/core/elementwise.pxi":102
 *             numpy_type = _int_type
 *     else:
 *         numpy_type = _python_type_to_numpy_type[type(x)]             # <<<<<<<<<<<<<<
 *     return numpy_type(x)
 * 
 */
  /*else*/ {
    if (unlikely(__pyx_v_4cupy_4core_4core__python_type_to_numpy_type == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 102, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_4cupy_4core_4core__python_type_to_numpy_type, ((PyObject *)Py_TYPE(__pyx_v_x))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 102, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_numpy_type = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/elementwise.pxi":103
 *     else:
 *         numpy_type = _python_type_to_numpy_type[type(x)]
 *     return numpy_type(x)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_numpy_type);
  __pyx_t_4 = __pyx_v_numpy_type; __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);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 103, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_x};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 103, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_x};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 103, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 103, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_x);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 103, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":88
 * 
 * 
 * cpdef _python_scalar_to_numpy_scalar(x):             # <<<<<<<<<<<<<<
 *     # Note that isinstance(x, six_integer_types) matches with bool.
 *     if isinstance(x, bool):
 */

  /* 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("cupy.core.core._python_scalar_to_numpy_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_numpy_type);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_11_python_scalar_to_numpy_scalar(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/
static char __pyx_doc_4cupy_4core_4core_10_python_scalar_to_numpy_scalar[] = "_python_scalar_to_numpy_scalar(x)";
static PyObject *__pyx_pw_4cupy_4core_4core_11_python_scalar_to_numpy_scalar(PyObject *__pyx_self, PyObject *__pyx_v_x) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_python_scalar_to_numpy_scalar (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_10_python_scalar_to_numpy_scalar(__pyx_self, ((PyObject *)__pyx_v_x));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_10_python_scalar_to_numpy_scalar(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_python_scalar_to_numpy_scalar", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__python_scalar_to_numpy_scalar(__pyx_v_x, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._python_scalar_to_numpy_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":106
 * 
 * 
 * cpdef str _get_typename(dtype):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         raise ValueError('dtype is None')
 */

static PyObject *__pyx_pw_4cupy_4core_4core_13_get_typename(PyObject *__pyx_self, PyObject *__pyx_v_dtype); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_typename(PyObject *__pyx_v_dtype, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("_get_typename", 0);
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/elementwise.pxi":107
 * 
 * cpdef str _get_typename(dtype):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('dtype is None')
 *     if dtype not in _typenames:
 */
  __pyx_t_1 = (__pyx_v_dtype == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "cupy/core/elementwise.pxi":108
 * cpdef str _get_typename(dtype):
 *     if dtype is None:
 *         raise ValueError('dtype is None')             # <<<<<<<<<<<<<<
 *     if dtype not in _typenames:
 *         dtype = get_dtype(dtype).type
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 108, __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, 108, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":107
 * 
 * cpdef str _get_typename(dtype):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('dtype is None')
 *     if dtype not in _typenames:
 */
  }

  /* "cupy/core/elementwise.pxi":109
 *     if dtype is None:
 *         raise ValueError('dtype is None')
 *     if dtype not in _typenames:             # <<<<<<<<<<<<<<
 *         dtype = get_dtype(dtype).type
 *     return _typenames[dtype]
 */
  if (unlikely(__pyx_v_4cupy_4core_4core__typenames == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(1, 109, __pyx_L1_error)
  }
  __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_v_dtype, __pyx_v_4cupy_4core_4core__typenames, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 109, __pyx_L1_error)
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/elementwise.pxi":110
 *         raise ValueError('dtype is None')
 *     if dtype not in _typenames:
 *         dtype = get_dtype(dtype).type             # <<<<<<<<<<<<<<
 *     return _typenames[dtype]
 * 
 */
    __pyx_t_3 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/elementwise.pxi":109
 *     if dtype is None:
 *         raise ValueError('dtype is None')
 *     if dtype not in _typenames:             # <<<<<<<<<<<<<<
 *         dtype = get_dtype(dtype).type
 *     return _typenames[dtype]
 */
  }

  /* "cupy/core/elementwise.pxi":111
 *     if dtype not in _typenames:
 *         dtype = get_dtype(dtype).type
 *     return _typenames[dtype]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_4cupy_4core_4core__typenames == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 111, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_4cupy_4core_4core__typenames, __pyx_v_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(1, 111, __pyx_L1_error)
  __pyx_r = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":106
 * 
 * 
 * cpdef str _get_typename(dtype):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         raise ValueError('dtype is None')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core._get_typename", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13_get_typename(PyObject *__pyx_self, PyObject *__pyx_v_dtype); /*proto*/
static char __pyx_doc_4cupy_4core_4core_12_get_typename[] = "_get_typename(dtype) -> str";
static PyObject *__pyx_pw_4cupy_4core_4core_13_get_typename(PyObject *__pyx_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_typename (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_12_get_typename(__pyx_self, ((PyObject *)__pyx_v_dtype));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_12_get_typename(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_typename", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_typename", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":114
 * 
 * 
 * cpdef list _preprocess_args(args):             # <<<<<<<<<<<<<<
 *     """Preprocesses arguments for kernel invocation
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_15_preprocess_args(PyObject *__pyx_self, PyObject *__pyx_v_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__preprocess_args(PyObject *__pyx_v_args, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_ret = 0;
  int __pyx_v_dev_id;
  PyTypeObject *__pyx_v_typ = 0;
  PyObject *__pyx_v_arg = NULL;
  struct __pyx_obj_4cupy_4cuda_6device_Device *__pyx_v_arr_dev = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  __Pyx_RefNannySetupContext("_preprocess_args", 0);

  /* "cupy/core/elementwise.pxi":120
 *     - Converts Python scalars into NumPy scalars
 *     """
 *     cdef list ret = []             # <<<<<<<<<<<<<<
 *     cdef int dev_id = device.get_device_id()
 *     cdef type typ
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 120, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":121
 *     """
 *     cdef list ret = []
 *     cdef int dev_id = device.get_device_id()             # <<<<<<<<<<<<<<
 *     cdef type typ
 * 
 */
  __pyx_t_2 = __pyx_f_4cupy_4cuda_6device_get_device_id(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 121, __pyx_L1_error)
  __pyx_v_dev_id = __pyx_t_2;

  /* "cupy/core/elementwise.pxi":124
 *     cdef type typ
 * 
 *     for arg in args:             # <<<<<<<<<<<<<<
 *         typ = type(arg)
 *         if typ is ndarray:
 */
  if (likely(PyList_CheckExact(__pyx_v_args)) || PyTuple_CheckExact(__pyx_v_args)) {
    __pyx_t_1 = __pyx_v_args; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 124, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 124, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 124, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 124, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 124, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 124, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_4(__pyx_t_1);
      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, 124, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":125
 * 
 *     for arg in args:
 *         typ = type(arg)             # <<<<<<<<<<<<<<
 *         if typ is ndarray:
 *             arr_dev = (<ndarray?>arg).data.device
 */
    __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_arg)));
    __Pyx_XDECREF_SET(__pyx_v_typ, ((PyTypeObject*)((PyObject *)Py_TYPE(__pyx_v_arg))));

    /* "cupy/core/elementwise.pxi":126
 *     for arg in args:
 *         typ = type(arg)
 *         if typ is ndarray:             # <<<<<<<<<<<<<<
 *             arr_dev = (<ndarray?>arg).data.device
 *             if arr_dev is not None and arr_dev.id != dev_id:
 */
    __pyx_t_6 = (__pyx_v_typ == __pyx_ptype_4cupy_4core_4core_ndarray);
    __pyx_t_7 = (__pyx_t_6 != 0);
    if (__pyx_t_7) {

      /* "cupy/core/elementwise.pxi":127
 *         typ = type(arg)
 *         if typ is ndarray:
 *             arr_dev = (<ndarray?>arg).data.device             # <<<<<<<<<<<<<<
 *             if arr_dev is not None and arr_dev.id != dev_id:
 *                 raise ValueError(
 */
      if (!(likely(__Pyx_TypeTest(__pyx_v_arg, __pyx_ptype_4cupy_4core_4core_ndarray)))) __PYX_ERR(1, 127, __pyx_L1_error)
      __pyx_t_5 = ((PyObject *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_arg)->data->device);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_XDECREF_SET(__pyx_v_arr_dev, ((struct __pyx_obj_4cupy_4cuda_6device_Device *)__pyx_t_5));
      __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":128
 *         if typ is ndarray:
 *             arr_dev = (<ndarray?>arg).data.device
 *             if arr_dev is not None and arr_dev.id != dev_id:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'Array device must be same as the current '
 */
      __pyx_t_6 = (((PyObject *)__pyx_v_arr_dev) != Py_None);
      __pyx_t_8 = (__pyx_t_6 != 0);
      if (__pyx_t_8) {
      } else {
        __pyx_t_7 = __pyx_t_8;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_8 = ((__pyx_v_arr_dev->id != __pyx_v_dev_id) != 0);
      __pyx_t_7 = __pyx_t_8;
      __pyx_L7_bool_binop_done:;
      if (unlikely(__pyx_t_7)) {

        /* "cupy/core/elementwise.pxi":132
 *                     'Array device must be same as the current '
 *                     'device: array device = %d while current = %d'
 *                     % (arr_dev.id, dev_id))             # <<<<<<<<<<<<<<
 *         elif typ in _python_scalar_type_set:
 *             arg = _python_scalar_to_numpy_scalar(arg)
 */
        __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_arr_dev->id); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 132, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_dev_id); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 132, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 132, __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_9);
        PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
        __pyx_t_5 = 0;
        __pyx_t_9 = 0;
        __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_Array_device_must_be_same_as_the, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 132, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "cupy/core/elementwise.pxi":129
 *             arr_dev = (<ndarray?>arg).data.device
 *             if arr_dev is not None and arr_dev.id != dev_id:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'Array device must be same as the current '
 *                     'device: array device = %d while current = %d'
 */
        __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 129, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_Raise(__pyx_t_10, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __PYX_ERR(1, 129, __pyx_L1_error)

        /* "cupy/core/elementwise.pxi":128
 *         if typ is ndarray:
 *             arr_dev = (<ndarray?>arg).data.device
 *             if arr_dev is not None and arr_dev.id != dev_id:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'Array device must be same as the current '
 */
      }

      /* "cupy/core/elementwise.pxi":126
 *     for arg in args:
 *         typ = type(arg)
 *         if typ is ndarray:             # <<<<<<<<<<<<<<
 *             arr_dev = (<ndarray?>arg).data.device
 *             if arr_dev is not None and arr_dev.id != dev_id:
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":133
 *                     'device: array device = %d while current = %d'
 *                     % (arr_dev.id, dev_id))
 *         elif typ in _python_scalar_type_set:             # <<<<<<<<<<<<<<
 *             arg = _python_scalar_to_numpy_scalar(arg)
 *         elif typ in _numpy_scalar_type_set:
 */
    if (unlikely(__pyx_v_4cupy_4core_4core__python_scalar_type_set == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 133, __pyx_L1_error)
    }
    __pyx_t_7 = (__Pyx_PySet_ContainsTF(((PyObject *)__pyx_v_typ), __pyx_v_4cupy_4core_4core__python_scalar_type_set, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 133, __pyx_L1_error)
    __pyx_t_8 = (__pyx_t_7 != 0);
    if (__pyx_t_8) {

      /* "cupy/core/elementwise.pxi":134
 *                     % (arr_dev.id, dev_id))
 *         elif typ in _python_scalar_type_set:
 *             arg = _python_scalar_to_numpy_scalar(arg)             # <<<<<<<<<<<<<<
 *         elif typ in _numpy_scalar_type_set:
 *             pass
 */
      __pyx_t_10 = __pyx_f_4cupy_4core_4core__python_scalar_to_numpy_scalar(__pyx_v_arg, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 134, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_10);
      __pyx_t_10 = 0;

      /* "cupy/core/elementwise.pxi":133
 *                     'device: array device = %d while current = %d'
 *                     % (arr_dev.id, dev_id))
 *         elif typ in _python_scalar_type_set:             # <<<<<<<<<<<<<<
 *             arg = _python_scalar_to_numpy_scalar(arg)
 *         elif typ in _numpy_scalar_type_set:
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":135
 *         elif typ in _python_scalar_type_set:
 *             arg = _python_scalar_to_numpy_scalar(arg)
 *         elif typ in _numpy_scalar_type_set:             # <<<<<<<<<<<<<<
 *             pass
 *         else:
 */
    if (unlikely(__pyx_v_4cupy_4core_4core__numpy_scalar_type_set == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 135, __pyx_L1_error)
    }
    __pyx_t_8 = (__Pyx_PySet_ContainsTF(((PyObject *)__pyx_v_typ), __pyx_v_4cupy_4core_4core__numpy_scalar_type_set, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 135, __pyx_L1_error)
    __pyx_t_7 = (__pyx_t_8 != 0);
    if (likely(__pyx_t_7)) {
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":138
 *             pass
 *         else:
 *             raise TypeError('Unsupported type %s' % typ)             # <<<<<<<<<<<<<<
 *         ret.append(arg)
 *     return ret
 */
    /*else*/ {
      __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Unsupported_type_s, ((PyObject *)__pyx_v_typ)); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(1, 138, __pyx_L1_error)
    }
    __pyx_L5:;

    /* "cupy/core/elementwise.pxi":139
 *         else:
 *             raise TypeError('Unsupported type %s' % typ)
 *         ret.append(arg)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_arg); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(1, 139, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":124
 *     cdef type typ
 * 
 *     for arg in args:             # <<<<<<<<<<<<<<
 *         typ = type(arg)
 *         if typ is ndarray:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":140
 *             raise TypeError('Unsupported type %s' % typ)
 *         ret.append(arg)
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":114
 * 
 * 
 * cpdef list _preprocess_args(args):             # <<<<<<<<<<<<<<
 *     """Preprocesses arguments for kernel invocation
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.core.core._preprocess_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_typ);
  __Pyx_XDECREF(__pyx_v_arg);
  __Pyx_XDECREF((PyObject *)__pyx_v_arr_dev);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_15_preprocess_args(PyObject *__pyx_self, PyObject *__pyx_v_args); /*proto*/
static char __pyx_doc_4cupy_4core_4core_14_preprocess_args[] = "_preprocess_args(args) -> list\nPreprocesses arguments for kernel invocation\n\n    - Checks device compatibility for ndarrays\n    - Converts Python scalars into NumPy scalars\n    ";
static PyObject *__pyx_pw_4cupy_4core_4core_15_preprocess_args(PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_preprocess_args (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_14_preprocess_args(__pyx_self, ((PyObject *)__pyx_v_args));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_14_preprocess_args(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_preprocess_args", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_v_args, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._preprocess_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":143
 * 
 * 
 * cpdef tuple _get_args_info(list args):             # <<<<<<<<<<<<<<
 *     ret = []
 *     for a in args:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_17_get_args_info(PyObject *__pyx_self, PyObject *__pyx_v_args); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_args_info(PyObject *__pyx_v_args, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_v_a = NULL;
  PyTypeObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("_get_args_info", 0);

  /* "cupy/core/elementwise.pxi":144
 * 
 * cpdef tuple _get_args_info(list args):
 *     ret = []             # <<<<<<<<<<<<<<
 *     for a in args:
 *         t = type(a)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":145
 * cpdef tuple _get_args_info(list args):
 *     ret = []
 *     for a in args:             # <<<<<<<<<<<<<<
 *         t = type(a)
 *         if t is Indexer:
 */
  if (unlikely(__pyx_v_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(1, 145, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_v_args; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 145, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 145, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":146
 *     ret = []
 *     for a in args:
 *         t = type(a)             # <<<<<<<<<<<<<<
 *         if t is Indexer:
 *             dtype = None
 */
    __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_a)));
    __Pyx_XDECREF_SET(__pyx_v_t, ((PyTypeObject*)((PyObject *)Py_TYPE(__pyx_v_a))));

    /* "cupy/core/elementwise.pxi":147
 *     for a in args:
 *         t = type(a)
 *         if t is Indexer:             # <<<<<<<<<<<<<<
 *             dtype = None
 *         else:
 */
    __pyx_t_4 = (__pyx_v_t == __pyx_ptype_4cupy_4core_4core_Indexer);
    __pyx_t_5 = (__pyx_t_4 != 0);
    if (__pyx_t_5) {

      /* "cupy/core/elementwise.pxi":148
 *         t = type(a)
 *         if t is Indexer:
 *             dtype = None             # <<<<<<<<<<<<<<
 *         else:
 *             dtype = a.dtype.type
 */
      __Pyx_INCREF(Py_None);
      __Pyx_XDECREF_SET(__pyx_v_dtype, Py_None);

      /* "cupy/core/elementwise.pxi":147
 *     for a in args:
 *         t = type(a)
 *         if t is Indexer:             # <<<<<<<<<<<<<<
 *             dtype = None
 *         else:
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":150
 *             dtype = None
 *         else:
 *             dtype = a.dtype.type             # <<<<<<<<<<<<<<
 *         ret.append((t, dtype, a.ndim))
 *     return tuple(ret)
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 150, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 150, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_dtype, __pyx_t_6);
      __pyx_t_6 = 0;
    }
    __pyx_L5:;

    /* "cupy/core/elementwise.pxi":151
 *         else:
 *             dtype = a.dtype.type
 *         ret.append((t, dtype, a.ndim))             # <<<<<<<<<<<<<<
 *     return tuple(ret)
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 151, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 151, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_t));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_t));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_t));
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_t_3); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(1, 151, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":145
 * cpdef tuple _get_args_info(list args):
 *     ret = []
 *     for a in args:             # <<<<<<<<<<<<<<
 *         t = type(a)
 *         if t is Indexer:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":152
 *             dtype = a.dtype.type
 *         ret.append((t, dtype, a.ndim))
 *     return tuple(ret)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_AsTuple(__pyx_v_ret); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":143
 * 
 * 
 * cpdef tuple _get_args_info(list args):             # <<<<<<<<<<<<<<
 *     ret = []
 *     for a in args:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core._get_args_info", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17_get_args_info(PyObject *__pyx_self, PyObject *__pyx_v_args); /*proto*/
static char __pyx_doc_4cupy_4core_4core_16_get_args_info[] = "_get_args_info(list args) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_17_get_args_info(PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_args_info (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args), (&PyList_Type), 1, "args", 1))) __PYX_ERR(1, 143, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_16_get_args_info(__pyx_self, ((PyObject*)__pyx_v_args));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_16_get_args_info(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_args_info", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_args_info(__pyx_v_args, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_args_info", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":155
 * 
 * 
 * cpdef str _get_kernel_params(tuple params, tuple args_info):             # <<<<<<<<<<<<<<
 *     cdef ParameterInfo p
 *     ret = []
 */

static PyObject *__pyx_pw_4cupy_4core_4core_19_get_kernel_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_kernel_params(PyObject *__pyx_v_params, PyObject *__pyx_v_args_info, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_p = 0;
  PyObject *__pyx_v_ret = NULL;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_type = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_ndim = NULL;
  PyObject *__pyx_v_is_array = NULL;
  PyObject *__pyx_v_t = NULL;
  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;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("_get_kernel_params", 0);

  /* "cupy/core/elementwise.pxi":157
 * cpdef str _get_kernel_params(tuple params, tuple args_info):
 *     cdef ParameterInfo p
 *     ret = []             # <<<<<<<<<<<<<<
 *     for i in range(len(params)):
 *         p = params[i]
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":158
 *     cdef ParameterInfo p
 *     ret = []
 *     for i in range(len(params)):             # <<<<<<<<<<<<<<
 *         p = params[i]
 *         type, dtype, ndim = <tuple>(args_info[i])
 */
  if (unlikely(__pyx_v_params == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 158, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v_params); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(1, 158, __pyx_L1_error)
  __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;

    /* "cupy/core/elementwise.pxi":159
 *     ret = []
 *     for i in range(len(params)):
 *         p = params[i]             # <<<<<<<<<<<<<<
 *         type, dtype, ndim = <tuple>(args_info[i])
 *         is_array = type is ndarray
 */
    if (unlikely(__pyx_v_params == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 159, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_params, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 159, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ParameterInfo))))) __PYX_ERR(1, 159, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_p, ((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":160
 *     for i in range(len(params)):
 *         p = params[i]
 *         type, dtype, ndim = <tuple>(args_info[i])             # <<<<<<<<<<<<<<
 *         is_array = type is ndarray
 *         if type is Indexer:
 */
    if (unlikely(__pyx_v_args_info == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 160, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_args_info, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 160, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __pyx_t_1;
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(__pyx_t_5 != Py_None)) {
      PyObject* sequence = __pyx_t_5;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(1, 160, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 160, __pyx_L1_error)
    }
    __Pyx_XDECREF_SET(__pyx_v_type, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_dtype, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_ndim, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":161
 *         p = params[i]
 *         type, dtype, ndim = <tuple>(args_info[i])
 *         is_array = type is ndarray             # <<<<<<<<<<<<<<
 *         if type is Indexer:
 *             t = 'CIndexer<%d>' % ndim
 */
    __pyx_t_8 = (__pyx_v_type == ((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
    __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 161, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XDECREF_SET(__pyx_v_is_array, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":162
 *         type, dtype, ndim = <tuple>(args_info[i])
 *         is_array = type is ndarray
 *         if type is Indexer:             # <<<<<<<<<<<<<<
 *             t = 'CIndexer<%d>' % ndim
 *         else:
 */
    __pyx_t_8 = (__pyx_v_type == ((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer));
    __pyx_t_9 = (__pyx_t_8 != 0);
    if (__pyx_t_9) {

      /* "cupy/core/elementwise.pxi":163
 *         is_array = type is ndarray
 *         if type is Indexer:
 *             t = 'CIndexer<%d>' % ndim             # <<<<<<<<<<<<<<
 *         else:
 *             t = _get_typename(dtype)
 */
      __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_CIndexer_d, __pyx_v_ndim); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 163, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":162
 *         type, dtype, ndim = <tuple>(args_info[i])
 *         is_array = type is ndarray
 *         if type is Indexer:             # <<<<<<<<<<<<<<
 *             t = 'CIndexer<%d>' % ndim
 *         else:
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":165
 *             t = 'CIndexer<%d>' % ndim
 *         else:
 *             t = _get_typename(dtype)             # <<<<<<<<<<<<<<
 *             if is_array:
 *                 t = 'CArray<%s, %d>' % (t, ndim)
 */
    /*else*/ {
      __pyx_t_5 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 165, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":166
 *         else:
 *             t = _get_typename(dtype)
 *             if is_array:             # <<<<<<<<<<<<<<
 *                 t = 'CArray<%s, %d>' % (t, ndim)
 *         ret.append('%s %s%s' % (t,
 */
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_is_array); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(1, 166, __pyx_L1_error)
      if (__pyx_t_9) {

        /* "cupy/core/elementwise.pxi":167
 *             t = _get_typename(dtype)
 *             if is_array:
 *                 t = 'CArray<%s, %d>' % (t, ndim)             # <<<<<<<<<<<<<<
 *         ret.append('%s %s%s' % (t,
 *                                 '_raw_' if is_array and not p.raw else '',
 */
        __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 167, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_v_t);
        __Pyx_GIVEREF(__pyx_v_t);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_t);
        __Pyx_INCREF(__pyx_v_ndim);
        __Pyx_GIVEREF(__pyx_v_ndim);
        PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_ndim);
        __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_CArray_s_d, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 167, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_7);
        __pyx_t_7 = 0;

        /* "cupy/core/elementwise.pxi":166
 *         else:
 *             t = _get_typename(dtype)
 *             if is_array:             # <<<<<<<<<<<<<<
 *                 t = 'CArray<%s, %d>' % (t, ndim)
 *         ret.append('%s %s%s' % (t,
 */
      }
    }
    __pyx_L5:;

    /* "cupy/core/elementwise.pxi":169
 *                 t = 'CArray<%s, %d>' % (t, ndim)
 *         ret.append('%s %s%s' % (t,
 *                                 '_raw_' if is_array and not p.raw else '',             # <<<<<<<<<<<<<<
 *                                 p.name))
 *     return ', '.join(ret)
 */
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_is_array); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 169, __pyx_L1_error)
    if (__pyx_t_8) {
    } else {
      __pyx_t_9 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_8 = ((!(__pyx_v_p->raw != 0)) != 0);
    __pyx_t_9 = __pyx_t_8;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_9) {
      __Pyx_INCREF(__pyx_n_s_raw);
      __pyx_t_7 = __pyx_n_s_raw;
    } else {
      __Pyx_INCREF(__pyx_kp_s__6);
      __pyx_t_7 = __pyx_kp_s__6;
    }

    /* "cupy/core/elementwise.pxi":168
 *             if is_array:
 *                 t = 'CArray<%s, %d>' % (t, ndim)
 *         ret.append('%s %s%s' % (t,             # <<<<<<<<<<<<<<
 *                                 '_raw_' if is_array and not p.raw else '',
 *                                 p.name))
 */
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 168, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_t);
    __Pyx_GIVEREF(__pyx_v_t);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_t);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_7);
    __Pyx_INCREF(__pyx_v_p->name);
    __Pyx_GIVEREF(__pyx_v_p->name);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_p->name);
    __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_s_s_s, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 168, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_t_7); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(1, 168, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }

  /* "cupy/core/elementwise.pxi":171
 *                                 '_raw_' if is_array and not p.raw else '',
 *                                 p.name))
 *     return ', '.join(ret)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = __Pyx_PyString_Join(__pyx_kp_s__56, __pyx_v_ret); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (!(likely(PyString_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_7)->tp_name), 0))) __PYX_ERR(1, 171, __pyx_L1_error)
  __pyx_r = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":155
 * 
 * 
 * cpdef str _get_kernel_params(tuple params, tuple args_info):             # <<<<<<<<<<<<<<
 *     cdef ParameterInfo p
 *     ret = []
 */

  /* 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_AddTraceback("cupy.core.core._get_kernel_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_type);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_ndim);
  __Pyx_XDECREF(__pyx_v_is_array);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_19_get_kernel_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_18_get_kernel_params[] = "_get_kernel_params(tuple params, tuple args_info) -> str";
static PyObject *__pyx_pw_4cupy_4core_4core_19_get_kernel_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_args_info = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_kernel_params (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_params,&__pyx_n_s_args_info,0};
    PyObject* values[2] = {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  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_params)) != 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_args_info)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_kernel_params", 1, 2, 2, 1); __PYX_ERR(1, 155, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_kernel_params") < 0)) __PYX_ERR(1, 155, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_params = ((PyObject*)values[0]);
    __pyx_v_args_info = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_kernel_params", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 155, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_kernel_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_params), (&PyTuple_Type), 1, "params", 1))) __PYX_ERR(1, 155, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args_info), (&PyTuple_Type), 1, "args_info", 1))) __PYX_ERR(1, 155, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_18_get_kernel_params(__pyx_self, __pyx_v_params, __pyx_v_args_info);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_18_get_kernel_params(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_params, PyObject *__pyx_v_args_info) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_kernel_params", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_kernel_params(__pyx_v_params, __pyx_v_args_info, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_kernel_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":174
 * 
 * 
 * cpdef tuple _reduce_dims(list args, tuple params, tuple shape):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, j, n, ndim, cnt, axis, s
 *     cdef vector.vector[Py_ssize_t] vecshape, newshape, newstrides
 */

static PyObject *__pyx_pw_4cupy_4core_4core_21_reduce_dims(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__reduce_dims(PyObject *__pyx_v_args, PyObject *__pyx_v_params, PyObject *__pyx_v_shape, CYTHON_UNUSED int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_j;
  Py_ssize_t __pyx_v_n;
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_cnt;
  Py_ssize_t __pyx_v_axis;
  std::vector<Py_ssize_t>  __pyx_v_vecshape;
  std::vector<Py_ssize_t>  __pyx_v_newshape;
  std::vector<Py_ssize_t>  __pyx_v_newstrides;
  std::vector<int>  __pyx_v_is_array_flags;
  std::vector<std::vector<Py_ssize_t> >  __pyx_v_args_strides;
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_p = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr = 0;
  int __pyx_v_flag;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  std::vector<Py_ssize_t>  __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides __pyx_t_13;
  int __pyx_t_14;
  __Pyx_RefNannySetupContext("_reduce_dims", 0);

  /* "cupy/core/elementwise.pxi":183
 *     cdef bint flag
 * 
 *     ndim = len(shape)             # <<<<<<<<<<<<<<
 *     if ndim <= 1:
 *         return args, shape
 */
  if (unlikely(__pyx_v_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 183, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 183, __pyx_L1_error)
  __pyx_v_ndim = __pyx_t_1;

  /* "cupy/core/elementwise.pxi":184
 * 
 *     ndim = len(shape)
 *     if ndim <= 1:             # <<<<<<<<<<<<<<
 *         return args, shape
 * 
 */
  __pyx_t_2 = ((__pyx_v_ndim <= 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":185
 *     ndim = len(shape)
 *     if ndim <= 1:
 *         return args, shape             # <<<<<<<<<<<<<<
 * 
 *     n = len(args)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 185, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_args);
    __Pyx_GIVEREF(__pyx_v_args);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_args);
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_shape);
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":184
 * 
 *     ndim = len(shape)
 *     if ndim <= 1:             # <<<<<<<<<<<<<<
 *         return args, shape
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":187
 *         return args, shape
 * 
 *     n = len(args)             # <<<<<<<<<<<<<<
 *     for i in range(n):
 *         p = params[i]
 */
  if (unlikely(__pyx_v_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 187, __pyx_L1_error)
  }
  __pyx_t_1 = PyList_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 187, __pyx_L1_error)
  __pyx_v_n = __pyx_t_1;

  /* "cupy/core/elementwise.pxi":188
 * 
 *     n = len(args)
 *     for i in range(n):             # <<<<<<<<<<<<<<
 *         p = params[i]
 *         a = args[i]
 */
  __pyx_t_1 = __pyx_v_n;
  __pyx_t_4 = __pyx_t_1;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "cupy/core/elementwise.pxi":189
 *     n = len(args)
 *     for i in range(n):
 *         p = params[i]             # <<<<<<<<<<<<<<
 *         a = args[i]
 *         flag = not p.raw and isinstance(a, ndarray)
 */
    if (unlikely(__pyx_v_params == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 189, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_params, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 189, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ParameterInfo))))) __PYX_ERR(1, 189, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_p, ((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":190
 *     for i in range(n):
 *         p = params[i]
 *         a = args[i]             # <<<<<<<<<<<<<<
 *         flag = not p.raw and isinstance(a, ndarray)
 *         is_array_flags.push_back(flag)
 */
    if (unlikely(__pyx_v_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 190, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_args, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 190, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":191
 *         p = params[i]
 *         a = args[i]
 *         flag = not p.raw and isinstance(a, ndarray)             # <<<<<<<<<<<<<<
 *         is_array_flags.push_back(flag)
 *         if flag:
 */
    __pyx_t_6 = ((!(__pyx_v_p->raw != 0)) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_2 = __pyx_t_6;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_7 = (__pyx_t_6 != 0);
    __pyx_t_2 = __pyx_t_7;
    __pyx_L6_bool_binop_done:;
    __pyx_v_flag = __pyx_t_2;

    /* "cupy/core/elementwise.pxi":192
 *         a = args[i]
 *         flag = not p.raw and isinstance(a, ndarray)
 *         is_array_flags.push_back(flag)             # <<<<<<<<<<<<<<
 *         if flag:
 *             arr = a
 */
    try {
      __pyx_v_is_array_flags.push_back(__pyx_v_flag);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(1, 192, __pyx_L1_error)
    }

    /* "cupy/core/elementwise.pxi":193
 *         flag = not p.raw and isinstance(a, ndarray)
 *         is_array_flags.push_back(flag)
 *         if flag:             # <<<<<<<<<<<<<<
 *             arr = a
 *             args_strides.push_back(arr._strides)
 */
    __pyx_t_2 = (__pyx_v_flag != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":194
 *         is_array_flags.push_back(flag)
 *         if flag:
 *             arr = a             # <<<<<<<<<<<<<<
 *             args_strides.push_back(arr._strides)
 * 
 */
      if (!(likely(((__pyx_v_a) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 194, __pyx_L1_error)
      __pyx_t_3 = __pyx_v_a;
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_v_arr, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
      __pyx_t_3 = 0;

      /* "cupy/core/elementwise.pxi":195
 *         if flag:
 *             arr = a
 *             args_strides.push_back(arr._strides)             # <<<<<<<<<<<<<<
 * 
 *     vecshape = shape
 */
      try {
        __pyx_v_args_strides.push_back(__pyx_v_arr->_strides);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(1, 195, __pyx_L1_error)
      }

      /* "cupy/core/elementwise.pxi":193
 *         flag = not p.raw and isinstance(a, ndarray)
 *         is_array_flags.push_back(flag)
 *         if flag:             # <<<<<<<<<<<<<<
 *             arr = a
 *             args_strides.push_back(arr._strides)
 */
    }
  }

  /* "cupy/core/elementwise.pxi":197
 *             args_strides.push_back(arr._strides)
 * 
 *     vecshape = shape             # <<<<<<<<<<<<<<
 *     axis = -1
 *     cnt = 0
 */
  __pyx_t_8 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 197, __pyx_L1_error)
  __pyx_v_vecshape = __pyx_t_8;

  /* "cupy/core/elementwise.pxi":198
 * 
 *     vecshape = shape
 *     axis = -1             # <<<<<<<<<<<<<<
 *     cnt = 0
 *     for i in range(1, ndim):
 */
  __pyx_v_axis = -1L;

  /* "cupy/core/elementwise.pxi":199
 *     vecshape = shape
 *     axis = -1
 *     cnt = 0             # <<<<<<<<<<<<<<
 *     for i in range(1, ndim):
 *         if vecshape[i - 1] == 1:
 */
  __pyx_v_cnt = 0;

  /* "cupy/core/elementwise.pxi":200
 *     axis = -1
 *     cnt = 0
 *     for i in range(1, ndim):             # <<<<<<<<<<<<<<
 *         if vecshape[i - 1] == 1:
 *             continue
 */
  __pyx_t_1 = __pyx_v_ndim;
  __pyx_t_4 = __pyx_t_1;
  for (__pyx_t_5 = 1; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "cupy/core/elementwise.pxi":201
 *     cnt = 0
 *     for i in range(1, ndim):
 *         if vecshape[i - 1] == 1:             # <<<<<<<<<<<<<<
 *             continue
 *         for j in range(<Py_ssize_t>args_strides.size()):
 */
    __pyx_t_2 = (((__pyx_v_vecshape[(__pyx_v_i - 1)]) == 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":202
 *     for i in range(1, ndim):
 *         if vecshape[i - 1] == 1:
 *             continue             # <<<<<<<<<<<<<<
 *         for j in range(<Py_ssize_t>args_strides.size()):
 *             if args_strides[j][i] * vecshape[i] != args_strides[j][i - 1]:
 */
      goto __pyx_L9_continue;

      /* "cupy/core/elementwise.pxi":201
 *     cnt = 0
 *     for i in range(1, ndim):
 *         if vecshape[i - 1] == 1:             # <<<<<<<<<<<<<<
 *             continue
 *         for j in range(<Py_ssize_t>args_strides.size()):
 */
    }

    /* "cupy/core/elementwise.pxi":203
 *         if vecshape[i - 1] == 1:
 *             continue
 *         for j in range(<Py_ssize_t>args_strides.size()):             # <<<<<<<<<<<<<<
 *             if args_strides[j][i] * vecshape[i] != args_strides[j][i - 1]:
 *                 cnt += 1
 */
    __pyx_t_9 = ((Py_ssize_t)__pyx_v_args_strides.size());
    __pyx_t_10 = __pyx_t_9;
    for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
      __pyx_v_j = __pyx_t_11;

      /* "cupy/core/elementwise.pxi":204
 *             continue
 *         for j in range(<Py_ssize_t>args_strides.size()):
 *             if args_strides[j][i] * vecshape[i] != args_strides[j][i - 1]:             # <<<<<<<<<<<<<<
 *                 cnt += 1
 *                 axis = i - 1
 */
      __pyx_t_2 = (((((__pyx_v_args_strides[__pyx_v_j])[__pyx_v_i]) * (__pyx_v_vecshape[__pyx_v_i])) != ((__pyx_v_args_strides[__pyx_v_j])[(__pyx_v_i - 1)])) != 0);
      if (__pyx_t_2) {

        /* "cupy/core/elementwise.pxi":205
 *         for j in range(<Py_ssize_t>args_strides.size()):
 *             if args_strides[j][i] * vecshape[i] != args_strides[j][i - 1]:
 *                 cnt += 1             # <<<<<<<<<<<<<<
 *                 axis = i - 1
 *                 break
 */
        __pyx_v_cnt = (__pyx_v_cnt + 1);

        /* "cupy/core/elementwise.pxi":206
 *             if args_strides[j][i] * vecshape[i] != args_strides[j][i - 1]:
 *                 cnt += 1
 *                 axis = i - 1             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
        __pyx_v_axis = (__pyx_v_i - 1);

        /* "cupy/core/elementwise.pxi":207
 *                 cnt += 1
 *                 axis = i - 1
 *                 break             # <<<<<<<<<<<<<<
 *         else:
 *             vecshape[i] *= vecshape[i - 1]
 */
        goto __pyx_L13_break;

        /* "cupy/core/elementwise.pxi":204
 *             continue
 *         for j in range(<Py_ssize_t>args_strides.size()):
 *             if args_strides[j][i] * vecshape[i] != args_strides[j][i - 1]:             # <<<<<<<<<<<<<<
 *                 cnt += 1
 *                 axis = i - 1
 */
      }
    }
    /*else*/ {

      /* "cupy/core/elementwise.pxi":209
 *                 break
 *         else:
 *             vecshape[i] *= vecshape[i - 1]             # <<<<<<<<<<<<<<
 *             vecshape[i - 1] = 1
 *     if vecshape[ndim - 1] != 1:
 */
      __pyx_t_11 = __pyx_v_i;
      (__pyx_v_vecshape[__pyx_t_11]) = ((__pyx_v_vecshape[__pyx_t_11]) * (__pyx_v_vecshape[(__pyx_v_i - 1)]));

      /* "cupy/core/elementwise.pxi":210
 *         else:
 *             vecshape[i] *= vecshape[i - 1]
 *             vecshape[i - 1] = 1             # <<<<<<<<<<<<<<
 *     if vecshape[ndim - 1] != 1:
 *         cnt += 1
 */
      (__pyx_v_vecshape[(__pyx_v_i - 1)]) = 1;
    }
    __pyx_L13_break:;
    __pyx_L9_continue:;
  }

  /* "cupy/core/elementwise.pxi":211
 *             vecshape[i] *= vecshape[i - 1]
 *             vecshape[i - 1] = 1
 *     if vecshape[ndim - 1] != 1:             # <<<<<<<<<<<<<<
 *         cnt += 1
 *         axis = ndim - 1
 */
  __pyx_t_2 = (((__pyx_v_vecshape[(__pyx_v_ndim - 1)]) != 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":212
 *             vecshape[i - 1] = 1
 *     if vecshape[ndim - 1] != 1:
 *         cnt += 1             # <<<<<<<<<<<<<<
 *         axis = ndim - 1
 * 
 */
    __pyx_v_cnt = (__pyx_v_cnt + 1);

    /* "cupy/core/elementwise.pxi":213
 *     if vecshape[ndim - 1] != 1:
 *         cnt += 1
 *         axis = ndim - 1             # <<<<<<<<<<<<<<
 * 
 *     if cnt == ndim:
 */
    __pyx_v_axis = (__pyx_v_ndim - 1);

    /* "cupy/core/elementwise.pxi":211
 *             vecshape[i] *= vecshape[i - 1]
 *             vecshape[i - 1] = 1
 *     if vecshape[ndim - 1] != 1:             # <<<<<<<<<<<<<<
 *         cnt += 1
 *         axis = ndim - 1
 */
  }

  /* "cupy/core/elementwise.pxi":215
 *         axis = ndim - 1
 * 
 *     if cnt == ndim:             # <<<<<<<<<<<<<<
 *         return args, shape
 *     if cnt == 1:
 */
  __pyx_t_2 = ((__pyx_v_cnt == __pyx_v_ndim) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":216
 * 
 *     if cnt == ndim:
 *         return args, shape             # <<<<<<<<<<<<<<
 *     if cnt == 1:
 *         newshape.assign(<Py_ssize_t>1, <Py_ssize_t>vecshape[axis])
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 216, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_args);
    __Pyx_GIVEREF(__pyx_v_args);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_args);
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_shape);
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":215
 *         axis = ndim - 1
 * 
 *     if cnt == ndim:             # <<<<<<<<<<<<<<
 *         return args, shape
 *     if cnt == 1:
 */
  }

  /* "cupy/core/elementwise.pxi":217
 *     if cnt == ndim:
 *         return args, shape
 *     if cnt == 1:             # <<<<<<<<<<<<<<
 *         newshape.assign(<Py_ssize_t>1, <Py_ssize_t>vecshape[axis])
 *         ret = []
 */
  __pyx_t_2 = ((__pyx_v_cnt == 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":218
 *         return args, shape
 *     if cnt == 1:
 *         newshape.assign(<Py_ssize_t>1, <Py_ssize_t>vecshape[axis])             # <<<<<<<<<<<<<<
 *         ret = []
 *         for i, a in enumerate(args):
 */
    try {
      __pyx_v_newshape.assign(((Py_ssize_t)1), ((Py_ssize_t)(__pyx_v_vecshape[__pyx_v_axis])));
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(1, 218, __pyx_L1_error)
    }

    /* "cupy/core/elementwise.pxi":219
 *     if cnt == 1:
 *         newshape.assign(<Py_ssize_t>1, <Py_ssize_t>vecshape[axis])
 *         ret = []             # <<<<<<<<<<<<<<
 *         for i, a in enumerate(args):
 *             if is_array_flags[i]:
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 219, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_ret = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":220
 *         newshape.assign(<Py_ssize_t>1, <Py_ssize_t>vecshape[axis])
 *         ret = []
 *         for i, a in enumerate(args):             # <<<<<<<<<<<<<<
 *             if is_array_flags[i]:
 *                 arr = a
 */
    __pyx_t_1 = 0;
    __pyx_t_3 = __pyx_v_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_12 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_12); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 220, __pyx_L1_error)
      #else
      __pyx_t_12 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 220, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_12);
      __pyx_t_12 = 0;
      __pyx_v_i = __pyx_t_1;
      __pyx_t_1 = (__pyx_t_1 + 1);

      /* "cupy/core/elementwise.pxi":221
 *         ret = []
 *         for i, a in enumerate(args):
 *             if is_array_flags[i]:             # <<<<<<<<<<<<<<
 *                 arr = a
 *                 arr = arr.view()
 */
      __pyx_t_2 = ((__pyx_v_is_array_flags[__pyx_v_i]) != 0);
      if (__pyx_t_2) {

        /* "cupy/core/elementwise.pxi":222
 *         for i, a in enumerate(args):
 *             if is_array_flags[i]:
 *                 arr = a             # <<<<<<<<<<<<<<
 *                 arr = arr.view()
 *                 newstrides.assign(
 */
        if (!(likely(((__pyx_v_a) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 222, __pyx_L1_error)
        __pyx_t_12 = __pyx_v_a;
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_XDECREF_SET(__pyx_v_arr, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12));
        __pyx_t_12 = 0;

        /* "cupy/core/elementwise.pxi":223
 *             if is_array_flags[i]:
 *                 arr = a
 *                 arr = arr.view()             # <<<<<<<<<<<<<<
 *                 newstrides.assign(
 *                     <Py_ssize_t>1, <Py_ssize_t>arr._strides[axis])
 */
        __pyx_t_12 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_arr->__pyx_vtab)->view(__pyx_v_arr, 0, NULL)); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 223, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF_SET(__pyx_v_arr, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12));
        __pyx_t_12 = 0;

        /* "cupy/core/elementwise.pxi":224
 *                 arr = a
 *                 arr = arr.view()
 *                 newstrides.assign(             # <<<<<<<<<<<<<<
 *                     <Py_ssize_t>1, <Py_ssize_t>arr._strides[axis])
 *                 arr._set_shape_and_strides(newshape, newstrides, False)
 */
        try {
          __pyx_v_newstrides.assign(((Py_ssize_t)1), ((Py_ssize_t)(__pyx_v_arr->_strides[__pyx_v_axis])));
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(1, 224, __pyx_L1_error)
        }

        /* "cupy/core/elementwise.pxi":226
 *                 newstrides.assign(
 *                     <Py_ssize_t>1, <Py_ssize_t>arr._strides[axis])
 *                 arr._set_shape_and_strides(newshape, newstrides, False)             # <<<<<<<<<<<<<<
 *                 a = arr
 *             ret.append(a)
 */
        __pyx_t_13.__pyx_n = 1;
        __pyx_t_13.update_c_contiguity = 0;
        __pyx_t_12 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_arr->__pyx_vtab)->_set_shape_and_strides(__pyx_v_arr, __pyx_v_newshape, __pyx_v_newstrides, 0, &__pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 226, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

        /* "cupy/core/elementwise.pxi":227
 *                     <Py_ssize_t>1, <Py_ssize_t>arr._strides[axis])
 *                 arr._set_shape_and_strides(newshape, newstrides, False)
 *                 a = arr             # <<<<<<<<<<<<<<
 *             ret.append(a)
 *         return ret, tuple(newshape)
 */
        __Pyx_INCREF(((PyObject *)__pyx_v_arr));
        __Pyx_DECREF_SET(__pyx_v_a, ((PyObject *)__pyx_v_arr));

        /* "cupy/core/elementwise.pxi":221
 *         ret = []
 *         for i, a in enumerate(args):
 *             if is_array_flags[i]:             # <<<<<<<<<<<<<<
 *                 arr = a
 *                 arr = arr.view()
 */
      }

      /* "cupy/core/elementwise.pxi":228
 *                 arr._set_shape_and_strides(newshape, newstrides, False)
 *                 a = arr
 *             ret.append(a)             # <<<<<<<<<<<<<<
 *         return ret, tuple(newshape)
 * 
 */
      __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_a); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(1, 228, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":220
 *         newshape.assign(<Py_ssize_t>1, <Py_ssize_t>vecshape[axis])
 *         ret = []
 *         for i, a in enumerate(args):             # <<<<<<<<<<<<<<
 *             if is_array_flags[i]:
 *                 arr = a
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":229
 *                 a = arr
 *             ret.append(a)
 *         return ret, tuple(newshape)             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_newshape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 229, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_12 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 229, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 229, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_ret);
    __Pyx_GIVEREF(__pyx_v_ret);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_ret);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":217
 *     if cnt == ndim:
 *         return args, shape
 *     if cnt == 1:             # <<<<<<<<<<<<<<
 *         newshape.assign(<Py_ssize_t>1, <Py_ssize_t>vecshape[axis])
 *         ret = []
 */
  }

  /* "cupy/core/elementwise.pxi":231
 *         return ret, tuple(newshape)
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         if vecshape[i] != 1:
 *             newshape.push_back(vecshape[i])
 */
  __pyx_t_1 = __pyx_v_ndim;
  __pyx_t_4 = __pyx_t_1;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "cupy/core/elementwise.pxi":232
 * 
 *     for i in range(ndim):
 *         if vecshape[i] != 1:             # <<<<<<<<<<<<<<
 *             newshape.push_back(vecshape[i])
 *     ret = []
 */
    __pyx_t_2 = (((__pyx_v_vecshape[__pyx_v_i]) != 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":233
 *     for i in range(ndim):
 *         if vecshape[i] != 1:
 *             newshape.push_back(vecshape[i])             # <<<<<<<<<<<<<<
 *     ret = []
 *     for i, a in enumerate(args):
 */
      try {
        __pyx_v_newshape.push_back((__pyx_v_vecshape[__pyx_v_i]));
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(1, 233, __pyx_L1_error)
      }

      /* "cupy/core/elementwise.pxi":232
 * 
 *     for i in range(ndim):
 *         if vecshape[i] != 1:             # <<<<<<<<<<<<<<
 *             newshape.push_back(vecshape[i])
 *     ret = []
 */
    }
  }

  /* "cupy/core/elementwise.pxi":234
 *         if vecshape[i] != 1:
 *             newshape.push_back(vecshape[i])
 *     ret = []             # <<<<<<<<<<<<<<
 *     for i, a in enumerate(args):
 *         if is_array_flags[i]:
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 234, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ret = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":235
 *             newshape.push_back(vecshape[i])
 *     ret = []
 *     for i, a in enumerate(args):             # <<<<<<<<<<<<<<
 *         if is_array_flags[i]:
 *             arr = a
 */
  __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_v_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_12 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_12); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 235, __pyx_L1_error)
    #else
    __pyx_t_12 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_v_i = __pyx_t_1;
    __pyx_t_1 = (__pyx_t_1 + 1);

    /* "cupy/core/elementwise.pxi":236
 *     ret = []
 *     for i, a in enumerate(args):
 *         if is_array_flags[i]:             # <<<<<<<<<<<<<<
 *             arr = a
 *             arr = arr.view()
 */
    __pyx_t_2 = ((__pyx_v_is_array_flags[__pyx_v_i]) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":237
 *     for i, a in enumerate(args):
 *         if is_array_flags[i]:
 *             arr = a             # <<<<<<<<<<<<<<
 *             arr = arr.view()
 *             newstrides.clear()
 */
      if (!(likely(((__pyx_v_a) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(1, 237, __pyx_L1_error)
      __pyx_t_12 = __pyx_v_a;
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_XDECREF_SET(__pyx_v_arr, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12));
      __pyx_t_12 = 0;

      /* "cupy/core/elementwise.pxi":238
 *         if is_array_flags[i]:
 *             arr = a
 *             arr = arr.view()             # <<<<<<<<<<<<<<
 *             newstrides.clear()
 *             for j in range(ndim):
 */
      __pyx_t_12 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_arr->__pyx_vtab)->view(__pyx_v_arr, 0, NULL)); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 238, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF_SET(__pyx_v_arr, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12));
      __pyx_t_12 = 0;

      /* "cupy/core/elementwise.pxi":239
 *             arr = a
 *             arr = arr.view()
 *             newstrides.clear()             # <<<<<<<<<<<<<<
 *             for j in range(ndim):
 *                 if vecshape[j] != 1:
 */
      __pyx_v_newstrides.clear();

      /* "cupy/core/elementwise.pxi":240
 *             arr = arr.view()
 *             newstrides.clear()
 *             for j in range(ndim):             # <<<<<<<<<<<<<<
 *                 if vecshape[j] != 1:
 *                     newstrides.push_back(arr._strides[j])
 */
      __pyx_t_5 = __pyx_v_ndim;
      __pyx_t_9 = __pyx_t_5;
      for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
        __pyx_v_j = __pyx_t_10;

        /* "cupy/core/elementwise.pxi":241
 *             newstrides.clear()
 *             for j in range(ndim):
 *                 if vecshape[j] != 1:             # <<<<<<<<<<<<<<
 *                     newstrides.push_back(arr._strides[j])
 *             arr._set_shape_and_strides(newshape, newstrides, False)
 */
        __pyx_t_2 = (((__pyx_v_vecshape[__pyx_v_j]) != 1) != 0);
        if (__pyx_t_2) {

          /* "cupy/core/elementwise.pxi":242
 *             for j in range(ndim):
 *                 if vecshape[j] != 1:
 *                     newstrides.push_back(arr._strides[j])             # <<<<<<<<<<<<<<
 *             arr._set_shape_and_strides(newshape, newstrides, False)
 *             a = arr
 */
          try {
            __pyx_v_newstrides.push_back((__pyx_v_arr->_strides[__pyx_v_j]));
          } catch(...) {
            __Pyx_CppExn2PyErr();
            __PYX_ERR(1, 242, __pyx_L1_error)
          }

          /* "cupy/core/elementwise.pxi":241
 *             newstrides.clear()
 *             for j in range(ndim):
 *                 if vecshape[j] != 1:             # <<<<<<<<<<<<<<
 *                     newstrides.push_back(arr._strides[j])
 *             arr._set_shape_and_strides(newshape, newstrides, False)
 */
        }
      }

      /* "cupy/core/elementwise.pxi":243
 *                 if vecshape[j] != 1:
 *                     newstrides.push_back(arr._strides[j])
 *             arr._set_shape_and_strides(newshape, newstrides, False)             # <<<<<<<<<<<<<<
 *             a = arr
 *         ret.append(a)
 */
      __pyx_t_13.__pyx_n = 1;
      __pyx_t_13.update_c_contiguity = 0;
      __pyx_t_12 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_arr->__pyx_vtab)->_set_shape_and_strides(__pyx_v_arr, __pyx_v_newshape, __pyx_v_newstrides, 0, &__pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 243, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

      /* "cupy/core/elementwise.pxi":244
 *                     newstrides.push_back(arr._strides[j])
 *             arr._set_shape_and_strides(newshape, newstrides, False)
 *             a = arr             # <<<<<<<<<<<<<<
 *         ret.append(a)
 *     return ret, tuple(newshape)
 */
      __Pyx_INCREF(((PyObject *)__pyx_v_arr));
      __Pyx_DECREF_SET(__pyx_v_a, ((PyObject *)__pyx_v_arr));

      /* "cupy/core/elementwise.pxi":236
 *     ret = []
 *     for i, a in enumerate(args):
 *         if is_array_flags[i]:             # <<<<<<<<<<<<<<
 *             arr = a
 *             arr = arr.view()
 */
    }

    /* "cupy/core/elementwise.pxi":245
 *             arr._set_shape_and_strides(newshape, newstrides, False)
 *             a = arr
 *         ret.append(a)             # <<<<<<<<<<<<<<
 *     return ret, tuple(newshape)
 * 
 */
    __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_a); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(1, 245, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":235
 *             newshape.push_back(vecshape[i])
 *     ret = []
 *     for i, a in enumerate(args):             # <<<<<<<<<<<<<<
 *         if is_array_flags[i]:
 *             arr = a
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":246
 *             a = arr
 *         ret.append(a)
 *     return ret, tuple(newshape)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_newshape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_12 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_ret);
  __Pyx_GIVEREF(__pyx_v_ret);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_ret);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_12);
  __pyx_t_12 = 0;
  __pyx_r = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":174
 * 
 * 
 * cpdef tuple _reduce_dims(list args, tuple params, tuple shape):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, j, n, ndim, cnt, axis, s
 *     cdef vector.vector[Py_ssize_t] vecshape, newshape, newstrides
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core._reduce_dims", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_p);
  __Pyx_XDECREF((PyObject *)__pyx_v_arr);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_21_reduce_dims(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_20_reduce_dims[] = "_reduce_dims(list args, tuple params, tuple shape) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_21_reduce_dims(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_reduce_dims (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_args,&__pyx_n_s_params,&__pyx_n_s_shape,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_args)) != 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_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_reduce_dims", 1, 3, 3, 1); __PYX_ERR(1, 174, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_reduce_dims", 1, 3, 3, 2); __PYX_ERR(1, 174, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_reduce_dims") < 0)) __PYX_ERR(1, 174, __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_args = ((PyObject*)values[0]);
    __pyx_v_params = ((PyObject*)values[1]);
    __pyx_v_shape = ((PyObject*)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_reduce_dims", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 174, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._reduce_dims", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args), (&PyList_Type), 1, "args", 1))) __PYX_ERR(1, 174, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_params), (&PyTuple_Type), 1, "params", 1))) __PYX_ERR(1, 174, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(1, 174, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_20_reduce_dims(__pyx_self, __pyx_v_args, __pyx_v_params, __pyx_v_shape);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_20_reduce_dims(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args, PyObject *__pyx_v_params, PyObject *__pyx_v_shape) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_reduce_dims", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__reduce_dims(__pyx_v_args, __pyx_v_params, __pyx_v_shape, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._reduce_dims", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":257
 *         readonly bint is_const
 * 
 *     def __init__(self, str param, bint is_const):             # <<<<<<<<<<<<<<
 *         self.name = None
 *         self.dtype = None
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_13ParameterInfo_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_4core_4core_13ParameterInfo_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_param = 0;
  int __pyx_v_is_const;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_param,&__pyx_n_s_is_const,0};
    PyObject* values[2] = {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  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_param)) != 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_is_const)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(1, 257, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(1, 257, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_param = ((PyObject*)values[0]);
    __pyx_v_is_const = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_is_const == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 257, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 257, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ParameterInfo.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_param), (&PyString_Type), 1, "param", 1))) __PYX_ERR(1, 257, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_13ParameterInfo___init__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self), __pyx_v_param, __pyx_v_is_const);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_13ParameterInfo___init__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self, PyObject *__pyx_v_param, int __pyx_v_is_const) {
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_i = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/elementwise.pxi":258
 * 
 *     def __init__(self, str param, bint is_const):
 *         self.name = None             # <<<<<<<<<<<<<<
 *         self.dtype = None
 *         self.ctype = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = ((PyObject*)Py_None);

  /* "cupy/core/elementwise.pxi":259
 *     def __init__(self, str param, bint is_const):
 *         self.name = None
 *         self.dtype = None             # <<<<<<<<<<<<<<
 *         self.ctype = None
 *         self.raw = False
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->dtype);
  __Pyx_DECREF(__pyx_v_self->dtype);
  __pyx_v_self->dtype = Py_None;

  /* "cupy/core/elementwise.pxi":260
 *         self.name = None
 *         self.dtype = None
 *         self.ctype = None             # <<<<<<<<<<<<<<
 *         self.raw = False
 *         self.is_const = is_const
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->ctype);
  __Pyx_DECREF(__pyx_v_self->ctype);
  __pyx_v_self->ctype = ((PyObject*)Py_None);

  /* "cupy/core/elementwise.pxi":261
 *         self.dtype = None
 *         self.ctype = None
 *         self.raw = False             # <<<<<<<<<<<<<<
 *         self.is_const = is_const
 *         s = tuple([i for i in param.split() if len(i) != 0])
 */
  __pyx_v_self->raw = 0;

  /* "cupy/core/elementwise.pxi":262
 *         self.ctype = None
 *         self.raw = False
 *         self.is_const = is_const             # <<<<<<<<<<<<<<
 *         s = tuple([i for i in param.split() if len(i) != 0])
 *         if len(s) < 2:
 */
  __pyx_v_self->is_const = __pyx_v_is_const;

  /* "cupy/core/elementwise.pxi":263
 *         self.raw = False
 *         self.is_const = is_const
 *         s = tuple([i for i in param.split() if len(i) != 0])             # <<<<<<<<<<<<<<
 *         if len(s) < 2:
 *             raise Exception('Syntax error: %s' % param)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyString_Type_split, __pyx_v_param); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 263, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 263, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 263, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 263, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 263, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 263, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_6 = PyObject_Length(__pyx_v_i); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(1, 263, __pyx_L1_error)
    __pyx_t_7 = ((__pyx_t_6 != 0) != 0);
    if (__pyx_t_7) {
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_v_i))) __PYX_ERR(1, 263, __pyx_L1_error)
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_s = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":264
 *         self.is_const = is_const
 *         s = tuple([i for i in param.split() if len(i) != 0])
 *         if len(s) < 2:             # <<<<<<<<<<<<<<
 *             raise Exception('Syntax error: %s' % param)
 * 
 */
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v_s); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 264, __pyx_L1_error)
  __pyx_t_7 = ((__pyx_t_4 < 2) != 0);
  if (unlikely(__pyx_t_7)) {

    /* "cupy/core/elementwise.pxi":265
 *         s = tuple([i for i in param.split() if len(i) != 0])
 *         if len(s) < 2:
 *             raise Exception('Syntax error: %s' % param)             # <<<<<<<<<<<<<<
 * 
 *         t, self.name = s[-2:]
 */
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Syntax_error_s, __pyx_v_param); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 265, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 265, __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, 265, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":264
 *         self.is_const = is_const
 *         s = tuple([i for i in param.split() if len(i) != 0])
 *         if len(s) < 2:             # <<<<<<<<<<<<<<
 *             raise Exception('Syntax error: %s' % param)
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":267
 *             raise Exception('Syntax error: %s' % param)
 * 
 *         t, self.name = s[-2:]             # <<<<<<<<<<<<<<
 *         if t == 'CIndexer':
 *             pass
 */
  __pyx_t_1 = __Pyx_PyTuple_GetSlice(__pyx_v_s, -2L, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (1) {
    PyObject* sequence = __pyx_t_1;
    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, 267, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 267, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 267, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(1, 267, __pyx_L1_error)
  __pyx_v_t = __pyx_t_3;
  __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":268
 * 
 *         t, self.name = s[-2:]
 *         if t == 'CIndexer':             # <<<<<<<<<<<<<<
 *             pass
 *         elif len(t) == 1:
 */
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_t, __pyx_n_s_CIndexer, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 268, __pyx_L1_error)
  if (__pyx_t_7) {
    goto __pyx_L7;
  }

  /* "cupy/core/elementwise.pxi":270
 *         if t == 'CIndexer':
 *             pass
 *         elif len(t) == 1:             # <<<<<<<<<<<<<<
 *             self.ctype = t
 *         else:
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_t); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 270, __pyx_L1_error)
  __pyx_t_7 = ((__pyx_t_4 == 1) != 0);
  if (__pyx_t_7) {

    /* "cupy/core/elementwise.pxi":271
 *             pass
 *         elif len(t) == 1:
 *             self.ctype = t             # <<<<<<<<<<<<<<
 *         else:
 *             dtype = get_dtype(t)
 */
    if (!(likely(PyString_CheckExact(__pyx_v_t))||((__pyx_v_t) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_t)->tp_name), 0))) __PYX_ERR(1, 271, __pyx_L1_error)
    __pyx_t_1 = __pyx_v_t;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->ctype);
    __Pyx_DECREF(__pyx_v_self->ctype);
    __pyx_v_self->ctype = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":270
 *         if t == 'CIndexer':
 *             pass
 *         elif len(t) == 1:             # <<<<<<<<<<<<<<
 *             self.ctype = t
 *         else:
 */
    goto __pyx_L7;
  }

  /* "cupy/core/elementwise.pxi":273
 *             self.ctype = t
 *         else:
 *             dtype = get_dtype(t)             # <<<<<<<<<<<<<<
 *             self.dtype = dtype.type
 *             if dtype.name != t:
 */
  /*else*/ {
    __pyx_t_1 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_t, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 273, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_dtype = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":274
 *         else:
 *             dtype = get_dtype(t)
 *             self.dtype = dtype.type             # <<<<<<<<<<<<<<
 *             if dtype.name != t:
 *                 raise ValueError('Wrong type %s' % t)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 274, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->dtype);
    __Pyx_DECREF(__pyx_v_self->dtype);
    __pyx_v_self->dtype = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":275
 *             dtype = get_dtype(t)
 *             self.dtype = dtype.type
 *             if dtype.name != t:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Wrong type %s' % t)
 *             self.ctype = _get_typename(self.dtype)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_v_t, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 275, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 275, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(__pyx_t_7)) {

      /* "cupy/core/elementwise.pxi":276
 *             self.dtype = dtype.type
 *             if dtype.name != t:
 *                 raise ValueError('Wrong type %s' % t)             # <<<<<<<<<<<<<<
 *             self.ctype = _get_typename(self.dtype)
 * 
 */
      __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_type_s, __pyx_v_t); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 276, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 276, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(1, 276, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":275
 *             dtype = get_dtype(t)
 *             self.dtype = dtype.type
 *             if dtype.name != t:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Wrong type %s' % t)
 *             self.ctype = _get_typename(self.dtype)
 */
    }

    /* "cupy/core/elementwise.pxi":277
 *             if dtype.name != t:
 *                 raise ValueError('Wrong type %s' % t)
 *             self.ctype = _get_typename(self.dtype)             # <<<<<<<<<<<<<<
 * 
 *         for i in s[:-2]:
 */
    __pyx_t_1 = __pyx_v_self->dtype;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 277, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->ctype);
    __Pyx_DECREF(__pyx_v_self->ctype);
    __pyx_v_self->ctype = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
  }
  __pyx_L7:;

  /* "cupy/core/elementwise.pxi":279
 *             self.ctype = _get_typename(self.dtype)
 * 
 *         for i in s[:-2]:             # <<<<<<<<<<<<<<
 *             if i == 'raw':
 *                 self.raw = True
 */
  __pyx_t_2 = __Pyx_PyTuple_GetSlice(__pyx_v_s, 0, -2L); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 279, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 279, __pyx_L1_error)
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 279, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":280
 * 
 *         for i in s[:-2]:
 *             if i == 'raw':             # <<<<<<<<<<<<<<
 *                 self.raw = True
 *             else:
 */
    __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_i, __pyx_n_s_raw_2, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 280, __pyx_L1_error)
    if (likely(__pyx_t_7)) {

      /* "cupy/core/elementwise.pxi":281
 *         for i in s[:-2]:
 *             if i == 'raw':
 *                 self.raw = True             # <<<<<<<<<<<<<<
 *             else:
 *                 raise Exception('Unknown keyword "%s"' % i)
 */
      __pyx_v_self->raw = 1;

      /* "cupy/core/elementwise.pxi":280
 * 
 *         for i in s[:-2]:
 *             if i == 'raw':             # <<<<<<<<<<<<<<
 *                 self.raw = True
 *             else:
 */
      goto __pyx_L11;
    }

    /* "cupy/core/elementwise.pxi":283
 *                 self.raw = True
 *             else:
 *                 raise Exception('Unknown keyword "%s"' % i)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    /*else*/ {
      __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_keyword_s, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 283, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 283, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(1, 283, __pyx_L1_error)
    }
    __pyx_L11:;

    /* "cupy/core/elementwise.pxi":279
 *             self.ctype = _get_typename(self.dtype)
 * 
 *         for i in s[:-2]:             # <<<<<<<<<<<<<<
 *             if i == 'raw':
 *                 self.raw = True
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":257
 *         readonly bint is_const
 * 
 *     def __init__(self, str param, bint is_const):             # <<<<<<<<<<<<<<
 *         self.name = None
 *         self.dtype = None
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.ParameterInfo.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":251
 * cdef class ParameterInfo:
 *     cdef:
 *         readonly str name             # <<<<<<<<<<<<<<
 *         readonly object dtype
 *         readonly str ctype
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_4name_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_13ParameterInfo_4name___get__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_4name___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->name);
  __pyx_r = __pyx_v_self->name;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":252
 *     cdef:
 *         readonly str name
 *         readonly object dtype             # <<<<<<<<<<<<<<
 *         readonly str ctype
 *         readonly bint raw
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_5dtype_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_5dtype_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_13ParameterInfo_5dtype___get__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_5dtype___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->dtype);
  __pyx_r = __pyx_v_self->dtype;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":253
 *         readonly str name
 *         readonly object dtype
 *         readonly str ctype             # <<<<<<<<<<<<<<
 *         readonly bint raw
 *         readonly bint is_const
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_5ctype_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_5ctype_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_13ParameterInfo_5ctype___get__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_5ctype___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->ctype);
  __pyx_r = __pyx_v_self->ctype;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":254
 *         readonly object dtype
 *         readonly str ctype
 *         readonly bint raw             # <<<<<<<<<<<<<<
 *         readonly bint is_const
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_3raw_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_3raw_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_13ParameterInfo_3raw___get__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_3raw___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->raw); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ParameterInfo.raw.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":255
 *         readonly str ctype
 *         readonly bint raw
 *         readonly bint is_const             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, str param, bint is_const):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_8is_const_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_8is_const_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_13ParameterInfo_8is_const___get__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_8is_const___get__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->is_const); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ParameterInfo.is_const.__get__", __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):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.ctype, self.dtype, self.is_const, self.name, self.raw)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_13ParameterInfo_2__reduce_cython__[] = "ParameterInfo.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_3__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_4cupy_4core_4core_13ParameterInfo_2__reduce_cython__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_2__reduce_cython__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.ctype, self.dtype, self.is_const, self.name, self.raw)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->is_const); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->raw); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_self->ctype);
  __Pyx_GIVEREF(__pyx_v_self->ctype);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->ctype);
  __Pyx_INCREF(__pyx_v_self->dtype);
  __Pyx_GIVEREF(__pyx_v_self->dtype);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->dtype);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->name);
  __Pyx_GIVEREF(__pyx_v_self->name);
  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_self->name);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.ctype, self.dtype, self.is_const, self.name, self.raw)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v__dict = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":5
 *     state = (self.ctype, self.dtype, self.is_const, self.name, self.raw)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_4 = (__pyx_v__dict != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.ctype is not None or self.dtype is not None or self.name is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.ctype, self.dtype, self.is_const, self.name, self.raw)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.ctype is not None or self.dtype is not None or self.name is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, None), state
 */
  /*else*/ {
    __pyx_t_4 = (__pyx_v_self->ctype != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->dtype != Py_None);
    __pyx_t_4 = (__pyx_t_6 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_4 = (__pyx_v_self->name != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_4 != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_5;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.ctype is not None or self.dtype is not None or self.name is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, None), state
 *     else:
 */
  __pyx_t_5 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":11
 *         use_setstate = self.ctype is not None or self.dtype is not None or self.name is not None
 *     if use_setstate:
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_ParameterInfo); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_121017544);
    __Pyx_GIVEREF(__pyx_int_121017544);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_121017544);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.ctype is not None or self.dtype is not None or self.name is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, None), state
 *     else:
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ParameterInfo__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_ParameterInfo); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_121017544);
    __Pyx_GIVEREF(__pyx_int_121017544);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_121017544);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.ctype, self.dtype, self.is_const, self.name, self.raw)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.ParameterInfo.__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)":14
 *     else:
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ParameterInfo__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_4core_4core_13ParameterInfo_4__setstate_cython__[] = "ParameterInfo.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_4core_4core_13ParameterInfo_5__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_4cupy_4core_4core_13ParameterInfo_4__setstate_cython__(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_13ParameterInfo_4__setstate_cython__(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ParameterInfo__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(4, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core___pyx_unpickle_ParameterInfo__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_ParameterInfo, (type(self), 0x73694c8, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ParameterInfo__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("cupy.core.core.ParameterInfo.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":287
 * 
 * @util.memoize()
 * def _get_param_info(s, is_const):             # <<<<<<<<<<<<<<
 *     if len(s) == 0:
 *         return ()
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_23_get_param_info(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_22_get_param_info[] = "_get_param_info(s, is_const)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_23_get_param_info = {"_get_param_info", (PyCFunction)__pyx_pw_4cupy_4core_4core_23_get_param_info, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_22_get_param_info};
static PyObject *__pyx_pw_4cupy_4core_4core_23_get_param_info(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_s = 0;
  PyObject *__pyx_v_is_const = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_param_info (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_s_2,&__pyx_n_s_is_const,0};
    PyObject* values[2] = {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  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_s_2)) != 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_is_const)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_param_info", 1, 2, 2, 1); __PYX_ERR(1, 287, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_param_info") < 0)) __PYX_ERR(1, 287, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_s = values[0];
    __pyx_v_is_const = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_param_info", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 287, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_param_info", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_22_get_param_info(__pyx_self, __pyx_v_s, __pyx_v_is_const);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_22_get_param_info(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_s, PyObject *__pyx_v_is_const) {
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __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)(PyObject *);
  __Pyx_RefNannySetupContext("_get_param_info", 0);

  /* "cupy/core/elementwise.pxi":288
 * @util.memoize()
 * def _get_param_info(s, is_const):
 *     if len(s) == 0:             # <<<<<<<<<<<<<<
 *         return ()
 *     return tuple([ParameterInfo(i, is_const) for i in s.strip().split(',')])
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 288, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 == 0) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":289
 * def _get_param_info(s, is_const):
 *     if len(s) == 0:
 *         return ()             # <<<<<<<<<<<<<<
 *     return tuple([ParameterInfo(i, is_const) for i in s.strip().split(',')])
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":288
 * @util.memoize()
 * def _get_param_info(s, is_const):
 *     if len(s) == 0:             # <<<<<<<<<<<<<<
 *         return ()
 *     return tuple([ParameterInfo(i, is_const) for i in s.strip().split(',')])
 */
  }

  /* "cupy/core/elementwise.pxi":290
 *     if len(s) == 0:
 *         return ()
 *     return tuple([ParameterInfo(i, is_const) for i in s.strip().split(',')])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_strip); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 290, __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);
    }
  }
  if (__pyx_t_6) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 290, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 290, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_split); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_1 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 290, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(1, 290, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 290, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(1, 290, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 290, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_7(__pyx_t_5);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 290, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_i);
    __Pyx_INCREF(__pyx_v_is_const);
    __Pyx_GIVEREF(__pyx_v_is_const);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_is_const);
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ParameterInfo), __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_6))) __PYX_ERR(1, 290, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":287
 * 
 * @util.memoize()
 * def _get_param_info(s, is_const):             # <<<<<<<<<<<<<<
 *     if len(s) == 0:
 *         return ()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core._get_param_info", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":294
 * 
 * @util.memoize()
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):             # <<<<<<<<<<<<<<
 *     type_dict = {}
 *     if out_args_dtype:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_25_decide_params_type(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_24_decide_params_type[] = "_decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_25_decide_params_type = {"_decide_params_type", (PyCFunction)__pyx_pw_4cupy_4core_4core_25_decide_params_type, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_24_decide_params_type};
static PyObject *__pyx_pw_4cupy_4core_4core_25_decide_params_type(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_in_params = 0;
  PyObject *__pyx_v_out_params = 0;
  PyObject *__pyx_v_in_args_dtype = 0;
  PyObject *__pyx_v_out_args_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_decide_params_type (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_params,&__pyx_n_s_out_params,&__pyx_n_s_in_args_dtype,&__pyx_n_s_out_args_dtype,0};
    PyObject* values[4] = {0,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  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_in_params)) != 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_out_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_decide_params_type", 1, 4, 4, 1); __PYX_ERR(1, 294, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_in_args_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_decide_params_type", 1, 4, 4, 2); __PYX_ERR(1, 294, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out_args_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_decide_params_type", 1, 4, 4, 3); __PYX_ERR(1, 294, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_decide_params_type") < 0)) __PYX_ERR(1, 294, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_in_params = values[0];
    __pyx_v_out_params = values[1];
    __pyx_v_in_args_dtype = values[2];
    __pyx_v_out_args_dtype = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_decide_params_type", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 294, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._decide_params_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_24_decide_params_type(__pyx_self, __pyx_v_in_params, __pyx_v_out_params, __pyx_v_in_args_dtype, __pyx_v_out_args_dtype);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_24_decide_params_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_params, PyObject *__pyx_v_out_params, PyObject *__pyx_v_in_args_dtype, PyObject *__pyx_v_out_args_dtype) {
  PyObject *__pyx_v_type_dict = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_unknown_ctype = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  int __pyx_t_11;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_RefNannySetupContext("_decide_params_type", 0);

  /* "cupy/core/elementwise.pxi":295
 * @util.memoize()
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):
 *     type_dict = {}             # <<<<<<<<<<<<<<
 *     if out_args_dtype:
 *         assert len(out_params) == len(out_args_dtype)
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_type_dict = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":296
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):
 *     type_dict = {}
 *     if out_args_dtype:             # <<<<<<<<<<<<<<
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in zip(out_params, out_args_dtype):
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_out_args_dtype); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 296, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":297
 *     type_dict = {}
 *     if out_args_dtype:
 *         assert len(out_params) == len(out_args_dtype)             # <<<<<<<<<<<<<<
 *         for p, a in zip(out_params, out_args_dtype):
 *             if a is None:
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_3 = PyObject_Length(__pyx_v_out_params); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 297, __pyx_L1_error)
      __pyx_t_4 = PyObject_Length(__pyx_v_out_args_dtype); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 297, __pyx_L1_error)
      if (unlikely(!((__pyx_t_3 == __pyx_t_4) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(1, 297, __pyx_L1_error)
      }
    }
    #endif

    /* "cupy/core/elementwise.pxi":298
 *     if out_args_dtype:
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in zip(out_params, out_args_dtype):             # <<<<<<<<<<<<<<
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 */
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_out_params);
    __Pyx_GIVEREF(__pyx_v_out_params);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_out_params);
    __Pyx_INCREF(__pyx_v_out_args_dtype);
    __Pyx_GIVEREF(__pyx_v_out_args_dtype);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_out_args_dtype);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
      __pyx_t_1 = __pyx_t_5; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 298, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 298, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 298, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 298, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 298, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 298, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        }
      } else {
        __pyx_t_5 = __pyx_t_6(__pyx_t_1);
        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, 298, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
        PyObject* sequence = __pyx_t_5;
        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, 298, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        #else
        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 298, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 298, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 298, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
        index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(1, 298, __pyx_L1_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(1, 298, __pyx_L1_error)
        __pyx_L7_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_7);
      __pyx_t_7 = 0;
      __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "cupy/core/elementwise.pxi":299
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in zip(out_params, out_args_dtype):
 *             if a is None:             # <<<<<<<<<<<<<<
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:
 */
      __pyx_t_2 = (__pyx_v_a == Py_None);
      __pyx_t_11 = (__pyx_t_2 != 0);
      if (unlikely(__pyx_t_11)) {

        /* "cupy/core/elementwise.pxi":300
 *         for p, a in zip(out_params, out_args_dtype):
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')             # <<<<<<<<<<<<<<
 *             if p.dtype is not None:
 *                 if get_dtype(a) != get_dtype(p.dtype):
 */
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 300, __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, 300, __pyx_L1_error)

        /* "cupy/core/elementwise.pxi":299
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in zip(out_params, out_args_dtype):
 *             if a is None:             # <<<<<<<<<<<<<<
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:
 */
      }

      /* "cupy/core/elementwise.pxi":301
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:             # <<<<<<<<<<<<<<
 *                 if get_dtype(a) != get_dtype(p.dtype):
 *                     raise TypeError(
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 301, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_11 = (__pyx_t_5 != Py_None);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_2 = (__pyx_t_11 != 0);
      if (__pyx_t_2) {

        /* "cupy/core/elementwise.pxi":302
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:
 *                 if get_dtype(a) != get_dtype(p.dtype):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 */
        __pyx_t_5 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_a, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 302, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 302, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_7 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_t_8, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 302, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, __pyx_t_7, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 302, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 302, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(__pyx_t_2)) {

          /* "cupy/core/elementwise.pxi":304
 *                 if get_dtype(a) != get_dtype(p.dtype):
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))             # <<<<<<<<<<<<<<
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 */
          __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 304, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 304, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 304, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8);
          __Pyx_INCREF(__pyx_v_a);
          __Pyx_GIVEREF(__pyx_v_a);
          PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_a);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_7);
          __pyx_t_8 = 0;
          __pyx_t_7 = 0;
          __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Type_is_mismatched_s_s_s, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 304, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "cupy/core/elementwise.pxi":303
 *             if p.dtype is not None:
 *                 if get_dtype(a) != get_dtype(p.dtype):
 *                     raise TypeError(             # <<<<<<<<<<<<<<
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:
 */
          __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 303, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_Raise(__pyx_t_5, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __PYX_ERR(1, 303, __pyx_L1_error)

          /* "cupy/core/elementwise.pxi":302
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:
 *                 if get_dtype(a) != get_dtype(p.dtype):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 */
        }

        /* "cupy/core/elementwise.pxi":301
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 *             if p.dtype is not None:             # <<<<<<<<<<<<<<
 *                 if get_dtype(a) != get_dtype(p.dtype):
 *                     raise TypeError(
 */
        goto __pyx_L9;
      }

      /* "cupy/core/elementwise.pxi":305
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:             # <<<<<<<<<<<<<<
 *                 t = type_dict[p.ctype]
 *                 if get_dtype(t) != get_dtype(a):
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 305, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_t_5, __pyx_v_type_dict, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 305, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_11 = (__pyx_t_2 != 0);
      if (__pyx_t_11) {

        /* "cupy/core/elementwise.pxi":306
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]             # <<<<<<<<<<<<<<
 *                 if get_dtype(t) != get_dtype(a):
 *                     raise TypeError(
 */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 306, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_type_dict, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 306, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_7);
        __pyx_t_7 = 0;

        /* "cupy/core/elementwise.pxi":307
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 *                 if get_dtype(t) != get_dtype(a):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 */
        __pyx_t_7 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_t, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 307, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_a, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 307, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_8 = PyObject_RichCompare(__pyx_t_7, __pyx_t_5, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 307, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(1, 307, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(__pyx_t_11)) {

          /* "cupy/core/elementwise.pxi":310
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 *                             p.name, a, t, p.ctype))             # <<<<<<<<<<<<<<
 *             else:
 *                 type_dict[p.ctype] = a
 */
          __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 310, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 310, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 310, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8);
          __Pyx_INCREF(__pyx_v_a);
          __Pyx_GIVEREF(__pyx_v_a);
          PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_a);
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_v_t);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_5);
          __pyx_t_8 = 0;
          __pyx_t_5 = 0;

          /* "cupy/core/elementwise.pxi":309
 *                 if get_dtype(t) != get_dtype(a):
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (             # <<<<<<<<<<<<<<
 *                             p.name, a, t, p.ctype))
 *             else:
 */
          __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Type_is_mismatched_s_s_s_s, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 309, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "cupy/core/elementwise.pxi":308
 *                 t = type_dict[p.ctype]
 *                 if get_dtype(t) != get_dtype(a):
 *                     raise TypeError(             # <<<<<<<<<<<<<<
 *                         'Type is mismatched. %s %s %s %s' % (
 *                             p.name, a, t, p.ctype))
 */
          __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 308, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_Raise(__pyx_t_7, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __PYX_ERR(1, 308, __pyx_L1_error)

          /* "cupy/core/elementwise.pxi":307
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 *                 if get_dtype(t) != get_dtype(a):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 */
        }

        /* "cupy/core/elementwise.pxi":305
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:             # <<<<<<<<<<<<<<
 *                 t = type_dict[p.ctype]
 *                 if get_dtype(t) != get_dtype(a):
 */
        goto __pyx_L9;
      }

      /* "cupy/core/elementwise.pxi":312
 *                             p.name, a, t, p.ctype))
 *             else:
 *                 type_dict[p.ctype] = a             # <<<<<<<<<<<<<<
 * 
 *     assert len(in_params) == len(in_args_dtype)
 */
      /*else*/ {
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 312, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (unlikely(PyDict_SetItem(__pyx_v_type_dict, __pyx_t_7, __pyx_v_a) < 0)) __PYX_ERR(1, 312, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __pyx_L9:;

      /* "cupy/core/elementwise.pxi":298
 *     if out_args_dtype:
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in zip(out_params, out_args_dtype):             # <<<<<<<<<<<<<<
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":296
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):
 *     type_dict = {}
 *     if out_args_dtype:             # <<<<<<<<<<<<<<
 *         assert len(out_params) == len(out_args_dtype)
 *         for p, a in zip(out_params, out_args_dtype):
 */
  }

  /* "cupy/core/elementwise.pxi":314
 *                 type_dict[p.ctype] = a
 * 
 *     assert len(in_params) == len(in_args_dtype)             # <<<<<<<<<<<<<<
 *     unknown_ctype = []
 *     for p, a in zip(in_params, in_args_dtype):
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_4 = PyObject_Length(__pyx_v_in_params); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 314, __pyx_L1_error)
    __pyx_t_3 = PyObject_Length(__pyx_v_in_args_dtype); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 314, __pyx_L1_error)
    if (unlikely(!((__pyx_t_4 == __pyx_t_3) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(1, 314, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/core/elementwise.pxi":315
 * 
 *     assert len(in_params) == len(in_args_dtype)
 *     unknown_ctype = []             # <<<<<<<<<<<<<<
 *     for p, a in zip(in_params, in_args_dtype):
 *         if a is None:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_unknown_ctype = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":316
 *     assert len(in_params) == len(in_args_dtype)
 *     unknown_ctype = []
 *     for p, a in zip(in_params, in_args_dtype):             # <<<<<<<<<<<<<<
 *         if a is None:
 *             if p.dtype is None:
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 316, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_in_params);
  __Pyx_GIVEREF(__pyx_v_in_params);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_in_params);
  __Pyx_INCREF(__pyx_v_in_args_dtype);
  __Pyx_GIVEREF(__pyx_v_in_args_dtype);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_in_args_dtype);
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 316, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_7)) || PyTuple_CheckExact(__pyx_t_7)) {
    __pyx_t_1 = __pyx_t_7; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 316, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 316, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_7); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 316, __pyx_L1_error)
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 316, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_7); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 316, __pyx_L1_error)
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 316, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      }
    } else {
      __pyx_t_7 = __pyx_t_6(__pyx_t_1);
      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, 316, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_7);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
      PyObject* sequence = __pyx_t_7;
      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, 316, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_8);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 316, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 316, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      #endif
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_9 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 316, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_5)) goto __pyx_L14_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L14_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_8);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(1, 316, __pyx_L1_error)
      __pyx_t_10 = NULL;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L15_unpacking_done;
      __pyx_L14_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(1, 316, __pyx_L1_error)
      __pyx_L15_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/elementwise.pxi":317
 *     unknown_ctype = []
 *     for p, a in zip(in_params, in_args_dtype):
 *         if a is None:             # <<<<<<<<<<<<<<
 *             if p.dtype is None:
 *                 unknown_ctype.append(p.ctype)
 */
    __pyx_t_11 = (__pyx_v_a == Py_None);
    __pyx_t_2 = (__pyx_t_11 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":318
 *     for p, a in zip(in_params, in_args_dtype):
 *         if a is None:
 *             if p.dtype is None:             # <<<<<<<<<<<<<<
 *                 unknown_ctype.append(p.ctype)
 *         else:
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 318, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_2 = (__pyx_t_7 == Py_None);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_11 = (__pyx_t_2 != 0);
      if (__pyx_t_11) {

        /* "cupy/core/elementwise.pxi":319
 *         if a is None:
 *             if p.dtype is None:
 *                 unknown_ctype.append(p.ctype)             # <<<<<<<<<<<<<<
 *         else:
 *             if p.dtype is not None:
 */
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 319, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_unknown_ctype, __pyx_t_7); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(1, 319, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "cupy/core/elementwise.pxi":318
 *     for p, a in zip(in_params, in_args_dtype):
 *         if a is None:
 *             if p.dtype is None:             # <<<<<<<<<<<<<<
 *                 unknown_ctype.append(p.ctype)
 *         else:
 */
      }

      /* "cupy/core/elementwise.pxi":317
 *     unknown_ctype = []
 *     for p, a in zip(in_params, in_args_dtype):
 *         if a is None:             # <<<<<<<<<<<<<<
 *             if p.dtype is None:
 *                 unknown_ctype.append(p.ctype)
 */
      goto __pyx_L16;
    }

    /* "cupy/core/elementwise.pxi":321
 *                 unknown_ctype.append(p.ctype)
 *         else:
 *             if p.dtype is not None:             # <<<<<<<<<<<<<<
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):
 *                     raise TypeError(
 */
    /*else*/ {
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_11 = (__pyx_t_7 != Py_None);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_2 = (__pyx_t_11 != 0);
      if (__pyx_t_2) {

        /* "cupy/core/elementwise.pxi":322
 *         else:
 *             if p.dtype is not None:
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 */
        __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 322, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 322, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        if (!__pyx_t_8) {
          __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_a); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 322, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_5)) {
            PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_a};
            __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 322, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_GOTREF(__pyx_t_7);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
            PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_a};
            __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 322, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_GOTREF(__pyx_t_7);
          } else
          #endif
          {
            __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 322, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
            __Pyx_INCREF(__pyx_v_a);
            __Pyx_GIVEREF(__pyx_v_a);
            PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_a);
            __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 322, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 322, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 322, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 322, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_13 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_13)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        if (!__pyx_t_13) {
          __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 322, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_5);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_8)) {
            PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_9};
            __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 322, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
            PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_9};
            __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 322, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          } else
          #endif
          {
            __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 322, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
            __Pyx_GIVEREF(__pyx_t_9);
            PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_9);
            __pyx_t_9 = 0;
            __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_14, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 322, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = PyObject_RichCompare(__pyx_t_7, __pyx_t_5, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 322, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 322, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(__pyx_t_2)) {

          /* "cupy/core/elementwise.pxi":324
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))             # <<<<<<<<<<<<<<
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 */
          __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 324, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 324, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 324, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8);
          __Pyx_INCREF(__pyx_v_a);
          __Pyx_GIVEREF(__pyx_v_a);
          PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_a);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_5);
          __pyx_t_8 = 0;
          __pyx_t_5 = 0;
          __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Type_is_mismatched_s_s_s, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 324, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "cupy/core/elementwise.pxi":323
 *             if p.dtype is not None:
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):
 *                     raise TypeError(             # <<<<<<<<<<<<<<
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:
 */
          __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 323, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_Raise(__pyx_t_7, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __PYX_ERR(1, 323, __pyx_L1_error)

          /* "cupy/core/elementwise.pxi":322
 *         else:
 *             if p.dtype is not None:
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 */
        }

        /* "cupy/core/elementwise.pxi":321
 *                 unknown_ctype.append(p.ctype)
 *         else:
 *             if p.dtype is not None:             # <<<<<<<<<<<<<<
 *                 if numpy.dtype(a) != numpy.dtype(p.dtype):
 *                     raise TypeError(
 */
        goto __pyx_L18;
      }

      /* "cupy/core/elementwise.pxi":325
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:             # <<<<<<<<<<<<<<
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 325, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_t_7, __pyx_v_type_dict, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 325, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_11 = (__pyx_t_2 != 0);
      if (__pyx_t_11) {

        /* "cupy/core/elementwise.pxi":326
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]             # <<<<<<<<<<<<<<
 *                 if numpy.dtype(t) != numpy.dtype(a):
 *                     raise TypeError(
 */
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 326, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_type_dict, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 326, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_5);
        __pyx_t_5 = 0;

        /* "cupy/core/elementwise.pxi":327
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 */
        __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 327, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 327, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_7)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        if (!__pyx_t_7) {
          __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_t); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 327, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_8)) {
            PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_t};
            __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 327, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_GOTREF(__pyx_t_5);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
            PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_t};
            __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 327, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_GOTREF(__pyx_t_5);
          } else
          #endif
          {
            __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 327, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_7); __pyx_t_7 = NULL;
            __Pyx_INCREF(__pyx_v_t);
            __Pyx_GIVEREF(__pyx_v_t);
            PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_t);
            __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_14, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 327, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 327, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 327, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_14 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_7);
          if (likely(__pyx_t_14)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_7, function);
          }
        }
        if (!__pyx_t_14) {
          __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_a); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 327, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_v_a};
            __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 327, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_GOTREF(__pyx_t_8);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_v_a};
            __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 327, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_GOTREF(__pyx_t_8);
          } else
          #endif
          {
            __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 327, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_14); __pyx_t_14 = NULL;
            __Pyx_INCREF(__pyx_v_a);
            __Pyx_GIVEREF(__pyx_v_a);
            PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_a);
            __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 327, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = PyObject_RichCompare(__pyx_t_5, __pyx_t_8, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 327, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(1, 327, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(__pyx_t_11)) {

          /* "cupy/core/elementwise.pxi":330
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 *                             p.name, a, t, p.ctype))             # <<<<<<<<<<<<<<
 *             else:
 *                 type_dict[p.ctype] = a
 */
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 330, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 330, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 330, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7);
          __Pyx_INCREF(__pyx_v_a);
          __Pyx_GIVEREF(__pyx_v_a);
          PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_a);
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_t);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_8);
          __pyx_t_7 = 0;
          __pyx_t_8 = 0;

          /* "cupy/core/elementwise.pxi":329
 *                 if numpy.dtype(t) != numpy.dtype(a):
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (             # <<<<<<<<<<<<<<
 *                             p.name, a, t, p.ctype))
 *             else:
 */
          __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_Type_is_mismatched_s_s_s_s, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 329, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "cupy/core/elementwise.pxi":328
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):
 *                     raise TypeError(             # <<<<<<<<<<<<<<
 *                         'Type is mismatched. %s %s %s %s' % (
 *                             p.name, a, t, p.ctype))
 */
          __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 328, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_Raise(__pyx_t_5, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __PYX_ERR(1, 328, __pyx_L1_error)

          /* "cupy/core/elementwise.pxi":327
 *             elif p.ctype in type_dict:
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s %s' % (
 */
        }

        /* "cupy/core/elementwise.pxi":325
 *                     raise TypeError(
 *                         'Type is mismatched. %s %s %s' % (p.name, a, p.dtype))
 *             elif p.ctype in type_dict:             # <<<<<<<<<<<<<<
 *                 t = type_dict[p.ctype]
 *                 if numpy.dtype(t) != numpy.dtype(a):
 */
        goto __pyx_L18;
      }

      /* "cupy/core/elementwise.pxi":332
 *                             p.name, a, t, p.ctype))
 *             else:
 *                 type_dict[p.ctype] = a             # <<<<<<<<<<<<<<
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 */
      /*else*/ {
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 332, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (unlikely(PyDict_SetItem(__pyx_v_type_dict, __pyx_t_5, __pyx_v_a) < 0)) __PYX_ERR(1, 332, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __pyx_L18:;
    }
    __pyx_L16:;

    /* "cupy/core/elementwise.pxi":316
 *     assert len(in_params) == len(in_args_dtype)
 *     unknown_ctype = []
 *     for p, a in zip(in_params, in_args_dtype):             # <<<<<<<<<<<<<<
 *         if a is None:
 *             if p.dtype is None:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":334
 *                 type_dict[p.ctype] = a
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":335
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                       for p in in_params])             # <<<<<<<<<<<<<<
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                        for p in out_params])
 */
  if (likely(PyList_CheckExact(__pyx_v_in_params)) || PyTuple_CheckExact(__pyx_v_in_params)) {
    __pyx_t_5 = __pyx_v_in_params; __Pyx_INCREF(__pyx_t_5); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_in_params); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 335, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 335, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_8); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 335, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 335, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_8); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 335, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 335, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      }
    } else {
      __pyx_t_8 = __pyx_t_6(__pyx_t_5);
      if (unlikely(!__pyx_t_8)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 335, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_8);
    }
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/elementwise.pxi":334
 *                 type_dict[p.ctype] = a
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 334, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_11 = (__pyx_t_7 == Py_None);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if ((__pyx_t_11 != 0)) {
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_9 = __Pyx_PyDict_GetItem(__pyx_v_type_dict, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = __pyx_t_9;
      __pyx_t_9 = 0;
    } else {
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = __pyx_t_9;
      __pyx_t_9 = 0;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_8))) __PYX_ERR(1, 334, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/elementwise.pxi":335
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                       for p in in_params])             # <<<<<<<<<<<<<<
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                        for p in out_params])
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/elementwise.pxi":334
 *                 type_dict[p.ctype] = a
 * 
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 */
  __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_in_types = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/elementwise.pxi":336
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                        for p in out_params])
 *     return in_types, out_types, tuple(type_dict.items())
 */
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 336, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/elementwise.pxi":337
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                        for p in out_params])             # <<<<<<<<<<<<<<
 *     return in_types, out_types, tuple(type_dict.items())
 * 
 */
  if (likely(PyList_CheckExact(__pyx_v_out_params)) || PyTuple_CheckExact(__pyx_v_out_params)) {
    __pyx_t_1 = __pyx_v_out_params; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_out_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 337, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 337, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_8); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 337, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 337, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_8); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 337, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 337, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      }
    } else {
      __pyx_t_8 = __pyx_t_6(__pyx_t_1);
      if (unlikely(!__pyx_t_8)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 337, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_8);
    }
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/elementwise.pxi":336
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                        for p in out_params])
 *     return in_types, out_types, tuple(type_dict.items())
 */
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 336, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = (__pyx_t_9 == Py_None);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if ((__pyx_t_11 != 0)) {
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 336, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_type_dict, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 336, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_8 = __pyx_t_7;
      __pyx_t_7 = 0;
    } else {
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 336, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __pyx_t_7;
      __pyx_t_7 = 0;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_8))) __PYX_ERR(1, 336, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/elementwise.pxi":337
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                        for p in out_params])             # <<<<<<<<<<<<<<
 *     return in_types, out_types, tuple(type_dict.items())
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":336
 *     in_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                       for p in in_params])
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype             # <<<<<<<<<<<<<<
 *                        for p in out_params])
 *     return in_types, out_types, tuple(type_dict.items())
 */
  __pyx_t_1 = PyList_AsTuple(((PyObject*)__pyx_t_5)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 336, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_out_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":338
 *     out_types = tuple([type_dict[p.ctype] if p.dtype is None else p.dtype
 *                        for p in out_params])
 *     return in_types, out_types, tuple(type_dict.items())             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyDict_Items(__pyx_v_type_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_in_types);
  __Pyx_GIVEREF(__pyx_v_in_types);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_in_types);
  __Pyx_INCREF(__pyx_v_out_types);
  __Pyx_GIVEREF(__pyx_v_out_types);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_out_types);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":294
 * 
 * @util.memoize()
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):             # <<<<<<<<<<<<<<
 *     type_dict = {}
 *     if out_args_dtype:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("cupy.core.core._decide_params_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_type_dict);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_unknown_ctype);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":341
 * 
 * 
 * cdef tuple _broadcast(list args, tuple params, bint use_size):             # <<<<<<<<<<<<<<
 *     cpdef Py_ssize_t i
 *     cpdef ParameterInfo p
 */

static PyObject *__pyx_f_4cupy_4core_4core__broadcast(PyObject *__pyx_v_args, PyObject *__pyx_v_params, int __pyx_v_use_size) {
  Py_ssize_t __pyx_v_i;
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_p = 0;
  int __pyx_v_is_none;
  int __pyx_v_is_not_none;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_v_a = NULL;
  struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_brod = NULL;
  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;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("_broadcast", 0);

  /* "cupy/core/elementwise.pxi":345
 *     cpdef ParameterInfo p
 *     cpdef bint is_none, is_not_none
 *     value = []             # <<<<<<<<<<<<<<
 *     is_none = False
 *     is_not_none = False
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_value = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":346
 *     cpdef bint is_none, is_not_none
 *     value = []
 *     is_none = False             # <<<<<<<<<<<<<<
 *     is_not_none = False
 *     for i in range(len(args)):
 */
  __pyx_v_is_none = 0;

  /* "cupy/core/elementwise.pxi":347
 *     value = []
 *     is_none = False
 *     is_not_none = False             # <<<<<<<<<<<<<<
 *     for i in range(len(args)):
 *         p = params[i]
 */
  __pyx_v_is_not_none = 0;

  /* "cupy/core/elementwise.pxi":348
 *     is_none = False
 *     is_not_none = False
 *     for i in range(len(args)):             # <<<<<<<<<<<<<<
 *         p = params[i]
 *         a = args[i]
 */
  if (unlikely(__pyx_v_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 348, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(1, 348, __pyx_L1_error)
  __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;

    /* "cupy/core/elementwise.pxi":349
 *     is_not_none = False
 *     for i in range(len(args)):
 *         p = params[i]             # <<<<<<<<<<<<<<
 *         a = args[i]
 *         if not p.raw and isinstance(a, ndarray):
 */
    if (unlikely(__pyx_v_params == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 349, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_params, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 349, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ParameterInfo))))) __PYX_ERR(1, 349, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_p, ((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":350
 *     for i in range(len(args)):
 *         p = params[i]
 *         a = args[i]             # <<<<<<<<<<<<<<
 *         if not p.raw and isinstance(a, ndarray):
 *             is_not_none = True
 */
    if (unlikely(__pyx_v_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 350, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_args, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 350, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":351
 *         p = params[i]
 *         a = args[i]
 *         if not p.raw and isinstance(a, ndarray):             # <<<<<<<<<<<<<<
 *             is_not_none = True
 *             value.append(a)
 */
    __pyx_t_6 = ((!(__pyx_v_p->raw != 0)) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_7 = (__pyx_t_6 != 0);
    __pyx_t_5 = __pyx_t_7;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_5) {

      /* "cupy/core/elementwise.pxi":352
 *         a = args[i]
 *         if not p.raw and isinstance(a, ndarray):
 *             is_not_none = True             # <<<<<<<<<<<<<<
 *             value.append(a)
 *         else:
 */
      __pyx_v_is_not_none = 1;

      /* "cupy/core/elementwise.pxi":353
 *         if not p.raw and isinstance(a, ndarray):
 *             is_not_none = True
 *             value.append(a)             # <<<<<<<<<<<<<<
 *         else:
 *             is_none = True
 */
      __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_value, __pyx_v_a); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(1, 353, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":351
 *         p = params[i]
 *         a = args[i]
 *         if not p.raw and isinstance(a, ndarray):             # <<<<<<<<<<<<<<
 *             is_not_none = True
 *             value.append(a)
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":355
 *             value.append(a)
 *         else:
 *             is_none = True             # <<<<<<<<<<<<<<
 *             value.append(None)
 * 
 */
    /*else*/ {
      __pyx_v_is_none = 1;

      /* "cupy/core/elementwise.pxi":356
 *         else:
 *             is_none = True
 *             value.append(None)             # <<<<<<<<<<<<<<
 * 
 *     if use_size:
 */
      __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_value, Py_None); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(1, 356, __pyx_L1_error)
    }
    __pyx_L5:;
  }

  /* "cupy/core/elementwise.pxi":358
 *             value.append(None)
 * 
 *     if use_size:             # <<<<<<<<<<<<<<
 *         if not is_none:
 *             raise ValueError("Specified 'size' can be used only "
 */
  __pyx_t_5 = (__pyx_v_use_size != 0);
  if (__pyx_t_5) {

    /* "cupy/core/elementwise.pxi":359
 * 
 *     if use_size:
 *         if not is_none:             # <<<<<<<<<<<<<<
 *             raise ValueError("Specified 'size' can be used only "
 *                              "if all of the ndarray are 'raw'.")
 */
    __pyx_t_5 = ((!(__pyx_v_is_none != 0)) != 0);
    if (unlikely(__pyx_t_5)) {

      /* "cupy/core/elementwise.pxi":360
 *     if use_size:
 *         if not is_none:
 *             raise ValueError("Specified 'size' can be used only "             # <<<<<<<<<<<<<<
 *                              "if all of the ndarray are 'raw'.")
 *     else:
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__60, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 360, __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, 360, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":359
 * 
 *     if use_size:
 *         if not is_none:             # <<<<<<<<<<<<<<
 *             raise ValueError("Specified 'size' can be used only "
 *                              "if all of the ndarray are 'raw'.")
 */
    }

    /* "cupy/core/elementwise.pxi":358
 *             value.append(None)
 * 
 *     if use_size:             # <<<<<<<<<<<<<<
 *         if not is_none:
 *             raise ValueError("Specified 'size' can be used only "
 */
    goto __pyx_L8;
  }

  /* "cupy/core/elementwise.pxi":363
 *                              "if all of the ndarray are 'raw'.")
 *     else:
 *         if not is_not_none:             # <<<<<<<<<<<<<<
 *             raise ValueError('Loop size is Undecided')
 *     brod = broadcast(*value)
 */
  /*else*/ {
    __pyx_t_5 = ((!(__pyx_v_is_not_none != 0)) != 0);
    if (unlikely(__pyx_t_5)) {

      /* "cupy/core/elementwise.pxi":364
 *     else:
 *         if not is_not_none:
 *             raise ValueError('Loop size is Undecided')             # <<<<<<<<<<<<<<
 *     brod = broadcast(*value)
 *     value = []
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__61, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 364, __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, 364, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":363
 *                              "if all of the ndarray are 'raw'.")
 *     else:
 *         if not is_not_none:             # <<<<<<<<<<<<<<
 *             raise ValueError('Loop size is Undecided')
 *     brod = broadcast(*value)
 */
    }
  }
  __pyx_L8:;

  /* "cupy/core/elementwise.pxi":365
 *         if not is_not_none:
 *             raise ValueError('Loop size is Undecided')
 *     brod = broadcast(*value)             # <<<<<<<<<<<<<<
 *     value = []
 *     for i in range(len(args)):
 */
  __pyx_t_1 = PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 365, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_t_1, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 365, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_brod = ((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":366
 *             raise ValueError('Loop size is Undecided')
 *     brod = broadcast(*value)
 *     value = []             # <<<<<<<<<<<<<<
 *     for i in range(len(args)):
 *         a = brod.values[i]
 */
  __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 366, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF_SET(__pyx_v_value, ((PyObject*)__pyx_t_9));
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":367
 *     brod = broadcast(*value)
 *     value = []
 *     for i in range(len(args)):             # <<<<<<<<<<<<<<
 *         a = brod.values[i]
 *         if a is None:
 */
  if (unlikely(__pyx_v_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 367, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(1, 367, __pyx_L1_error)
  __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;

    /* "cupy/core/elementwise.pxi":368
 *     value = []
 *     for i in range(len(args)):
 *         a = brod.values[i]             # <<<<<<<<<<<<<<
 *         if a is None:
 *             a = args[i]
 */
    if (unlikely(__pyx_v_brod->values == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 368, __pyx_L1_error)
    }
    __pyx_t_9 = __Pyx_GetItemInt_Tuple(__pyx_v_brod->values, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 368, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_9);
    __pyx_t_9 = 0;

    /* "cupy/core/elementwise.pxi":369
 *     for i in range(len(args)):
 *         a = brod.values[i]
 *         if a is None:             # <<<<<<<<<<<<<<
 *             a = args[i]
 *         value.append(a)
 */
    __pyx_t_5 = (__pyx_v_a == Py_None);
    __pyx_t_7 = (__pyx_t_5 != 0);
    if (__pyx_t_7) {

      /* "cupy/core/elementwise.pxi":370
 *         a = brod.values[i]
 *         if a is None:
 *             a = args[i]             # <<<<<<<<<<<<<<
 *         value.append(a)
 *     return value, brod.shape
 */
      if (unlikely(__pyx_v_args == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(1, 370, __pyx_L1_error)
      }
      __pyx_t_9 = __Pyx_GetItemInt_List(__pyx_v_args, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 370, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF_SET(__pyx_v_a, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "cupy/core/elementwise.pxi":369
 *     for i in range(len(args)):
 *         a = brod.values[i]
 *         if a is None:             # <<<<<<<<<<<<<<
 *             a = args[i]
 *         value.append(a)
 */
    }

    /* "cupy/core/elementwise.pxi":371
 *         if a is None:
 *             a = args[i]
 *         value.append(a)             # <<<<<<<<<<<<<<
 *     return value, brod.shape
 * 
 */
    __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_value, __pyx_v_a); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(1, 371, __pyx_L1_error)
  }

  /* "cupy/core/elementwise.pxi":372
 *             a = args[i]
 *         value.append(a)
 *     return value, brod.shape             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_value);
  __Pyx_INCREF(__pyx_v_brod->shape);
  __Pyx_GIVEREF(__pyx_v_brod->shape);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_brod->shape);
  __pyx_r = ((PyObject*)__pyx_t_9);
  __pyx_t_9 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":341
 * 
 * 
 * cdef tuple _broadcast(list args, tuple params, bint use_size):             # <<<<<<<<<<<<<<
 *     cpdef Py_ssize_t i
 *     cpdef ParameterInfo p
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core._broadcast", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_brod);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":375
 * 
 * 
 * cdef list _get_out_args(list out_args, tuple out_types, tuple out_shape,             # <<<<<<<<<<<<<<
 *                         str casting):
 *     if not out_args:
 */

static PyObject *__pyx_f_4cupy_4core_4core__get_out_args(PyObject *__pyx_v_out_args, PyObject *__pyx_v_out_types, PyObject *__pyx_v_out_shape, PyObject *__pyx_v_casting) {
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_out_type = NULL;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_v_t = NULL;
  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 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  __Pyx_RefNannySetupContext("_get_out_args", 0);

  /* "cupy/core/elementwise.pxi":377
 * cdef list _get_out_args(list out_args, tuple out_types, tuple out_shape,
 *                         str casting):
 *     if not out_args:             # <<<<<<<<<<<<<<
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 */
  __pyx_t_1 = (__pyx_v_out_args != Py_None)&&(PyList_GET_SIZE(__pyx_v_out_args) != 0);
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":378
 *                         str casting):
 *     if not out_args:
 *         return [ndarray(out_shape, t) for t in out_types]             # <<<<<<<<<<<<<<
 * 
 *     for i, a in enumerate(out_args):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 378, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__pyx_v_out_types == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 378, __pyx_L1_error)
    }
    __pyx_t_4 = __pyx_v_out_types; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    for (;;) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 378, __pyx_L1_error)
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 378, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 378, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_out_shape);
      __Pyx_GIVEREF(__pyx_v_out_shape);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_out_shape);
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_GIVEREF(__pyx_v_t);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_t);
      __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 378, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(1, 378, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":377
 * cdef list _get_out_args(list out_args, tuple out_types, tuple out_shape,
 *                         str casting):
 *     if not out_args:             # <<<<<<<<<<<<<<
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":380
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 *     for i, a in enumerate(out_args):             # <<<<<<<<<<<<<<
 *         if not isinstance(a, ndarray):
 *             raise TypeError(
 */
  __pyx_t_5 = 0;
  __pyx_t_3 = __pyx_v_out_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0;
  for (;;) {
    if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 380, __pyx_L1_error)
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 380, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_v_i = __pyx_t_5;
    __pyx_t_5 = (__pyx_t_5 + 1);

    /* "cupy/core/elementwise.pxi":381
 * 
 *     for i, a in enumerate(out_args):
 *         if not isinstance(a, ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 */
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "cupy/core/elementwise.pxi":382
 *     for i, a in enumerate(out_args):
 *         if not isinstance(a, ndarray):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'Output arguments type must be cupy.ndarray')
 *         if a.shape != out_shape:
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__62, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 382, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(1, 382, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":381
 * 
 *     for i, a in enumerate(out_args):
 *         if not isinstance(a, ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 */
    }

    /* "cupy/core/elementwise.pxi":384
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 *         if a.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Out shape is mismatched')
 *         out_type = out_types[i]
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 384, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = PyObject_RichCompare(__pyx_t_4, __pyx_v_out_shape, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 384, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 384, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_t_1)) {

      /* "cupy/core/elementwise.pxi":385
 *                 'Output arguments type must be cupy.ndarray')
 *         if a.shape != out_shape:
 *             raise ValueError('Out shape is mismatched')             # <<<<<<<<<<<<<<
 *         out_type = out_types[i]
 *         if not numpy.can_cast(out_type, a.dtype, casting=casting):
 */
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 385, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __PYX_ERR(1, 385, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":384
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 *         if a.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Out shape is mismatched')
 *         out_type = out_types[i]
 */
    }

    /* "cupy/core/elementwise.pxi":386
 *         if a.shape != out_shape:
 *             raise ValueError('Out shape is mismatched')
 *         out_type = out_types[i]             # <<<<<<<<<<<<<<
 *         if not numpy.can_cast(out_type, a.dtype, casting=casting):
 *             msg = 'output (typecode \'{}\') could not be coerced to ' \
 */
    if (unlikely(__pyx_v_out_types == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 386, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v_out_types, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 386, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_XDECREF_SET(__pyx_v_out_type, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":387
 *             raise ValueError('Out shape is mismatched')
 *         out_type = out_types[i]
 *         if not numpy.can_cast(out_type, a.dtype, casting=casting):             # <<<<<<<<<<<<<<
 *             msg = 'output (typecode \'{}\') could not be coerced to ' \
 *                   'provided output parameter (typecode \'{}\') according to ' \
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_can_cast); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_out_type);
    __Pyx_GIVEREF(__pyx_v_out_type);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_out_type);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_casting, __pyx_v_casting) < 0) __PYX_ERR(1, 387, __pyx_L1_error)
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 387, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_2 = ((!__pyx_t_1) != 0);
    if (unlikely(__pyx_t_2)) {

      /* "cupy/core/elementwise.pxi":390
 *             msg = 'output (typecode \'{}\') could not be coerced to ' \
 *                   'provided output parameter (typecode \'{}\') according to ' \
 *                   'the casting rule "{}"'.format(             # <<<<<<<<<<<<<<
 *                       get_dtype(out_type).char,
 *                       a.dtype.char,
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_output_typecode_could_not_be_coe, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 390, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);

      /* "cupy/core/elementwise.pxi":391
 *                   'provided output parameter (typecode \'{}\') according to ' \
 *                   'the casting rule "{}"'.format(
 *                       get_dtype(out_type).char,             # <<<<<<<<<<<<<<
 *                       a.dtype.char,
 *                       casting)
 */
      __pyx_t_6 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_out_type, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 391, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_char); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 391, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/elementwise.pxi":392
 *                   'the casting rule "{}"'.format(
 *                       get_dtype(out_type).char,
 *                       a.dtype.char,             # <<<<<<<<<<<<<<
 *                       casting)
 *             raise TypeError(msg)
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 392, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_char); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 392, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/elementwise.pxi":393
 *                       get_dtype(out_type).char,
 *                       a.dtype.char,
 *                       casting)             # <<<<<<<<<<<<<<
 *             raise TypeError(msg)
 *     return out_args
 */
      __pyx_t_6 = NULL;
      __pyx_t_11 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_11 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_4, __pyx_t_10, __pyx_v_casting};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 390, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_4, __pyx_t_10, __pyx_v_casting};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 390, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 390, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        if (__pyx_t_6) {
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6); __pyx_t_6 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_10);
        __Pyx_INCREF(__pyx_v_casting);
        __Pyx_GIVEREF(__pyx_v_casting);
        PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_v_casting);
        __pyx_t_4 = 0;
        __pyx_t_10 = 0;
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 390, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_msg = __pyx_t_9;
      __pyx_t_9 = 0;

      /* "cupy/core/elementwise.pxi":394
 *                       a.dtype.char,
 *                       casting)
 *             raise TypeError(msg)             # <<<<<<<<<<<<<<
 *     return out_args
 * 
 */
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_v_msg); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 394, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(1, 394, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":387
 *             raise ValueError('Out shape is mismatched')
 *         out_type = out_types[i]
 *         if not numpy.can_cast(out_type, a.dtype, casting=casting):             # <<<<<<<<<<<<<<
 *             msg = 'output (typecode \'{}\') could not be coerced to ' \
 *                   'provided output parameter (typecode \'{}\') according to ' \
 */
    }

    /* "cupy/core/elementwise.pxi":380
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 *     for i, a in enumerate(out_args):             # <<<<<<<<<<<<<<
 *         if not isinstance(a, ndarray):
 *             raise TypeError(
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":395
 *                       casting)
 *             raise TypeError(msg)
 *     return out_args             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_out_args);
  __pyx_r = __pyx_v_out_args;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":375
 * 
 * 
 * cdef list _get_out_args(list out_args, tuple out_types, tuple out_shape,             # <<<<<<<<<<<<<<
 *                         str casting):
 *     if not out_args:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core._get_out_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_out_type);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":398
 * 
 * 
 * cdef list _get_out_args_with_params(             # <<<<<<<<<<<<<<
 *         list out_args, tuple out_types, tuple out_shape, tuple out_params,
 *         bint is_size_specified=False):
 */

static PyObject *__pyx_f_4cupy_4core_4core__get_out_args_with_params(PyObject *__pyx_v_out_args, PyObject *__pyx_v_out_types, PyObject *__pyx_v_out_shape, PyObject *__pyx_v_out_params, struct __pyx_opt_args_4cupy_4core_4core__get_out_args_with_params *__pyx_optional_args) {

  /* "cupy/core/elementwise.pxi":400
 * cdef list _get_out_args_with_params(
 *         list out_args, tuple out_types, tuple out_shape, tuple out_params,
 *         bint is_size_specified=False):             # <<<<<<<<<<<<<<
 *     cdef ParameterInfo p
 *     if not out_args:
 */
  int __pyx_v_is_size_specified = ((int)0);
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_p = 0;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  __Pyx_RefNannySetupContext("_get_out_args_with_params", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_is_size_specified = __pyx_optional_args->is_size_specified;
    }
  }

  /* "cupy/core/elementwise.pxi":402
 *         bint is_size_specified=False):
 *     cdef ParameterInfo p
 *     if not out_args:             # <<<<<<<<<<<<<<
 *         for p in out_params:
 *             if p.raw and is_size_specified is False:
 */
  __pyx_t_1 = (__pyx_v_out_args != Py_None)&&(PyList_GET_SIZE(__pyx_v_out_args) != 0);
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":403
 *     cdef ParameterInfo p
 *     if not out_args:
 *         for p in out_params:             # <<<<<<<<<<<<<<
 *             if p.raw and is_size_specified is False:
 *                 raise ValueError('Output array size is Undecided')
 */
    if (unlikely(__pyx_v_out_params == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 403, __pyx_L1_error)
    }
    __pyx_t_3 = __pyx_v_out_params; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= 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_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 403, __pyx_L1_error)
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ParameterInfo))))) __PYX_ERR(1, 403, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_p, ((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_t_5));
      __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":404
 *     if not out_args:
 *         for p in out_params:
 *             if p.raw and is_size_specified is False:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Output array size is Undecided')
 *         return [ndarray(out_shape, t) for t in out_types]
 */
      __pyx_t_1 = (__pyx_v_p->raw != 0);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_1 = ((__pyx_v_is_size_specified == 0) != 0);
      __pyx_t_2 = __pyx_t_1;
      __pyx_L7_bool_binop_done:;
      if (unlikely(__pyx_t_2)) {

        /* "cupy/core/elementwise.pxi":405
 *         for p in out_params:
 *             if p.raw and is_size_specified is False:
 *                 raise ValueError('Output array size is Undecided')             # <<<<<<<<<<<<<<
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 */
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 405, __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, 405, __pyx_L1_error)

        /* "cupy/core/elementwise.pxi":404
 *     if not out_args:
 *         for p in out_params:
 *             if p.raw and is_size_specified is False:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Output array size is Undecided')
 *         return [ndarray(out_shape, t) for t in out_types]
 */
      }

      /* "cupy/core/elementwise.pxi":403
 *     cdef ParameterInfo p
 *     if not out_args:
 *         for p in out_params:             # <<<<<<<<<<<<<<
 *             if p.raw and is_size_specified is False:
 *                 raise ValueError('Output array size is Undecided')
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":406
 *             if p.raw and is_size_specified is False:
 *                 raise ValueError('Output array size is Undecided')
 *         return [ndarray(out_shape, t) for t in out_types]             # <<<<<<<<<<<<<<
 * 
 *     for i in range(len(out_params)):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 406, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__pyx_v_out_types == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 406, __pyx_L1_error)
    }
    __pyx_t_5 = __pyx_v_out_types; __Pyx_INCREF(__pyx_t_5); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 406, __pyx_L1_error)
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 406, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 406, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_out_shape);
      __Pyx_GIVEREF(__pyx_v_out_shape);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_out_shape);
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_GIVEREF(__pyx_v_t);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_t);
      __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 406, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(1, 406, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":402
 *         bint is_size_specified=False):
 *     cdef ParameterInfo p
 *     if not out_args:             # <<<<<<<<<<<<<<
 *         for p in out_params:
 *             if p.raw and is_size_specified is False:
 */
  }

  /* "cupy/core/elementwise.pxi":408
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 *     for i in range(len(out_params)):             # <<<<<<<<<<<<<<
 *         a = out_args[i]
 *         p = out_params[i]
 */
  if (unlikely(__pyx_v_out_params == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 408, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v_out_params); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 408, __pyx_L1_error)
  __pyx_t_8 = __pyx_t_4;
  for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
    __pyx_v_i = __pyx_t_9;

    /* "cupy/core/elementwise.pxi":409
 * 
 *     for i in range(len(out_params)):
 *         a = out_args[i]             # <<<<<<<<<<<<<<
 *         p = out_params[i]
 *         if not isinstance(a, ndarray):
 */
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 409, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_out_args, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":410
 *     for i in range(len(out_params)):
 *         a = out_args[i]
 *         p = out_params[i]             # <<<<<<<<<<<<<<
 *         if not isinstance(a, ndarray):
 *             raise TypeError(
 */
    if (unlikely(__pyx_v_out_params == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 410, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_out_params, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 410, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ParameterInfo))))) __PYX_ERR(1, 410, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_p, ((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":411
 *         a = out_args[i]
 *         p = out_params[i]
 *         if not isinstance(a, ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 */
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "cupy/core/elementwise.pxi":412
 *         p = out_params[i]
 *         if not isinstance(a, ndarray):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'Output arguments type must be cupy.ndarray')
 *         if not p.raw and a.shape != out_shape:
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 412, __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, 412, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":411
 *         a = out_args[i]
 *         p = out_params[i]
 *         if not isinstance(a, ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 */
    }

    /* "cupy/core/elementwise.pxi":414
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 *         if not p.raw and a.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Out shape is mismatched')
 *     return out_args
 */
    __pyx_t_2 = ((!(__pyx_v_p->raw != 0)) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L15_bool_binop_done;
    }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_v_out_shape, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 414, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 414, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_1 = __pyx_t_2;
    __pyx_L15_bool_binop_done:;
    if (unlikely(__pyx_t_1)) {

      /* "cupy/core/elementwise.pxi":415
 *                 'Output arguments type must be cupy.ndarray')
 *         if not p.raw and a.shape != out_shape:
 *             raise ValueError('Out shape is mismatched')             # <<<<<<<<<<<<<<
 *     return out_args
 * 
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__66, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 415, __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, 415, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":414
 *             raise TypeError(
 *                 'Output arguments type must be cupy.ndarray')
 *         if not p.raw and a.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Out shape is mismatched')
 *     return out_args
 */
    }
  }

  /* "cupy/core/elementwise.pxi":416
 *         if not p.raw and a.shape != out_shape:
 *             raise ValueError('Out shape is mismatched')
 *     return out_args             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_out_args);
  __pyx_r = __pyx_v_out_args;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":398
 * 
 * 
 * cdef list _get_out_args_with_params(             # <<<<<<<<<<<<<<
 *         list out_args, tuple out_types, tuple out_shape, tuple out_params,
 *         bint is_size_specified=False):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core._get_out_args_with_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":420
 * 
 * @util.memoize(for_each_device=True)
 * def _get_elementwise_kernel(args_info, types, params, operation, name,             # <<<<<<<<<<<<<<
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_27_get_elementwise_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_26_get_elementwise_kernel[] = "_get_elementwise_kernel(args_info, types, params, operation, name, preamble, kwargs)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_27_get_elementwise_kernel = {"_get_elementwise_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_27_get_elementwise_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_26_get_elementwise_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_27_get_elementwise_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args_info = 0;
  PyObject *__pyx_v_types = 0;
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_operation = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_elementwise_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_args_info,&__pyx_n_s_types,&__pyx_n_s_params,&__pyx_n_s_operation,&__pyx_n_s_name,&__pyx_n_s_preamble,&__pyx_n_s_kwargs,0};
    PyObject* values[7] = {0,0,0,0,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  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_args_info)) != 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_types)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_elementwise_kernel", 1, 7, 7, 1); __PYX_ERR(1, 420, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_elementwise_kernel", 1, 7, 7, 2); __PYX_ERR(1, 420, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_operation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_elementwise_kernel", 1, 7, 7, 3); __PYX_ERR(1, 420, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_elementwise_kernel", 1, 7, 7, 4); __PYX_ERR(1, 420, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_preamble)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_elementwise_kernel", 1, 7, 7, 5); __PYX_ERR(1, 420, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_elementwise_kernel", 1, 7, 7, 6); __PYX_ERR(1, 420, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_elementwise_kernel") < 0)) __PYX_ERR(1, 420, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
    }
    __pyx_v_args_info = values[0];
    __pyx_v_types = values[1];
    __pyx_v_params = values[2];
    __pyx_v_operation = values[3];
    __pyx_v_name = values[4];
    __pyx_v_preamble = values[5];
    __pyx_v_kwargs = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_elementwise_kernel", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 420, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_elementwise_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_26_get_elementwise_kernel(__pyx_self, __pyx_v_args_info, __pyx_v_types, __pyx_v_params, __pyx_v_operation, __pyx_v_name, __pyx_v_preamble, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4cupy_4core_4core_23_get_elementwise_kernel_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "cupy/core/elementwise.pxi":424
 *     kernel_params = _get_kernel_params(params, args_info)
 *     types_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k) for k, v in types)             # <<<<<<<<<<<<<<
 *     preamble = types_preamble + '\n' + preamble
 * 
 */

static PyObject *__pyx_pf_4cupy_4core_4core_23_get_elementwise_kernel_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_1_genexpr(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(1, 424, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4cupy_4core_4core_23_get_elementwise_kernel_2generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_get_elementwise_kernel_locals_g, __pyx_n_s_cupy_core_core); if (unlikely(!gen)) __PYX_ERR(1, 424, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.core.core._get_elementwise_kernel.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_4cupy_4core_4core_23_get_elementwise_kernel_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L8_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 424, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types)) { __Pyx_RaiseClosureNameError("types"); __PYX_ERR(1, 424, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_types; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 424, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 424, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 424, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 424, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 424, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 424, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      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, 424, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 424, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 424, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 424, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(1, 424, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(1, 424, __pyx_L1_error)
      __pyx_L7_unpacking_done:;
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_k);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_k, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_cur_scope->__pyx_v_v, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_k);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_cur_scope->__pyx_v_k);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_typedef_s_s, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L8_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 424, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  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_7);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":420
 * 
 * @util.memoize(for_each_device=True)
 * def _get_elementwise_kernel(args_info, types, params, operation, name,             # <<<<<<<<<<<<<<
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)
 */

static PyObject *__pyx_pf_4cupy_4core_4core_26_get_elementwise_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args_info, PyObject *__pyx_v_types, PyObject *__pyx_v_params, PyObject *__pyx_v_operation, PyObject *__pyx_v_name, PyObject *__pyx_v_preamble, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *__pyx_cur_scope;
  PyObject *__pyx_v_kernel_params = NULL;
  PyObject *__pyx_v_types_preamble = NULL;
  PyObject *__pyx_v_op = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_fmt = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("_get_elementwise_kernel", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(1, 420, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_types = __pyx_v_types;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_types);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_types);
  __Pyx_INCREF(__pyx_v_operation);
  __Pyx_INCREF(__pyx_v_preamble);

  /* "cupy/core/elementwise.pxi":422
 * def _get_elementwise_kernel(args_info, types, params, operation, name,
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)             # <<<<<<<<<<<<<<
 *     types_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k) for k, v in types)
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_params))||((__pyx_v_params) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_params)->tp_name), 0))) __PYX_ERR(1, 422, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_args_info))||((__pyx_v_args_info) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args_info)->tp_name), 0))) __PYX_ERR(1, 422, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_kernel_params(((PyObject*)__pyx_v_params), ((PyObject*)__pyx_v_args_info), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_kernel_params = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":424
 *     kernel_params = _get_kernel_params(params, args_info)
 *     types_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k) for k, v in types)             # <<<<<<<<<<<<<<
 *     preamble = types_preamble + '\n' + preamble
 * 
 */
  __pyx_t_1 = __pyx_pf_4cupy_4core_4core_23_get_elementwise_kernel_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":423
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)
 *     types_preamble = '\n'.join(             # <<<<<<<<<<<<<<
 *         'typedef %s %s;' % (_get_typename(v), k) for k, v in types)
 *     preamble = types_preamble + '\n' + preamble
 */
  __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__53, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_types_preamble = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":425
 *     types_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k) for k, v in types)
 *     preamble = types_preamble + '\n' + preamble             # <<<<<<<<<<<<<<
 * 
 *     op = []
 */
  __pyx_t_2 = PyNumber_Add(__pyx_v_types_preamble, __pyx_kp_s__53); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Add(__pyx_t_2, __pyx_v_preamble); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_preamble, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":427
 *     preamble = types_preamble + '\n' + preamble
 * 
 *     op = []             # <<<<<<<<<<<<<<
 *     for p, a in zip(params, args_info):
 *         if not p.raw and a[0] == ndarray:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":428
 * 
 *     op = []
 *     for p, a in zip(params, args_info):             # <<<<<<<<<<<<<<
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_params);
  __Pyx_GIVEREF(__pyx_v_params);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_params);
  __Pyx_INCREF(__pyx_v_args_info);
  __Pyx_GIVEREF(__pyx_v_args_info);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_args_info);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 428, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 428, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 428, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 428, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 428, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 428, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 428, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      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, 428, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 428, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 428, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 428, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(1, 428, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(1, 428, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":429
 *     op = []
 *     for p, a in zip(params, args_info):
 *         if not p.raw and a[0] == ndarray:             # <<<<<<<<<<<<<<
 *             if p.is_const:
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_raw_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 429, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(1, 429, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_11 = ((!__pyx_t_10) != 0);
    if (__pyx_t_11) {
    } else {
      __pyx_t_9 = __pyx_t_11;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 429, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 429, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(1, 429, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_9 = __pyx_t_11;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_9) {

      /* "cupy/core/elementwise.pxi":430
 *     for p, a in zip(params, args_info):
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:             # <<<<<<<<<<<<<<
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 *             else:
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_is_const); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 430, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(1, 430, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__pyx_t_9) {

        /* "cupy/core/elementwise.pxi":431
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'             # <<<<<<<<<<<<<<
 *             else:
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 */
        __Pyx_INCREF(__pyx_kp_s_t_n__raw__n__ind_get);
        __Pyx_XDECREF_SET(__pyx_v_fmt, __pyx_kp_s_t_n__raw__n__ind_get);

        /* "cupy/core/elementwise.pxi":430
 *     for p, a in zip(params, args_info):
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:             # <<<<<<<<<<<<<<
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 *             else:
 */
        goto __pyx_L10;
      }

      /* "cupy/core/elementwise.pxi":433
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 *             else:
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'             # <<<<<<<<<<<<<<
 *             op.append(fmt.format(t=p.ctype, n=p.name))
 *     op.append(operation)
 */
      /*else*/ {
        __Pyx_INCREF(__pyx_kp_s_t_n__raw__n__ind_get);
        __Pyx_XDECREF_SET(__pyx_v_fmt, __pyx_kp_s_t_n__raw__n__ind_get);
      }
      __pyx_L10:;

      /* "cupy/core/elementwise.pxi":434
 *             else:
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 *             op.append(fmt.format(t=p.ctype, n=p.name))             # <<<<<<<<<<<<<<
 *     op.append(operation)
 *     operation = '\n'.join(op)
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_fmt, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 434, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 434, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 434, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_t, __pyx_t_5) < 0) __PYX_ERR(1, 434, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 434, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_n, __pyx_t_5) < 0) __PYX_ERR(1, 434, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 434, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_op, __pyx_t_5); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(1, 434, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":429
 *     op = []
 *     for p, a in zip(params, args_info):
 *         if not p.raw and a[0] == ndarray:             # <<<<<<<<<<<<<<
 *             if p.is_const:
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 */
    }

    /* "cupy/core/elementwise.pxi":428
 * 
 *     op = []
 *     for p, a in zip(params, args_info):             # <<<<<<<<<<<<<<
 *         if not p.raw and a[0] == ndarray:
 *             if p.is_const:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":435
 *                 fmt = '{t} &{n} = _raw_{n}[_ind.get()];'
 *             op.append(fmt.format(t=p.ctype, n=p.name))
 *     op.append(operation)             # <<<<<<<<<<<<<<
 *     operation = '\n'.join(op)
 *     return _get_simple_elementwise_kernel(
 */
  __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_op, __pyx_v_operation); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(1, 435, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":436
 *             op.append(fmt.format(t=p.ctype, n=p.name))
 *     op.append(operation)
 *     operation = '\n'.join(op)             # <<<<<<<<<<<<<<
 *     return _get_simple_elementwise_kernel(
 *         kernel_params, operation, name,
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__53, __pyx_v_op); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 436, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_operation, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":437
 *     op.append(operation)
 *     operation = '\n'.join(op)
 *     return _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         kernel_params, operation, name,
 *         preamble, **dict(kwargs))
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_simple_elementwise_kernel); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 437, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":439
 *     return _get_simple_elementwise_kernel(
 *         kernel_params, operation, name,
 *         preamble, **dict(kwargs))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 437, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_kernel_params);
  __Pyx_GIVEREF(__pyx_v_kernel_params);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_kernel_params);
  __Pyx_INCREF(__pyx_v_operation);
  __Pyx_GIVEREF(__pyx_v_operation);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_operation);
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_name);
  __Pyx_INCREF(__pyx_v_preamble);
  __Pyx_GIVEREF(__pyx_v_preamble);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_preamble);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyDict_Type)), __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/elementwise.pxi":437
 *     op.append(operation)
 *     operation = '\n'.join(op)
 *     return _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         kernel_params, operation, name,
 *         preamble, **dict(kwargs))
 */
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 437, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":420
 * 
 * @util.memoize(for_each_device=True)
 * def _get_elementwise_kernel(args_info, types, params, operation, name,             # <<<<<<<<<<<<<<
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core._get_elementwise_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_kernel_params);
  __Pyx_XDECREF(__pyx_v_types_preamble);
  __Pyx_XDECREF(__pyx_v_op);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_fmt);
  __Pyx_XDECREF(__pyx_v_operation);
  __Pyx_XDECREF(__pyx_v_preamble);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":491
 *         readonly object kwargs
 * 
 *     def __init__(self, in_params, out_params, operation,             # <<<<<<<<<<<<<<
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         if not compiler.is_valid_kernel_name(name):
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_in_params = 0;
  PyObject *__pyx_v_out_params = 0;
  PyObject *__pyx_v_operation = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_reduce_dims = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
  __Pyx_GOTREF(__pyx_v_kwargs);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_params,&__pyx_n_s_out_params,&__pyx_n_s_operation,&__pyx_n_s_name,&__pyx_n_s_reduce_dims,&__pyx_n_s_preamble,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[3] = ((PyObject *)__pyx_n_s_kernel);

    /* "cupy/core/elementwise.pxi":492
 * 
 *     def __init__(self, in_params, out_params, operation,
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):             # <<<<<<<<<<<<<<
 *         if not compiler.is_valid_kernel_name(name):
 *             raise ValueError(
 */
    values[4] = ((PyObject *)Py_True);
    values[5] = ((PyObject *)__pyx_kp_s__6);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_in_params)) != 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_out_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 6, 1); __PYX_ERR(1, 491, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_operation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 6, 2); __PYX_ERR(1, 491, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name);
          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_reduce_dims);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_preamble);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "__init__") < 0)) __PYX_ERR(1, 491, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_in_params = values[0];
    __pyx_v_out_params = values[1];
    __pyx_v_operation = values[2];
    __pyx_v_name = values[3];
    __pyx_v_reduce_dims = values[4];
    __pyx_v_preamble = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 491, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("cupy.core.core.ElementwiseKernel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel___init__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self), __pyx_v_in_params, __pyx_v_out_params, __pyx_v_operation, __pyx_v_name, __pyx_v_reduce_dims, __pyx_v_preamble, __pyx_v_kwargs);

  /* "cupy/core/elementwise.pxi":491
 *         readonly object kwargs
 * 
 *     def __init__(self, in_params, out_params, operation,             # <<<<<<<<<<<<<<
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         if not compiler.is_valid_kernel_name(name):
 */

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_17ElementwiseKernel___init__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self, PyObject *__pyx_v_in_params, PyObject *__pyx_v_out_params, PyObject *__pyx_v_operation, PyObject *__pyx_v_name, PyObject *__pyx_v_reduce_dims, PyObject *__pyx_v_preamble, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_param_rest = NULL;
  PyObject *__pyx_v_names = NULL;
  PyObject *__pyx_v_p = NULL;
  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_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/elementwise.pxi":493
 *     def __init__(self, in_params, out_params, operation,
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         if not compiler.is_valid_kernel_name(name):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'Invalid kernel name: "%s"' % name)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_compiler); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_valid_kernel_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __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);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_name};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_name};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 493, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(__pyx_v_name);
      __Pyx_GIVEREF(__pyx_v_name);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_name);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(1, 493, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = ((!__pyx_t_5) != 0);
  if (unlikely(__pyx_t_6)) {

    /* "cupy/core/elementwise.pxi":495
 *         if not compiler.is_valid_kernel_name(name):
 *             raise ValueError(
 *                 'Invalid kernel name: "%s"' % name)             # <<<<<<<<<<<<<<
 * 
 *         self.in_params = _get_param_info(in_params, True)
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_kernel_name_s, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 495, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "cupy/core/elementwise.pxi":494
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         if not compiler.is_valid_kernel_name(name):
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'Invalid kernel name: "%s"' % name)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 494, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 494, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":493
 *     def __init__(self, in_params, out_params, operation,
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         if not compiler.is_valid_kernel_name(name):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'Invalid kernel name: "%s"' % name)
 */
  }

  /* "cupy/core/elementwise.pxi":497
 *                 'Invalid kernel name: "%s"' % name)
 * 
 *         self.in_params = _get_param_info(in_params, True)             # <<<<<<<<<<<<<<
 *         self.out_params = _get_param_info(out_params, False)
 *         self.nin = len(self.in_params)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 497, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_in_params, Py_True};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 497, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_in_params, Py_True};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 497, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  {
    __pyx_t_2 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v_in_params);
    __Pyx_GIVEREF(__pyx_v_in_params);
    PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_7, __pyx_v_in_params);
    __Pyx_INCREF(Py_True);
    __Pyx_GIVEREF(Py_True);
    PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_7, Py_True);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 497, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->in_params);
  __Pyx_DECREF(__pyx_v_self->in_params);
  __pyx_v_self->in_params = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":498
 * 
 *         self.in_params = _get_param_info(in_params, True)
 *         self.out_params = _get_param_info(out_params, False)             # <<<<<<<<<<<<<<
 *         self.nin = len(self.in_params)
 *         self.nout = len(self.out_params)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 498, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_out_params, Py_False};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 498, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_out_params, Py_False};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 498, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  {
    __pyx_t_4 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_out_params);
    __Pyx_GIVEREF(__pyx_v_out_params);
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, __pyx_v_out_params);
    __Pyx_INCREF(Py_False);
    __Pyx_GIVEREF(Py_False);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, Py_False);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 498, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->out_params);
  __Pyx_DECREF(__pyx_v_self->out_params);
  __pyx_v_self->out_params = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":499
 *         self.in_params = _get_param_info(in_params, True)
 *         self.out_params = _get_param_info(out_params, False)
 *         self.nin = len(self.in_params)             # <<<<<<<<<<<<<<
 *         self.nout = len(self.out_params)
 *         self.nargs = self.nin + self.nout
 */
  __pyx_t_3 = __pyx_v_self->in_params;
  __Pyx_INCREF(__pyx_t_3);
  if (unlikely(__pyx_t_3 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 499, __pyx_L1_error)
  }
  __pyx_t_8 = PyTuple_GET_SIZE(__pyx_t_3); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(1, 499, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_self->nin = __pyx_t_8;

  /* "cupy/core/elementwise.pxi":500
 *         self.out_params = _get_param_info(out_params, False)
 *         self.nin = len(self.in_params)
 *         self.nout = len(self.out_params)             # <<<<<<<<<<<<<<
 *         self.nargs = self.nin + self.nout
 *         param_rest = _get_param_info('CIndexer _ind', False)
 */
  __pyx_t_3 = __pyx_v_self->out_params;
  __Pyx_INCREF(__pyx_t_3);
  if (unlikely(__pyx_t_3 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 500, __pyx_L1_error)
  }
  __pyx_t_8 = PyTuple_GET_SIZE(__pyx_t_3); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(1, 500, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_self->nout = __pyx_t_8;

  /* "cupy/core/elementwise.pxi":501
 *         self.nin = len(self.in_params)
 *         self.nout = len(self.out_params)
 *         self.nargs = self.nin + self.nout             # <<<<<<<<<<<<<<
 *         param_rest = _get_param_info('CIndexer _ind', False)
 *         self.params = self.in_params + self.out_params + param_rest
 */
  __pyx_v_self->nargs = (__pyx_v_self->nin + __pyx_v_self->nout);

  /* "cupy/core/elementwise.pxi":502
 *         self.nout = len(self.out_params)
 *         self.nargs = self.nin + self.nout
 *         param_rest = _get_param_info('CIndexer _ind', False)             # <<<<<<<<<<<<<<
 *         self.params = self.in_params + self.out_params + param_rest
 *         self.operation = operation
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 502, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__67, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 502, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_param_rest = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":503
 *         self.nargs = self.nin + self.nout
 *         param_rest = _get_param_info('CIndexer _ind', False)
 *         self.params = self.in_params + self.out_params + param_rest             # <<<<<<<<<<<<<<
 *         self.operation = operation
 *         self.name = name
 */
  __pyx_t_1 = PyNumber_Add(__pyx_v_self->in_params, __pyx_v_self->out_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 503, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_v_param_rest); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 503, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 503, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->params);
  __Pyx_DECREF(__pyx_v_self->params);
  __pyx_v_self->params = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":504
 *         param_rest = _get_param_info('CIndexer _ind', False)
 *         self.params = self.in_params + self.out_params + param_rest
 *         self.operation = operation             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.reduce_dims = reduce_dims
 */
  if (!(likely(PyString_CheckExact(__pyx_v_operation))||((__pyx_v_operation) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_operation)->tp_name), 0))) __PYX_ERR(1, 504, __pyx_L1_error)
  __pyx_t_3 = __pyx_v_operation;
  __Pyx_INCREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->operation);
  __Pyx_DECREF(__pyx_v_self->operation);
  __pyx_v_self->operation = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":505
 *         self.params = self.in_params + self.out_params + param_rest
 *         self.operation = operation
 *         self.name = name             # <<<<<<<<<<<<<<
 *         self.reduce_dims = reduce_dims
 *         self.preamble = preamble
 */
  if (!(likely(PyString_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(1, 505, __pyx_L1_error)
  __pyx_t_3 = __pyx_v_name;
  __Pyx_INCREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":506
 *         self.operation = operation
 *         self.name = name
 *         self.reduce_dims = reduce_dims             # <<<<<<<<<<<<<<
 *         self.preamble = preamble
 *         self.kwargs = frozenset(kwargs.items())
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_reduce_dims); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 506, __pyx_L1_error)
  __pyx_v_self->reduce_dims = __pyx_t_6;

  /* "cupy/core/elementwise.pxi":507
 *         self.name = name
 *         self.reduce_dims = reduce_dims
 *         self.preamble = preamble             # <<<<<<<<<<<<<<
 *         self.kwargs = frozenset(kwargs.items())
 *         names = [p.name for p in self.in_params + self.out_params]
 */
  if (!(likely(PyString_CheckExact(__pyx_v_preamble))||((__pyx_v_preamble) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_preamble)->tp_name), 0))) __PYX_ERR(1, 507, __pyx_L1_error)
  __pyx_t_3 = __pyx_v_preamble;
  __Pyx_INCREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->preamble);
  __Pyx_DECREF(__pyx_v_self->preamble);
  __pyx_v_self->preamble = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":508
 *         self.reduce_dims = reduce_dims
 *         self.preamble = preamble
 *         self.kwargs = frozenset(kwargs.items())             # <<<<<<<<<<<<<<
 *         names = [p.name for p in self.in_params + self.out_params]
 *         if 'i' in names:
 */
  __pyx_t_3 = __Pyx_PyDict_Items(__pyx_v_kwargs); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyFrozenSet_New(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->kwargs);
  __Pyx_DECREF(__pyx_v_self->kwargs);
  __pyx_v_self->kwargs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":509
 *         self.preamble = preamble
 *         self.kwargs = frozenset(kwargs.items())
 *         names = [p.name for p in self.in_params + self.out_params]             # <<<<<<<<<<<<<<
 *         if 'i' in names:
 *             raise ValueError("Can not use 'i' as a parameter name")
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyNumber_Add(__pyx_v_self->in_params, __pyx_v_self->out_params); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 509, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 509, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 509, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(1, 509, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_names = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":510
 *         self.kwargs = frozenset(kwargs.items())
 *         names = [p.name for p in self.in_params + self.out_params]
 *         if 'i' in names:             # <<<<<<<<<<<<<<
 *             raise ValueError("Can not use 'i' as a parameter name")
 * 
 */
  __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_n_s_i, __pyx_v_names, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 510, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_6 != 0);
  if (unlikely(__pyx_t_5)) {

    /* "cupy/core/elementwise.pxi":511
 *         names = [p.name for p in self.in_params + self.out_params]
 *         if 'i' in names:
 *             raise ValueError("Can not use 'i' as a parameter name")             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, *args, **kwargs):
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 511, __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, 511, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":510
 *         self.kwargs = frozenset(kwargs.items())
 *         names = [p.name for p in self.in_params + self.out_params]
 *         if 'i' in names:             # <<<<<<<<<<<<<<
 *             raise ValueError("Can not use 'i' as a parameter name")
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":491
 *         readonly object kwargs
 * 
 *     def __init__(self, in_params, out_params, operation,             # <<<<<<<<<<<<<<
 *                  name='kernel', reduce_dims=True, preamble='', **kwargs):
 *         if not compiler.is_valid_kernel_name(name):
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __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("cupy.core.core.ElementwiseKernel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_param_rest);
  __Pyx_XDECREF(__pyx_v_names);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":513
 *             raise ValueError("Can not use 'i' as a parameter name")
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the elementwise kernel.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_17ElementwiseKernel_2__call__[] = "Compiles and invokes the elementwise kernel.\n\n        The compilation runs only if the kernel is not cached. Note that the\n        kernels with different argument dtypes or dimensions are not\n        compatible. It means that single ElementwiseKernel object may be\n        compiled into multiple kernel binaries.\n\n        Args:\n            args: Arguments of the kernel.\n            size (int): Range size of the indices.  By default, the range size\n                is automatically determined from the result of broadcasting.\n                This parameter must be specified if and only if all ndarrays\n                are `raw` and the range size cannot be determined\n                automatically.\n\n        Returns:\n            Arrays are returned according to the ``out_params`` argument of the\n            ``__init__`` method.\n\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_4cupy_4core_4core_17ElementwiseKernel_2__call__;
#endif
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__call__", 1))) return NULL;
  __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_2__call__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_2__call__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4cupy_4cuda_8function_Function *__pyx_v_kern = 0;
  PyObject *__pyx_v_size = NULL;
  PyObject *__pyx_v_stream = NULL;
  Py_ssize_t __pyx_v_n_args;
  PyObject *__pyx_v_values = NULL;
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_in_args = NULL;
  PyObject *__pyx_v_out_args = NULL;
  PyObject *__pyx_v_in_ndarray_types = NULL;
  PyObject *__pyx_v_out_ndarray_types = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_v_types = NULL;
  int __pyx_v_is_size_specified;
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_v_inout_args = NULL;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_indexer = NULL;
  PyObject *__pyx_v_args_info = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  struct __pyx_opt_args_4cupy_4core_4core__get_out_args_with_params __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  struct __pyx_opt_args_4cupy_4cuda_8function_8Function_linear_launch __pyx_t_17;
  __Pyx_RefNannySetupContext("__call__", 0);
  __Pyx_INCREF(__pyx_v_args);

  /* "cupy/core/elementwise.pxi":537
 *         cdef function.Function kern
 * 
 *         size = kwargs.pop('size', None)             # <<<<<<<<<<<<<<
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_size, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 537, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_size = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":538
 * 
 *         size = kwargs.pop('size', None)
 *         stream = kwargs.pop('stream', None)             # <<<<<<<<<<<<<<
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_stream, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_stream = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":539
 *         size = kwargs.pop('size', None)
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 539, __pyx_L1_error)
  if (unlikely(__pyx_t_2)) {

    /* "cupy/core/elementwise.pxi":540
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)             # <<<<<<<<<<<<<<
 * 
 *         n_args = len(args)
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_arguments_s, __pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 540, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 540, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 540, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":539
 *         size = kwargs.pop('size', None)
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":542
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 *         n_args = len(args)             # <<<<<<<<<<<<<<
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 542, __pyx_L1_error)
  __pyx_v_n_args = __pyx_t_4;

  /* "cupy/core/elementwise.pxi":543
 * 
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 *         args = _preprocess_args(args)
 */
  __pyx_t_5 = ((__pyx_v_n_args != __pyx_v_self->nin) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_v_n_args != __pyx_v_self->nargs) != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L5_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "cupy/core/elementwise.pxi":544
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)             # <<<<<<<<<<<<<<
 *         args = _preprocess_args(args)
 * 
 */
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_number_of_arguments_for_s, __pyx_v_self->name); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 544, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 544, __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, 544, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":543
 * 
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 *         args = _preprocess_args(args)
 */
  }

  /* "cupy/core/elementwise.pxi":545
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 *         args = _preprocess_args(args)             # <<<<<<<<<<<<<<
 * 
 *         values, shape = _broadcast(args, self.params, size is not None)
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_v_args, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 545, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":547
 *         args = _preprocess_args(args)
 * 
 *         values, shape = _broadcast(args, self.params, size is not None)             # <<<<<<<<<<<<<<
 *         in_args = values[:self.nin]
 *         out_args = values[self.nin:]
 */
  if (!(likely(PyList_CheckExact(__pyx_v_args))||((__pyx_v_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_args)->tp_name), 0))) __PYX_ERR(1, 547, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_self->params;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = (__pyx_v_size != Py_None);
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__broadcast(((PyObject*)__pyx_v_args), ((PyObject*)__pyx_t_1), __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 547, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  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, 547, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_6);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 547, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 547, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 547, __pyx_L1_error)
  }
  __pyx_v_values = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_shape = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":548
 * 
 *         values, shape = _broadcast(args, self.params, size is not None)
 *         in_args = values[:self.nin]             # <<<<<<<<<<<<<<
 *         out_args = values[self.nin:]
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_values, 0, __pyx_v_self->nin, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 548, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_in_args = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":549
 *         values, shape = _broadcast(args, self.params, size is not None)
 *         in_args = values[:self.nin]
 *         out_args = values[self.nin:]             # <<<<<<<<<<<<<<
 * 
 *         in_ndarray_types = tuple(
 */
  __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_values, __pyx_v_self->nin, 0, NULL, NULL, NULL, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_out_args = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":552
 * 
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None             # <<<<<<<<<<<<<<
 *              for a in in_args])
 *         out_ndarray_types = tuple([a.dtype.type for a in out_args])
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/elementwise.pxi":553
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])             # <<<<<<<<<<<<<<
 *         out_ndarray_types = tuple([a.dtype.type for a in out_args])
 * 
 */
  if (likely(PyList_CheckExact(__pyx_v_in_args)) || PyTuple_CheckExact(__pyx_v_in_args)) {
    __pyx_t_6 = __pyx_v_in_args; __Pyx_INCREF(__pyx_t_6); __pyx_t_4 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_in_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 553, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 553, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_6))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 553, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 553, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 553, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 553, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_7(__pyx_t_6);
      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(1, 553, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":552
 * 
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None             # <<<<<<<<<<<<<<
 *              for a in in_args])
 *         out_ndarray_types = tuple([a.dtype.type for a in out_args])
 */
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_2 != 0)) {
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 552, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 552, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_1 = __pyx_t_9;
      __pyx_t_9 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_1 = Py_None;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_1))) __PYX_ERR(1, 552, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":553
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])             # <<<<<<<<<<<<<<
 *         out_ndarray_types = tuple([a.dtype.type for a in out_args])
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":551
 *         out_args = values[self.nin:]
 * 
 *         in_ndarray_types = tuple(             # <<<<<<<<<<<<<<
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])
 */
  __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_in_ndarray_types = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":554
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])
 *         out_ndarray_types = tuple([a.dtype.type for a in out_args])             # <<<<<<<<<<<<<<
 * 
 *         in_types, out_types, types = _decide_params_type(
 */
  __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (likely(PyList_CheckExact(__pyx_v_out_args)) || PyTuple_CheckExact(__pyx_v_out_args)) {
    __pyx_t_3 = __pyx_v_out_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_out_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 554, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 554, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 554, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 554, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 554, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_7(__pyx_t_3);
      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(1, 554, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_9))) __PYX_ERR(1, 554, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_AsTuple(((PyObject*)__pyx_t_6)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_out_ndarray_types = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":556
 *         out_ndarray_types = tuple([a.dtype.type for a in out_args])
 * 
 *         in_types, out_types, types = _decide_params_type(             # <<<<<<<<<<<<<<
 *             self.in_params, self.out_params,
 *             in_ndarray_types, out_ndarray_types)
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_decide_params_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "cupy/core/elementwise.pxi":558
 *         in_types, out_types, types = _decide_params_type(
 *             self.in_params, self.out_params,
 *             in_ndarray_types, out_ndarray_types)             # <<<<<<<<<<<<<<
 * 
 *         is_size_specified = False
 */
  __pyx_t_9 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_v_self->in_params, __pyx_v_self->out_params, __pyx_v_in_ndarray_types, __pyx_v_out_ndarray_types};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 556, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_v_self->in_params, __pyx_v_self->out_params, __pyx_v_in_ndarray_types, __pyx_v_out_ndarray_types};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 556, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  {
    __pyx_t_1 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_INCREF(__pyx_v_self->in_params);
    __Pyx_GIVEREF(__pyx_v_self->in_params);
    PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_10, __pyx_v_self->in_params);
    __Pyx_INCREF(__pyx_v_self->out_params);
    __Pyx_GIVEREF(__pyx_v_self->out_params);
    PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_10, __pyx_v_self->out_params);
    __Pyx_INCREF(__pyx_v_in_ndarray_types);
    __Pyx_GIVEREF(__pyx_v_in_ndarray_types);
    PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_10, __pyx_v_in_ndarray_types);
    __Pyx_INCREF(__pyx_v_out_ndarray_types);
    __Pyx_GIVEREF(__pyx_v_out_ndarray_types);
    PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_10, __pyx_v_out_ndarray_types);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(1, 556, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_9 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_9);
    #else
    __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_11 = Py_TYPE(__pyx_t_8)->tp_iternext;
    index = 0; __pyx_t_6 = __pyx_t_11(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L11_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_6);
    index = 1; __pyx_t_1 = __pyx_t_11(__pyx_t_8); if (unlikely(!__pyx_t_1)) goto __pyx_L11_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 2; __pyx_t_9 = __pyx_t_11(__pyx_t_8); if (unlikely(!__pyx_t_9)) goto __pyx_L11_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_9);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_8), 3) < 0) __PYX_ERR(1, 556, __pyx_L1_error)
    __pyx_t_11 = NULL;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L12_unpacking_done;
    __pyx_L11_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_11 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(1, 556, __pyx_L1_error)
    __pyx_L12_unpacking_done:;
  }

  /* "cupy/core/elementwise.pxi":556
 *         out_ndarray_types = tuple([a.dtype.type for a in out_args])
 * 
 *         in_types, out_types, types = _decide_params_type(             # <<<<<<<<<<<<<<
 *             self.in_params, self.out_params,
 *             in_ndarray_types, out_ndarray_types)
 */
  __pyx_v_in_types = __pyx_t_6;
  __pyx_t_6 = 0;
  __pyx_v_out_types = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_types = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":560
 *             in_ndarray_types, out_ndarray_types)
 * 
 *         is_size_specified = False             # <<<<<<<<<<<<<<
 *         if size is not None:
 *             shape = size,
 */
  __pyx_v_is_size_specified = 0;

  /* "cupy/core/elementwise.pxi":561
 * 
 *         is_size_specified = False
 *         if size is not None:             # <<<<<<<<<<<<<<
 *             shape = size,
 *             is_size_specified = True
 */
  __pyx_t_2 = (__pyx_v_size != Py_None);
  __pyx_t_5 = (__pyx_t_2 != 0);
  if (__pyx_t_5) {

    /* "cupy/core/elementwise.pxi":562
 *         is_size_specified = False
 *         if size is not None:
 *             shape = size,             # <<<<<<<<<<<<<<
 *             is_size_specified = True
 * 
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_size);
    __Pyx_GIVEREF(__pyx_v_size);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_size);
    __Pyx_DECREF_SET(__pyx_v_shape, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":563
 *         if size is not None:
 *             shape = size,
 *             is_size_specified = True             # <<<<<<<<<<<<<<
 * 
 *         out_args = _get_out_args_with_params(
 */
    __pyx_v_is_size_specified = 1;

    /* "cupy/core/elementwise.pxi":561
 * 
 *         is_size_specified = False
 *         if size is not None:             # <<<<<<<<<<<<<<
 *             shape = size,
 *             is_size_specified = True
 */
  }

  /* "cupy/core/elementwise.pxi":566
 * 
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, shape, self.out_params, is_size_specified)             # <<<<<<<<<<<<<<
 *         if self.nout == 1:
 *             ret = out_args[0]
 */
  if (!(likely(PyList_CheckExact(__pyx_v_out_args))||((__pyx_v_out_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_out_args)->tp_name), 0))) __PYX_ERR(1, 566, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_out_types))||((__pyx_v_out_types) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_out_types)->tp_name), 0))) __PYX_ERR(1, 566, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_shape))||((__pyx_v_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_shape)->tp_name), 0))) __PYX_ERR(1, 566, __pyx_L1_error)
  __pyx_t_3 = __pyx_v_self->out_params;
  __Pyx_INCREF(__pyx_t_3);

  /* "cupy/core/elementwise.pxi":565
 *             is_size_specified = True
 * 
 *         out_args = _get_out_args_with_params(             # <<<<<<<<<<<<<<
 *             out_args, out_types, shape, self.out_params, is_size_specified)
 *         if self.nout == 1:
 */
  __pyx_t_12.__pyx_n = 1;
  __pyx_t_12.is_size_specified = __pyx_v_is_size_specified;
  __pyx_t_9 = __pyx_f_4cupy_4core_4core__get_out_args_with_params(((PyObject*)__pyx_v_out_args), ((PyObject*)__pyx_v_out_types), ((PyObject*)__pyx_v_shape), ((PyObject*)__pyx_t_3), &__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_out_args, __pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":567
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, shape, self.out_params, is_size_specified)
 *         if self.nout == 1:             # <<<<<<<<<<<<<<
 *             ret = out_args[0]
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_self->nout == 1) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/elementwise.pxi":568
 *             out_args, out_types, shape, self.out_params, is_size_specified)
 *         if self.nout == 1:
 *             ret = out_args[0]             # <<<<<<<<<<<<<<
 *         else:
 *             ret = tuple(out_args)
 */
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 568, __pyx_L1_error)
    }
    __pyx_t_9 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_v_ret = __pyx_t_9;
    __pyx_t_9 = 0;

    /* "cupy/core/elementwise.pxi":567
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, shape, self.out_params, is_size_specified)
 *         if self.nout == 1:             # <<<<<<<<<<<<<<
 *             ret = out_args[0]
 *         else:
 */
    goto __pyx_L14;
  }

  /* "cupy/core/elementwise.pxi":570
 *             ret = out_args[0]
 *         else:
 *             ret = tuple(out_args)             # <<<<<<<<<<<<<<
 * 
 *         if 0 in shape:
 */
  /*else*/ {
    __pyx_t_9 = __Pyx_PySequence_Tuple(__pyx_v_out_args); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 570, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_v_ret = __pyx_t_9;
    __pyx_t_9 = 0;
  }
  __pyx_L14:;

  /* "cupy/core/elementwise.pxi":572
 *             ret = tuple(out_args)
 * 
 *         if 0 in shape:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_int_0, __pyx_v_shape, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(1, 572, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_5 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":573
 * 
 *         if 0 in shape:
 *             return ret             # <<<<<<<<<<<<<<
 * 
 *         inout_args = [x if isinstance(x, ndarray) else in_types[i](x)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_ret);
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":572
 *             ret = tuple(out_args)
 * 
 *         if 0 in shape:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":575
 *             return ret
 * 
 *         inout_args = [x if isinstance(x, ndarray) else in_types[i](x)             # <<<<<<<<<<<<<<
 *                       for i, x in enumerate(in_args)]
 *         inout_args += out_args
 */
  __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_3 = __pyx_int_0;

  /* "cupy/core/elementwise.pxi":576
 * 
 *         inout_args = [x if isinstance(x, ndarray) else in_types[i](x)
 *                       for i, x in enumerate(in_args)]             # <<<<<<<<<<<<<<
 *         inout_args += out_args
 * 
 */
  if (likely(PyList_CheckExact(__pyx_v_in_args)) || PyTuple_CheckExact(__pyx_v_in_args)) {
    __pyx_t_1 = __pyx_v_in_args; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_in_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 576, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 576, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 576, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 576, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 576, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 576, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 576, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 576, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":575
 *             return ret
 * 
 *         inout_args = [x if isinstance(x, ndarray) else in_types[i](x)             # <<<<<<<<<<<<<<
 *                       for i, x in enumerate(in_args)]
 *         inout_args += out_args
 */
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_2 != 0)) {
      __Pyx_INCREF(__pyx_v_x);
      __pyx_t_6 = __pyx_v_x;
    } else {
      __pyx_t_13 = __Pyx_PyObject_GetItem(__pyx_v_in_types, __pyx_v_i); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 575, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
        }
      }
      if (!__pyx_t_14) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_v_x); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 575, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_13)) {
          PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_v_x};
          __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 575, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
          PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_v_x};
          __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 575, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        {
          __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 575, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
          __Pyx_INCREF(__pyx_v_x);
          __Pyx_GIVEREF(__pyx_v_x);
          PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_v_x);
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_15, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 575, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_6 = __pyx_t_8;
      __pyx_t_8 = 0;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_9, (PyObject*)__pyx_t_6))) __PYX_ERR(1, 575, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":576
 * 
 *         inout_args = [x if isinstance(x, ndarray) else in_types[i](x)
 *                       for i, x in enumerate(in_args)]             # <<<<<<<<<<<<<<
 *         inout_args += out_args
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_inout_args = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":577
 *         inout_args = [x if isinstance(x, ndarray) else in_types[i](x)
 *                       for i, x in enumerate(in_args)]
 *         inout_args += out_args             # <<<<<<<<<<<<<<
 * 
 *         if self.reduce_dims:
 */
  __pyx_t_9 = PyNumber_InPlaceAdd(__pyx_v_inout_args, __pyx_v_out_args); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF_SET(__pyx_v_inout_args, __pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/elementwise.pxi":579
 *         inout_args += out_args
 * 
 *         if self.reduce_dims:             # <<<<<<<<<<<<<<
 *             inout_args, shape = _reduce_dims(
 *                 inout_args, self.params, shape)
 */
  __pyx_t_2 = (__pyx_v_self->reduce_dims != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":581
 *         if self.reduce_dims:
 *             inout_args, shape = _reduce_dims(
 *                 inout_args, self.params, shape)             # <<<<<<<<<<<<<<
 *         indexer = Indexer(shape)
 *         inout_args.append(indexer)
 */
    if (!(likely(PyList_CheckExact(__pyx_v_inout_args))||((__pyx_v_inout_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_inout_args)->tp_name), 0))) __PYX_ERR(1, 581, __pyx_L1_error)
    __pyx_t_9 = __pyx_v_self->params;
    __Pyx_INCREF(__pyx_t_9);
    if (!(likely(PyTuple_CheckExact(__pyx_v_shape))||((__pyx_v_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_shape)->tp_name), 0))) __PYX_ERR(1, 581, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":580
 * 
 *         if self.reduce_dims:
 *             inout_args, shape = _reduce_dims(             # <<<<<<<<<<<<<<
 *                 inout_args, self.params, shape)
 *         indexer = Indexer(shape)
 */
    __pyx_t_3 = __pyx_f_4cupy_4core_4core__reduce_dims(((PyObject*)__pyx_v_inout_args), ((PyObject*)__pyx_t_9), ((PyObject*)__pyx_v_shape), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    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, 580, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_1);
      #else
      __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 580, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 580, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 580, __pyx_L1_error)
    }
    __Pyx_DECREF_SET(__pyx_v_inout_args, __pyx_t_9);
    __pyx_t_9 = 0;
    __Pyx_DECREF_SET(__pyx_v_shape, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":579
 *         inout_args += out_args
 * 
 *         if self.reduce_dims:             # <<<<<<<<<<<<<<
 *             inout_args, shape = _reduce_dims(
 *                 inout_args, self.params, shape)
 */
  }

  /* "cupy/core/elementwise.pxi":582
 *             inout_args, shape = _reduce_dims(
 *                 inout_args, self.params, shape)
 *         indexer = Indexer(shape)             # <<<<<<<<<<<<<<
 *         inout_args.append(indexer)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_v_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 582, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":583
 *                 inout_args, self.params, shape)
 *         indexer = Indexer(shape)
 *         inout_args.append(indexer)             # <<<<<<<<<<<<<<
 * 
 *         args_info = _get_args_info(inout_args)
 */
  __pyx_t_16 = __Pyx_PyObject_Append(__pyx_v_inout_args, ((PyObject *)__pyx_v_indexer)); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(1, 583, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":585
 *         inout_args.append(indexer)
 * 
 *         args_info = _get_args_info(inout_args)             # <<<<<<<<<<<<<<
 *         kern = _get_elementwise_kernel(
 *             args_info, types, self.params, self.operation,
 */
  if (!(likely(PyList_CheckExact(__pyx_v_inout_args))||((__pyx_v_inout_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_inout_args)->tp_name), 0))) __PYX_ERR(1, 585, __pyx_L1_error)
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__get_args_info(((PyObject*)__pyx_v_inout_args), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_args_info = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":586
 * 
 *         args_info = _get_args_info(inout_args)
 *         kern = _get_elementwise_kernel(             # <<<<<<<<<<<<<<
 *             args_info, types, self.params, self.operation,
 *             self.name, self.preamble, self.kwargs)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_elementwise_kernel); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 586, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":588
 *         kern = _get_elementwise_kernel(
 *             args_info, types, self.params, self.operation,
 *             self.name, self.preamble, self.kwargs)             # <<<<<<<<<<<<<<
 *         kern.linear_launch(indexer.size, inout_args, shared_mem=0,
 *                            block_max_size=128, stream=stream)
 */
  __pyx_t_9 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_9, __pyx_v_args_info, __pyx_v_types, __pyx_v_self->params, __pyx_v_self->operation, __pyx_v_self->name, __pyx_v_self->preamble, __pyx_v_self->kwargs};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 7+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 586, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_9, __pyx_v_args_info, __pyx_v_types, __pyx_v_self->params, __pyx_v_self->operation, __pyx_v_self->name, __pyx_v_self->preamble, __pyx_v_self->kwargs};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 7+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 586, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(7+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_INCREF(__pyx_v_args_info);
    __Pyx_GIVEREF(__pyx_v_args_info);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_10, __pyx_v_args_info);
    __Pyx_INCREF(__pyx_v_types);
    __Pyx_GIVEREF(__pyx_v_types);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_10, __pyx_v_types);
    __Pyx_INCREF(__pyx_v_self->params);
    __Pyx_GIVEREF(__pyx_v_self->params);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_10, __pyx_v_self->params);
    __Pyx_INCREF(__pyx_v_self->operation);
    __Pyx_GIVEREF(__pyx_v_self->operation);
    PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_10, __pyx_v_self->operation);
    __Pyx_INCREF(__pyx_v_self->name);
    __Pyx_GIVEREF(__pyx_v_self->name);
    PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_10, __pyx_v_self->name);
    __Pyx_INCREF(__pyx_v_self->preamble);
    __Pyx_GIVEREF(__pyx_v_self->preamble);
    PyTuple_SET_ITEM(__pyx_t_6, 5+__pyx_t_10, __pyx_v_self->preamble);
    __Pyx_INCREF(__pyx_v_self->kwargs);
    __Pyx_GIVEREF(__pyx_v_self->kwargs);
    PyTuple_SET_ITEM(__pyx_t_6, 6+__pyx_t_10, __pyx_v_self->kwargs);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":586
 * 
 *         args_info = _get_args_info(inout_args)
 *         kern = _get_elementwise_kernel(             # <<<<<<<<<<<<<<
 *             args_info, types, self.params, self.operation,
 *             self.name, self.preamble, self.kwargs)
 */
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4cuda_8function_Function))))) __PYX_ERR(1, 586, __pyx_L1_error)
  __pyx_v_kern = ((struct __pyx_obj_4cupy_4cuda_8function_Function *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":589
 *             args_info, types, self.params, self.operation,
 *             self.name, self.preamble, self.kwargs)
 *         kern.linear_launch(indexer.size, inout_args, shared_mem=0,             # <<<<<<<<<<<<<<
 *                            block_max_size=128, stream=stream)
 *         return ret
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.shared_mem = 0;
  __pyx_t_17.block_max_size = 0x80;
  __pyx_t_17.stream = __pyx_v_stream;
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Function *)__pyx_v_kern->__pyx_vtab)->linear_launch(__pyx_v_kern, __pyx_v_indexer->size, __pyx_v_inout_args, 0, &__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":591
 *         kern.linear_launch(indexer.size, inout_args, shared_mem=0,
 *                            block_max_size=128, stream=stream)
 *         return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":513
 *             raise ValueError("Can not use 'i' as a parameter name")
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the elementwise kernel.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("cupy.core.core.ElementwiseKernel.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF((PyObject *)__pyx_v_kern);
  __Pyx_XDECREF(__pyx_v_size);
  __Pyx_XDECREF(__pyx_v_stream);
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_in_args);
  __Pyx_XDECREF(__pyx_v_out_args);
  __Pyx_XDECREF(__pyx_v_in_ndarray_types);
  __Pyx_XDECREF(__pyx_v_out_ndarray_types);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_inout_args);
  __Pyx_XDECREF((PyObject *)__pyx_v_indexer);
  __Pyx_XDECREF(__pyx_v_args_info);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":479
 * 
 *     cdef:
 *         readonly tuple in_params             # <<<<<<<<<<<<<<
 *         readonly tuple out_params
 *         readonly Py_ssize_t nin
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_9in_params_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_9in_params_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_9in_params___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_9in_params___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->in_params);
  __pyx_r = __pyx_v_self->in_params;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":480
 *     cdef:
 *         readonly tuple in_params
 *         readonly tuple out_params             # <<<<<<<<<<<<<<
 *         readonly Py_ssize_t nin
 *         readonly Py_ssize_t nout
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_10out_params_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_10out_params_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_10out_params___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_10out_params___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->out_params);
  __pyx_r = __pyx_v_self->out_params;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":481
 *         readonly tuple in_params
 *         readonly tuple out_params
 *         readonly Py_ssize_t nin             # <<<<<<<<<<<<<<
 *         readonly Py_ssize_t nout
 *         readonly Py_ssize_t nargs
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_3nin_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_3nin_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_3nin___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_3nin___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->nin); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 481, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ElementwiseKernel.nin.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":482
 *         readonly tuple out_params
 *         readonly Py_ssize_t nin
 *         readonly Py_ssize_t nout             # <<<<<<<<<<<<<<
 *         readonly Py_ssize_t nargs
 *         readonly tuple params
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_4nout_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_4nout_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_4nout___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_4nout___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->nout); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 482, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ElementwiseKernel.nout.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":483
 *         readonly Py_ssize_t nin
 *         readonly Py_ssize_t nout
 *         readonly Py_ssize_t nargs             # <<<<<<<<<<<<<<
 *         readonly tuple params
 *         readonly str operation
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_5nargs_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_5nargs_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_5nargs___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_5nargs___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->nargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 483, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ElementwiseKernel.nargs.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":484
 *         readonly Py_ssize_t nout
 *         readonly Py_ssize_t nargs
 *         readonly tuple params             # <<<<<<<<<<<<<<
 *         readonly str operation
 *         readonly str name
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_6params_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_6params_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_6params___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_6params___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->params);
  __pyx_r = __pyx_v_self->params;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":485
 *         readonly Py_ssize_t nargs
 *         readonly tuple params
 *         readonly str operation             # <<<<<<<<<<<<<<
 *         readonly str name
 *         readonly bint reduce_dims
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_9operation_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_9operation_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_9operation___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_9operation___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->operation);
  __pyx_r = __pyx_v_self->operation;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":486
 *         readonly tuple params
 *         readonly str operation
 *         readonly str name             # <<<<<<<<<<<<<<
 *         readonly bint reduce_dims
 *         readonly str preamble
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_4name_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_4name___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_4name___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->name);
  __pyx_r = __pyx_v_self->name;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":487
 *         readonly str operation
 *         readonly str name
 *         readonly bint reduce_dims             # <<<<<<<<<<<<<<
 *         readonly str preamble
 *         readonly object kwargs
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_11reduce_dims_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_11reduce_dims_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_11reduce_dims___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_11reduce_dims___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->reduce_dims); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 487, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ElementwiseKernel.reduce_dims.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":488
 *         readonly str name
 *         readonly bint reduce_dims
 *         readonly str preamble             # <<<<<<<<<<<<<<
 *         readonly object kwargs
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_8preamble_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_8preamble_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_8preamble___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_8preamble___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->preamble);
  __pyx_r = __pyx_v_self->preamble;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":489
 *         readonly bint reduce_dims
 *         readonly str preamble
 *         readonly object kwargs             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, in_params, out_params, operation,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_6kwargs_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_6kwargs_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_17ElementwiseKernel_6kwargs___get__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_6kwargs___get__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->kwargs);
  __pyx_r = __pyx_v_self->kwargs;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.in_params, self.kwargs, self.name, self.nargs, self.nin, self.nout, self.operation, self.out_params, self.params, self.preamble, self.reduce_dims)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_17ElementwiseKernel_4__reduce_cython__[] = "ElementwiseKernel.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_5__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_4cupy_4core_4core_17ElementwiseKernel_4__reduce_cython__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_4__reduce_cython__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = 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;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.in_params, self.kwargs, self.name, self.nargs, self.nin, self.nout, self.operation, self.out_params, self.params, self.preamble, self.reduce_dims)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->nargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->nin); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_self->nout); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_self->reduce_dims); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(11); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_self->in_params);
  __Pyx_GIVEREF(__pyx_v_self->in_params);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self->in_params);
  __Pyx_INCREF(__pyx_v_self->kwargs);
  __Pyx_GIVEREF(__pyx_v_self->kwargs);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_self->kwargs);
  __Pyx_INCREF(__pyx_v_self->name);
  __Pyx_GIVEREF(__pyx_v_self->name);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_self->name);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 5, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_self->operation);
  __Pyx_GIVEREF(__pyx_v_self->operation);
  PyTuple_SET_ITEM(__pyx_t_5, 6, __pyx_v_self->operation);
  __Pyx_INCREF(__pyx_v_self->out_params);
  __Pyx_GIVEREF(__pyx_v_self->out_params);
  PyTuple_SET_ITEM(__pyx_t_5, 7, __pyx_v_self->out_params);
  __Pyx_INCREF(__pyx_v_self->params);
  __Pyx_GIVEREF(__pyx_v_self->params);
  PyTuple_SET_ITEM(__pyx_t_5, 8, __pyx_v_self->params);
  __Pyx_INCREF(__pyx_v_self->preamble);
  __Pyx_GIVEREF(__pyx_v_self->preamble);
  PyTuple_SET_ITEM(__pyx_t_5, 9, __pyx_v_self->preamble);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 10, __pyx_t_4);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.in_params, self.kwargs, self.name, self.nargs, self.nin, self.nout, self.operation, self.out_params, self.params, self.preamble, self.reduce_dims)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_5 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v__dict = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "(tree fragment)":5
 *     state = (self.in_params, self.kwargs, self.name, self.nargs, self.nin, self.nout, self.operation, self.out_params, self.params, self.preamble, self.reduce_dims)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_6 = (__pyx_v__dict != Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.in_params is not None or self.kwargs is not None or self.name is not None or self.operation is not None or self.out_params is not None or self.params is not None or self.preamble is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.in_params, self.kwargs, self.name, self.nargs, self.nin, self.nout, self.operation, self.out_params, self.params, self.preamble, self.reduce_dims)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.in_params is not None or self.kwargs is not None or self.name is not None or self.operation is not None or self.out_params is not None or self.params is not None or self.preamble is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, None), state
 */
  /*else*/ {
    __pyx_t_6 = (__pyx_v_self->in_params != ((PyObject*)Py_None));
    __pyx_t_8 = (__pyx_t_6 != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_v_self->kwargs != Py_None);
    __pyx_t_6 = (__pyx_t_8 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->name != ((PyObject*)Py_None));
    __pyx_t_8 = (__pyx_t_6 != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_v_self->operation != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_8 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->out_params != ((PyObject*)Py_None));
    __pyx_t_8 = (__pyx_t_6 != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_v_self->params != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_8 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->preamble != ((PyObject*)Py_None));
    __pyx_t_8 = (__pyx_t_6 != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_7;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.in_params is not None or self.kwargs is not None or self.name is not None or self.operation is not None or self.out_params is not None or self.params is not None or self.preamble is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, None), state
 *     else:
 */
  __pyx_t_7 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":11
 *         use_setstate = self.in_params is not None or self.kwargs is not None or self.name is not None or self.operation is not None or self.out_params is not None or self.params is not None or self.preamble is not None
 *     if use_setstate:
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_ElementwiseKernel); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_131642003);
    __Pyx_GIVEREF(__pyx_int_131642003);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_131642003);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_5, 2, Py_None);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.in_params is not None or self.kwargs is not None or self.name is not None or self.operation is not None or self.out_params is not None or self.params is not None or self.preamble is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, None), state
 *     else:
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ElementwiseKernel__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_ElementwiseKernel); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_131642003);
    __Pyx_GIVEREF(__pyx_int_131642003);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_131642003);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
    __pyx_t_3 = 0;
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.in_params, self.kwargs, self.name, self.nargs, self.nin, self.nout, self.operation, self.out_params, self.params, self.preamble, self.reduce_dims)
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ElementwiseKernel.__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)":14
 *     else:
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ElementwiseKernel__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_4core_4core_17ElementwiseKernel_6__setstate_cython__[] = "ElementwiseKernel.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_7__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_4cupy_4core_4core_17ElementwiseKernel_6__setstate_cython__(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_17ElementwiseKernel_6__setstate_cython__(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ElementwiseKernel__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(4, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core___pyx_unpickle_ElementwiseKernel__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_ElementwiseKernel, (type(self), 0x7d8b293, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ElementwiseKernel__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("cupy.core.core.ElementwiseKernel.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":595
 * 
 * @util.memoize(for_each_device=True)
 * def _get_ufunc_kernel(             # <<<<<<<<<<<<<<
 *         in_types, out_types, routine, args_info, params, name, preamble):
 *     kernel_params = _get_kernel_params(params, args_info)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_29_get_ufunc_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_28_get_ufunc_kernel[] = "_get_ufunc_kernel(in_types, out_types, routine, args_info, params, name, preamble)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_29_get_ufunc_kernel = {"_get_ufunc_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_29_get_ufunc_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_28_get_ufunc_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_29_get_ufunc_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_in_types = 0;
  PyObject *__pyx_v_out_types = 0;
  PyObject *__pyx_v_routine = 0;
  PyObject *__pyx_v_args_info = 0;
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_ufunc_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_types,&__pyx_n_s_out_types,&__pyx_n_s_routine,&__pyx_n_s_args_info,&__pyx_n_s_params,&__pyx_n_s_name,&__pyx_n_s_preamble,0};
    PyObject* values[7] = {0,0,0,0,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  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_in_types)) != 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_out_types)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_ufunc_kernel", 1, 7, 7, 1); __PYX_ERR(1, 595, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_routine)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_ufunc_kernel", 1, 7, 7, 2); __PYX_ERR(1, 595, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args_info)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_ufunc_kernel", 1, 7, 7, 3); __PYX_ERR(1, 595, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_ufunc_kernel", 1, 7, 7, 4); __PYX_ERR(1, 595, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_ufunc_kernel", 1, 7, 7, 5); __PYX_ERR(1, 595, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_preamble)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_ufunc_kernel", 1, 7, 7, 6); __PYX_ERR(1, 595, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_ufunc_kernel") < 0)) __PYX_ERR(1, 595, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
    }
    __pyx_v_in_types = values[0];
    __pyx_v_out_types = values[1];
    __pyx_v_routine = values[2];
    __pyx_v_args_info = values[3];
    __pyx_v_params = values[4];
    __pyx_v_name = values[5];
    __pyx_v_preamble = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_ufunc_kernel", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 595, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_ufunc_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_28_get_ufunc_kernel(__pyx_self, __pyx_v_in_types, __pyx_v_out_types, __pyx_v_routine, __pyx_v_args_info, __pyx_v_params, __pyx_v_name, __pyx_v_preamble);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_28_get_ufunc_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_types, PyObject *__pyx_v_out_types, PyObject *__pyx_v_routine, PyObject *__pyx_v_args_info, PyObject *__pyx_v_params, PyObject *__pyx_v_name, PyObject *__pyx_v_preamble) {
  PyObject *__pyx_v_kernel_params = NULL;
  PyObject *__pyx_v_types = NULL;
  PyObject *__pyx_v_op = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_operation = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  Py_ssize_t __pyx_t_12;
  __Pyx_RefNannySetupContext("_get_ufunc_kernel", 0);
  __Pyx_INCREF(__pyx_v_preamble);

  /* "cupy/core/elementwise.pxi":597
 * def _get_ufunc_kernel(
 *         in_types, out_types, routine, args_info, params, name, preamble):
 *     kernel_params = _get_kernel_params(params, args_info)             # <<<<<<<<<<<<<<
 * 
 *     types = []
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_params))||((__pyx_v_params) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_params)->tp_name), 0))) __PYX_ERR(1, 597, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_args_info))||((__pyx_v_args_info) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args_info)->tp_name), 0))) __PYX_ERR(1, 597, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_kernel_params(((PyObject*)__pyx_v_params), ((PyObject*)__pyx_v_args_info), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_kernel_params = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":599
 *     kernel_params = _get_kernel_params(params, args_info)
 * 
 *     types = []             # <<<<<<<<<<<<<<
 *     op = []
 *     for i, x in enumerate(in_types):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 599, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":600
 * 
 *     types = []
 *     op = []             # <<<<<<<<<<<<<<
 *     for i, x in enumerate(in_types):
 *         types.append('typedef %s in%d_type;' % (_get_typename(x), i))
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 600, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":601
 *     types = []
 *     op = []
 *     for i, x in enumerate(in_types):             # <<<<<<<<<<<<<<
 *         types.append('typedef %s in%d_type;' % (_get_typename(x), i))
 *         if args_info[i][0] is ndarray:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_in_types)) || PyTuple_CheckExact(__pyx_v_in_types)) {
    __pyx_t_2 = __pyx_v_in_types; __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_in_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 601, __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, 601, __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, 601, __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, 601, __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, 601, __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, 601, __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, 601, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 601, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":602
 *     op = []
 *     for i, x in enumerate(in_types):
 *         types.append('typedef %s in%d_type;' % (_get_typename(x), i))             # <<<<<<<<<<<<<<
 *         if args_info[i][0] is ndarray:
 *             op.append(
 */
    __pyx_t_5 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_x, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 602, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 602, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_i);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_typedef_s_in_d_type, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 602, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_types, __pyx_t_5); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(1, 602, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":603
 *     for i, x in enumerate(in_types):
 *         types.append('typedef %s in%d_type;' % (_get_typename(x), i))
 *         if args_info[i][0] is ndarray:             # <<<<<<<<<<<<<<
 *             op.append(
 *                 'const in{0}_type in{0}(_raw_in{0}[_ind.get()]);'
 */
    __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_args_info, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 603, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 603, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_8 = (__pyx_t_6 == ((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_9 = (__pyx_t_8 != 0);
    if (__pyx_t_9) {

      /* "cupy/core/elementwise.pxi":606
 *             op.append(
 *                 'const in{0}_type in{0}(_raw_in{0}[_ind.get()]);'
 *                 .format(i))             # <<<<<<<<<<<<<<
 * 
 *     for i, x in enumerate(out_types):
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_const_in_0__type_in_0__raw_in_0, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 606, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 606, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_i};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 606, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_i};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 606, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 606, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_i);
          __Pyx_GIVEREF(__pyx_v_i);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_i);
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 606, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":604
 *         types.append('typedef %s in%d_type;' % (_get_typename(x), i))
 *         if args_info[i][0] is ndarray:
 *             op.append(             # <<<<<<<<<<<<<<
 *                 'const in{0}_type in{0}(_raw_in{0}[_ind.get()]);'
 *                 .format(i))
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_op, __pyx_t_6); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(1, 604, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/elementwise.pxi":603
 *     for i, x in enumerate(in_types):
 *         types.append('typedef %s in%d_type;' % (_get_typename(x), i))
 *         if args_info[i][0] is ndarray:             # <<<<<<<<<<<<<<
 *             op.append(
 *                 'const in{0}_type in{0}(_raw_in{0}[_ind.get()]);'
 */
    }

    /* "cupy/core/elementwise.pxi":601
 *     types = []
 *     op = []
 *     for i, x in enumerate(in_types):             # <<<<<<<<<<<<<<
 *         types.append('typedef %s in%d_type;' % (_get_typename(x), i))
 *         if args_info[i][0] is ndarray:
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":608
 *                 .format(i))
 * 
 *     for i, x in enumerate(out_types):             # <<<<<<<<<<<<<<
 *         types.append('typedef %s out%d_type;' % (
 *             _get_typename(args_info[i + len(in_types)][1]), i))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_out_types)) || PyTuple_CheckExact(__pyx_v_out_types)) {
    __pyx_t_2 = __pyx_v_out_types; __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_out_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 608, __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, 608, __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_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 608, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 608, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 608, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 608, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 608, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
    __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 608, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":610
 *     for i, x in enumerate(out_types):
 *         types.append('typedef %s out%d_type;' % (
 *             _get_typename(args_info[i + len(in_types)][1]), i))             # <<<<<<<<<<<<<<
 *         op.append('out{0}_type &out{0} = _raw_out{0}[_ind.get()];'.format(i))
 * 
 */
    __pyx_t_12 = PyObject_Length(__pyx_v_in_types); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(1, 610, __pyx_L1_error)
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 610, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyNumber_Add(__pyx_v_i, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 610, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_args_info, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 610, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_6, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 610, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_t_5, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 610, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 610, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_i);
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":609
 * 
 *     for i, x in enumerate(out_types):
 *         types.append('typedef %s out%d_type;' % (             # <<<<<<<<<<<<<<
 *             _get_typename(args_info[i + len(in_types)][1]), i))
 *         op.append('out{0}_type &out{0} = _raw_out{0}[_ind.get()];'.format(i))
 */
    __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_typedef_s_out_d_type, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 609, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_types, __pyx_t_6); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(1, 609, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":611
 *         types.append('typedef %s out%d_type;' % (
 *             _get_typename(args_info[i + len(in_types)][1]), i))
 *         op.append('out{0}_type &out{0} = _raw_out{0}[_ind.get()];'.format(i))             # <<<<<<<<<<<<<<
 * 
 *     op.append(routine)
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_out_0__type_out_0__raw_out_0__in, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 611, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_11) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 611, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_i};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 611, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_i};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 611, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 611, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_INCREF(__pyx_v_i);
        __Pyx_GIVEREF(__pyx_v_i);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_i);
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 611, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_op, __pyx_t_6); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(1, 611, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":608
 *                 .format(i))
 * 
 *     for i, x in enumerate(out_types):             # <<<<<<<<<<<<<<
 *         types.append('typedef %s out%d_type;' % (
 *             _get_typename(args_info[i + len(in_types)][1]), i))
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":613
 *         op.append('out{0}_type &out{0} = _raw_out{0}[_ind.get()];'.format(i))
 * 
 *     op.append(routine)             # <<<<<<<<<<<<<<
 *     operation = '\n'.join(op)
 * 
 */
  __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_op, __pyx_v_routine); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(1, 613, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":614
 * 
 *     op.append(routine)
 *     operation = '\n'.join(op)             # <<<<<<<<<<<<<<
 * 
 *     types.append(preamble)
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__53, __pyx_v_op); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 614, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_operation = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":616
 *     operation = '\n'.join(op)
 * 
 *     types.append(preamble)             # <<<<<<<<<<<<<<
 *     preamble = '\n'.join(types)
 * 
 */
  __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_types, __pyx_v_preamble); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(1, 616, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":617
 * 
 *     types.append(preamble)
 *     preamble = '\n'.join(types)             # <<<<<<<<<<<<<<
 * 
 *     return _get_simple_elementwise_kernel(
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__53, __pyx_v_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 617, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_preamble, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":619
 *     preamble = '\n'.join(types)
 * 
 *     return _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         kernel_params, operation, name, preamble)
 * 
 */
  __Pyx_XDECREF(__pyx_r);

  /* "cupy/core/elementwise.pxi":620
 * 
 *     return _get_simple_elementwise_kernel(
 *         kernel_params, operation, name, preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_simple_elementwise_kernel(__pyx_v_kernel_params, __pyx_v_operation, __pyx_v_name, __pyx_v_preamble, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 619, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":595
 * 
 * @util.memoize(for_each_device=True)
 * def _get_ufunc_kernel(             # <<<<<<<<<<<<<<
 *         in_types, out_types, routine, args_info, params, name, preamble):
 *     kernel_params = _get_kernel_params(params, args_info)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core._get_ufunc_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_kernel_params);
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XDECREF(__pyx_v_op);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_operation);
  __Pyx_XDECREF(__pyx_v_preamble);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":623
 * 
 * 
 * cdef tuple _guess_routine_from_in_types(list ops, tuple in_types):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, n
 *     cdef tuple op, op_types
 */

static PyObject *__pyx_f_4cupy_4core_4core__guess_routine_from_in_types(PyObject *__pyx_v_ops, PyObject *__pyx_v_in_types) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_n;
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_v_op_types = 0;
  PyObject *__pyx_v_can_cast = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __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;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  int __pyx_t_14;
  __Pyx_RefNannySetupContext("_guess_routine_from_in_types", 0);

  /* "cupy/core/elementwise.pxi":626
 *     cdef Py_ssize_t i, n
 *     cdef tuple op, op_types
 *     n = len(in_types)             # <<<<<<<<<<<<<<
 *     can_cast = numpy.can_cast
 *     for op in ops:
 */
  if (unlikely(__pyx_v_in_types == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 626, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_in_types); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 626, __pyx_L1_error)
  __pyx_v_n = __pyx_t_1;

  /* "cupy/core/elementwise.pxi":627
 *     cdef tuple op, op_types
 *     n = len(in_types)
 *     can_cast = numpy.can_cast             # <<<<<<<<<<<<<<
 *     for op in ops:
 *         op_types = op[0]
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 627, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_can_cast); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 627, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_can_cast = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":628
 *     n = len(in_types)
 *     can_cast = numpy.can_cast
 *     for op in ops:             # <<<<<<<<<<<<<<
 *         op_types = op[0]
 *         for i in range(n):
 */
  if (unlikely(__pyx_v_ops == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(1, 628, __pyx_L1_error)
  }
  __pyx_t_3 = __pyx_v_ops; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(1, 628, __pyx_L1_error)
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 628, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    if (!(likely(PyTuple_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(1, 628, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_op, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":629
 *     can_cast = numpy.can_cast
 *     for op in ops:
 *         op_types = op[0]             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             if not can_cast(in_types[i], op_types[i]):
 */
    if (unlikely(__pyx_v_op == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 629, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_GetItemInt_Tuple(__pyx_v_op, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 629, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(PyTuple_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(1, 629, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_op_types, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":630
 *     for op in ops:
 *         op_types = op[0]
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             if not can_cast(in_types[i], op_types[i]):
 *                 break
 */
    __pyx_t_4 = __pyx_v_n;
    __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;

      /* "cupy/core/elementwise.pxi":631
 *         op_types = op[0]
 *         for i in range(n):
 *             if not can_cast(in_types[i], op_types[i]):             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
      if (unlikely(__pyx_v_in_types == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(1, 631, __pyx_L1_error)
      }
      __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v_in_types, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 631, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(__pyx_v_op_types == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(1, 631, __pyx_L1_error)
      }
      __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v_op_types, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 631, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_v_can_cast);
      __pyx_t_9 = __pyx_v_can_cast; __pyx_t_10 = NULL;
      __pyx_t_11 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_11 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_7, __pyx_t_8};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 631, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_7, __pyx_t_8};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 631, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 631, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_8);
        __pyx_t_7 = 0;
        __pyx_t_8 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 631, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(1, 631, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_14 = ((!__pyx_t_13) != 0);
      if (__pyx_t_14) {

        /* "cupy/core/elementwise.pxi":632
 *         for i in range(n):
 *             if not can_cast(in_types[i], op_types[i]):
 *                 break             # <<<<<<<<<<<<<<
 *         else:
 *             return op
 */
        goto __pyx_L6_break;

        /* "cupy/core/elementwise.pxi":631
 *         op_types = op[0]
 *         for i in range(n):
 *             if not can_cast(in_types[i], op_types[i]):             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
      }
    }
    /*else*/ {

      /* "cupy/core/elementwise.pxi":634
 *                 break
 *         else:
 *             return op             # <<<<<<<<<<<<<<
 *     return None
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_op);
      __pyx_r = __pyx_v_op;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L0;
    }
    __pyx_L6_break:;

    /* "cupy/core/elementwise.pxi":628
 *     n = len(in_types)
 *     can_cast = numpy.can_cast
 *     for op in ops:             # <<<<<<<<<<<<<<
 *         op_types = op[0]
 *         for i in range(n):
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":635
 *         else:
 *             return op
 *     return None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":623
 * 
 * 
 * cdef tuple _guess_routine_from_in_types(list ops, tuple in_types):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, n
 *     cdef tuple op, op_types
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core._guess_routine_from_in_types", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_op);
  __Pyx_XDECREF(__pyx_v_op_types);
  __Pyx_XDECREF(__pyx_v_can_cast);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":638
 * 
 * 
 * cdef tuple _guess_routine_from_dtype(list ops, object dtype):             # <<<<<<<<<<<<<<
 *     cdef tuple op, op_types
 *     for op in ops:
 */

static PyObject *__pyx_f_4cupy_4core_4core__guess_routine_from_dtype(PyObject *__pyx_v_ops, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_v_op_types = 0;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("_guess_routine_from_dtype", 0);

  /* "cupy/core/elementwise.pxi":640
 * cdef tuple _guess_routine_from_dtype(list ops, object dtype):
 *     cdef tuple op, op_types
 *     for op in ops:             # <<<<<<<<<<<<<<
 *         op_types = op[1]
 *         for t in op_types:
 */
  if (unlikely(__pyx_v_ops == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(1, 640, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_v_ops; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 640, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 640, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 640, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_op, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":641
 *     cdef tuple op, op_types
 *     for op in ops:
 *         op_types = op[1]             # <<<<<<<<<<<<<<
 *         for t in op_types:
 *             if t != dtype:
 */
    if (unlikely(__pyx_v_op == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 641, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_op, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 641, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_op_types, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":642
 *     for op in ops:
 *         op_types = op[1]
 *         for t in op_types:             # <<<<<<<<<<<<<<
 *             if t != dtype:
 *                 break
 */
    if (unlikely(__pyx_v_op_types == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 642, __pyx_L1_error)
    }
    __pyx_t_3 = __pyx_v_op_types; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= 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_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 642, __pyx_L1_error)
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 642, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":643
 *         op_types = op[1]
 *         for t in op_types:
 *             if t != dtype:             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_v_dtype, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 643, __pyx_L1_error)
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 643, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {

        /* "cupy/core/elementwise.pxi":644
 *         for t in op_types:
 *             if t != dtype:
 *                 break             # <<<<<<<<<<<<<<
 *         else:
 *             return op
 */
        goto __pyx_L6_break;

        /* "cupy/core/elementwise.pxi":643
 *         op_types = op[1]
 *         for t in op_types:
 *             if t != dtype:             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
      }

      /* "cupy/core/elementwise.pxi":642
 *     for op in ops:
 *         op_types = op[1]
 *         for t in op_types:             # <<<<<<<<<<<<<<
 *             if t != dtype:
 *                 break
 */
    }
    /*else*/ {

      /* "cupy/core/elementwise.pxi":646
 *                 break
 *         else:
 *             return op             # <<<<<<<<<<<<<<
 *     return None
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_op);
      __pyx_r = __pyx_v_op;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L0;
    }

    /* "cupy/core/elementwise.pxi":642
 *     for op in ops:
 *         op_types = op[1]
 *         for t in op_types:             # <<<<<<<<<<<<<<
 *             if t != dtype:
 *                 break
 */
    __pyx_L6_break:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":640
 * cdef tuple _guess_routine_from_dtype(list ops, object dtype):
 *     cdef tuple op, op_types
 *     for op in ops:             # <<<<<<<<<<<<<<
 *         op_types = op[1]
 *         for t in op_types:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":647
 *         else:
 *             return op
 *     return None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":638
 * 
 * 
 * cdef tuple _guess_routine_from_dtype(list ops, object dtype):             # <<<<<<<<<<<<<<
 *     cdef tuple op, op_types
 *     for op in ops:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core._guess_routine_from_dtype", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_op);
  __Pyx_XDECREF(__pyx_v_op_types);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":650
 * 
 * 
 * cdef bint _check_should_use_min_scalar(list in_args) except *:             # <<<<<<<<<<<<<<
 *     cdef int kind, max_array_kind, max_scalar_kind
 *     cdef bint all_scalars
 */

static int __pyx_f_4cupy_4core_4core__check_should_use_min_scalar(PyObject *__pyx_v_in_args) {
  int __pyx_v_kind;
  int __pyx_v_max_array_kind;
  int __pyx_v_max_scalar_kind;
  int __pyx_v_all_scalars;
  PyObject *__pyx_v_i = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("_check_should_use_min_scalar", 0);

  /* "cupy/core/elementwise.pxi":653
 *     cdef int kind, max_array_kind, max_scalar_kind
 *     cdef bint all_scalars
 *     all_scalars = True             # <<<<<<<<<<<<<<
 *     max_array_kind = -1
 *     max_scalar_kind = -1
 */
  __pyx_v_all_scalars = 1;

  /* "cupy/core/elementwise.pxi":654
 *     cdef bint all_scalars
 *     all_scalars = True
 *     max_array_kind = -1             # <<<<<<<<<<<<<<
 *     max_scalar_kind = -1
 *     for i in in_args:
 */
  __pyx_v_max_array_kind = -1;

  /* "cupy/core/elementwise.pxi":655
 *     all_scalars = True
 *     max_array_kind = -1
 *     max_scalar_kind = -1             # <<<<<<<<<<<<<<
 *     for i in in_args:
 *         kind = _kind_score[i.dtype.kind]
 */
  __pyx_v_max_scalar_kind = -1;

  /* "cupy/core/elementwise.pxi":656
 *     max_array_kind = -1
 *     max_scalar_kind = -1
 *     for i in in_args:             # <<<<<<<<<<<<<<
 *         kind = _kind_score[i.dtype.kind]
 *         if isinstance(i, ndarray):
 */
  if (unlikely(__pyx_v_in_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(1, 656, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_v_in_args; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 656, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 656, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":657
 *     max_scalar_kind = -1
 *     for i in in_args:
 *         kind = _kind_score[i.dtype.kind]             # <<<<<<<<<<<<<<
 *         if isinstance(i, ndarray):
 *             all_scalars = False
 */
    if (unlikely(__pyx_v_4cupy_4core_4core__kind_score == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 657, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_i, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 657, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_kind); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 657, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_4cupy_4core_4core__kind_score, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 657, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 657, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_kind = __pyx_t_5;

    /* "cupy/core/elementwise.pxi":658
 *     for i in in_args:
 *         kind = _kind_score[i.dtype.kind]
 *         if isinstance(i, ndarray):             # <<<<<<<<<<<<<<
 *             all_scalars = False
 *             max_array_kind = max(max_array_kind, kind)
 */
    __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_i, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_7 = (__pyx_t_6 != 0);
    if (__pyx_t_7) {

      /* "cupy/core/elementwise.pxi":659
 *         kind = _kind_score[i.dtype.kind]
 *         if isinstance(i, ndarray):
 *             all_scalars = False             # <<<<<<<<<<<<<<
 *             max_array_kind = max(max_array_kind, kind)
 *         else:
 */
      __pyx_v_all_scalars = 0;

      /* "cupy/core/elementwise.pxi":660
 *         if isinstance(i, ndarray):
 *             all_scalars = False
 *             max_array_kind = max(max_array_kind, kind)             # <<<<<<<<<<<<<<
 *         else:
 *             max_scalar_kind = max(max_scalar_kind, kind)
 */
      __pyx_t_5 = __pyx_v_kind;
      __pyx_t_8 = __pyx_v_max_array_kind;
      if (((__pyx_t_5 > __pyx_t_8) != 0)) {
        __pyx_t_9 = __pyx_t_5;
      } else {
        __pyx_t_9 = __pyx_t_8;
      }
      __pyx_v_max_array_kind = __pyx_t_9;

      /* "cupy/core/elementwise.pxi":658
 *     for i in in_args:
 *         kind = _kind_score[i.dtype.kind]
 *         if isinstance(i, ndarray):             # <<<<<<<<<<<<<<
 *             all_scalars = False
 *             max_array_kind = max(max_array_kind, kind)
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":662
 *             max_array_kind = max(max_array_kind, kind)
 *         else:
 *             max_scalar_kind = max(max_scalar_kind, kind)             # <<<<<<<<<<<<<<
 *     return (max_scalar_kind != -1 and
 *             not all_scalars and
 */
    /*else*/ {
      __pyx_t_9 = __pyx_v_kind;
      __pyx_t_5 = __pyx_v_max_scalar_kind;
      if (((__pyx_t_9 > __pyx_t_5) != 0)) {
        __pyx_t_8 = __pyx_t_9;
      } else {
        __pyx_t_8 = __pyx_t_5;
      }
      __pyx_v_max_scalar_kind = __pyx_t_8;
    }
    __pyx_L5:;

    /* "cupy/core/elementwise.pxi":656
 *     max_array_kind = -1
 *     max_scalar_kind = -1
 *     for i in in_args:             # <<<<<<<<<<<<<<
 *         kind = _kind_score[i.dtype.kind]
 *         if isinstance(i, ndarray):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":663
 *         else:
 *             max_scalar_kind = max(max_scalar_kind, kind)
 *     return (max_scalar_kind != -1 and             # <<<<<<<<<<<<<<
 *             not all_scalars and
 *             max_array_kind >= max_scalar_kind)
 */
  __pyx_t_6 = ((__pyx_v_max_scalar_kind != -1L) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_7 = __pyx_t_6;
    goto __pyx_L6_bool_binop_done;
  }

  /* "cupy/core/elementwise.pxi":664
 *             max_scalar_kind = max(max_scalar_kind, kind)
 *     return (max_scalar_kind != -1 and
 *             not all_scalars and             # <<<<<<<<<<<<<<
 *             max_array_kind >= max_scalar_kind)
 * 
 */
  __pyx_t_6 = ((!(__pyx_v_all_scalars != 0)) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_7 = __pyx_t_6;
    goto __pyx_L6_bool_binop_done;
  }

  /* "cupy/core/elementwise.pxi":665
 *     return (max_scalar_kind != -1 and
 *             not all_scalars and
 *             max_array_kind >= max_scalar_kind)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_6 = ((__pyx_v_max_array_kind >= __pyx_v_max_scalar_kind) != 0);
  __pyx_t_7 = __pyx_t_6;
  __pyx_L6_bool_binop_done:;
  __pyx_r = __pyx_t_7;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":650
 * 
 * 
 * cdef bint _check_should_use_min_scalar(list in_args) except *:             # <<<<<<<<<<<<<<
 *     cdef int kind, max_array_kind, max_scalar_kind
 *     cdef bint all_scalars
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core._check_should_use_min_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":668
 * 
 * 
 * cdef tuple _guess_routine(str name, dict cache, list ops, list in_args, dtype):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         use_raw_value = _check_should_use_min_scalar(in_args)
 */

static PyObject *__pyx_f_4cupy_4core_4core__guess_routine(PyObject *__pyx_v_name, PyObject *__pyx_v_cache, PyObject *__pyx_v_ops, PyObject *__pyx_v_in_args, PyObject *__pyx_v_dtype) {
  int __pyx_v_use_raw_value;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_op = NULL;
  PyObject *__pyx_v_i = NULL;
  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 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("_guess_routine", 0);
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/elementwise.pxi":669
 * 
 * cdef tuple _guess_routine(str name, dict cache, list ops, list in_args, dtype):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         use_raw_value = _check_should_use_min_scalar(in_args)
 *         if use_raw_value:
 */
  __pyx_t_1 = (__pyx_v_dtype == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":670
 * cdef tuple _guess_routine(str name, dict cache, list ops, list in_args, dtype):
 *     if dtype is None:
 *         use_raw_value = _check_should_use_min_scalar(in_args)             # <<<<<<<<<<<<<<
 *         if use_raw_value:
 *             in_types = tuple(in_args)
 */
    __pyx_t_2 = __pyx_f_4cupy_4core_4core__check_should_use_min_scalar(__pyx_v_in_args); if (unlikely(__pyx_t_2 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(1, 670, __pyx_L1_error)
    __pyx_v_use_raw_value = __pyx_t_2;

    /* "cupy/core/elementwise.pxi":671
 *     if dtype is None:
 *         use_raw_value = _check_should_use_min_scalar(in_args)
 *         if use_raw_value:             # <<<<<<<<<<<<<<
 *             in_types = tuple(in_args)
 *             op = ()
 */
    __pyx_t_2 = (__pyx_v_use_raw_value != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":672
 *         use_raw_value = _check_should_use_min_scalar(in_args)
 *         if use_raw_value:
 *             in_types = tuple(in_args)             # <<<<<<<<<<<<<<
 *             op = ()
 *         else:
 */
      if (unlikely(__pyx_v_in_args == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(1, 672, __pyx_L1_error)
      }
      __pyx_t_3 = PyList_AsTuple(__pyx_v_in_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_in_types = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/elementwise.pxi":673
 *         if use_raw_value:
 *             in_types = tuple(in_args)
 *             op = ()             # <<<<<<<<<<<<<<
 *         else:
 *             in_types = tuple([i.dtype.type for i in in_args])
 */
      __Pyx_INCREF(__pyx_empty_tuple);
      __pyx_v_op = __pyx_empty_tuple;

      /* "cupy/core/elementwise.pxi":671
 *     if dtype is None:
 *         use_raw_value = _check_should_use_min_scalar(in_args)
 *         if use_raw_value:             # <<<<<<<<<<<<<<
 *             in_types = tuple(in_args)
 *             op = ()
 */
      goto __pyx_L4;
    }

    /* "cupy/core/elementwise.pxi":675
 *             op = ()
 *         else:
 *             in_types = tuple([i.dtype.type for i in in_args])             # <<<<<<<<<<<<<<
 *             op = cache.get(in_types, ())
 * 
 */
    /*else*/ {
      __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (unlikely(__pyx_v_in_args == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(1, 675, __pyx_L1_error)
      }
      __pyx_t_4 = __pyx_v_in_args; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      for (;;) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 675, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 675, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
        __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_i, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 675, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 675, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(1, 675, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_in_types = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/elementwise.pxi":676
 *         else:
 *             in_types = tuple([i.dtype.type for i in in_args])
 *             op = cache.get(in_types, ())             # <<<<<<<<<<<<<<
 * 
 *         if op is ():
 */
      if (unlikely(__pyx_v_cache == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
        __PYX_ERR(1, 676, __pyx_L1_error)
      }
      __pyx_t_4 = __Pyx_PyDict_GetItemDefault(__pyx_v_cache, __pyx_v_in_types, __pyx_empty_tuple); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 676, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_op = __pyx_t_4;
      __pyx_t_4 = 0;
    }
    __pyx_L4:;

    /* "cupy/core/elementwise.pxi":678
 *             op = cache.get(in_types, ())
 * 
 *         if op is ():             # <<<<<<<<<<<<<<
 *             op = _guess_routine_from_in_types(ops, in_types)
 *             if not use_raw_value:
 */
    __pyx_t_2 = (__pyx_v_op == __pyx_empty_tuple);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/elementwise.pxi":679
 * 
 *         if op is ():
 *             op = _guess_routine_from_in_types(ops, in_types)             # <<<<<<<<<<<<<<
 *             if not use_raw_value:
 *                 cache[in_types] = op
 */
      __pyx_t_4 = __pyx_f_4cupy_4core_4core__guess_routine_from_in_types(__pyx_v_ops, __pyx_v_in_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 679, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_op, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/elementwise.pxi":680
 *         if op is ():
 *             op = _guess_routine_from_in_types(ops, in_types)
 *             if not use_raw_value:             # <<<<<<<<<<<<<<
 *                 cache[in_types] = op
 *     else:
 */
      __pyx_t_1 = ((!(__pyx_v_use_raw_value != 0)) != 0);
      if (__pyx_t_1) {

        /* "cupy/core/elementwise.pxi":681
 *             op = _guess_routine_from_in_types(ops, in_types)
 *             if not use_raw_value:
 *                 cache[in_types] = op             # <<<<<<<<<<<<<<
 *     else:
 *         op = cache.get(dtype, ())
 */
        if (unlikely(__pyx_v_cache == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(1, 681, __pyx_L1_error)
        }
        if (unlikely(PyDict_SetItem(__pyx_v_cache, __pyx_v_in_types, __pyx_v_op) < 0)) __PYX_ERR(1, 681, __pyx_L1_error)

        /* "cupy/core/elementwise.pxi":680
 *         if op is ():
 *             op = _guess_routine_from_in_types(ops, in_types)
 *             if not use_raw_value:             # <<<<<<<<<<<<<<
 *                 cache[in_types] = op
 *     else:
 */
      }

      /* "cupy/core/elementwise.pxi":678
 *             op = cache.get(in_types, ())
 * 
 *         if op is ():             # <<<<<<<<<<<<<<
 *             op = _guess_routine_from_in_types(ops, in_types)
 *             if not use_raw_value:
 */
    }

    /* "cupy/core/elementwise.pxi":669
 * 
 * cdef tuple _guess_routine(str name, dict cache, list ops, list in_args, dtype):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         use_raw_value = _check_should_use_min_scalar(in_args)
 *         if use_raw_value:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/elementwise.pxi":683
 *                 cache[in_types] = op
 *     else:
 *         op = cache.get(dtype, ())             # <<<<<<<<<<<<<<
 *         if op is ():
 *             op = _guess_routine_from_dtype(ops, dtype)
 */
  /*else*/ {
    if (unlikely(__pyx_v_cache == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
      __PYX_ERR(1, 683, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_PyDict_GetItemDefault(__pyx_v_cache, __pyx_v_dtype, __pyx_empty_tuple); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 683, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_op = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/elementwise.pxi":684
 *     else:
 *         op = cache.get(dtype, ())
 *         if op is ():             # <<<<<<<<<<<<<<
 *             op = _guess_routine_from_dtype(ops, dtype)
 *             cache[dtype] = op
 */
    __pyx_t_1 = (__pyx_v_op == __pyx_empty_tuple);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/elementwise.pxi":685
 *         op = cache.get(dtype, ())
 *         if op is ():
 *             op = _guess_routine_from_dtype(ops, dtype)             # <<<<<<<<<<<<<<
 *             cache[dtype] = op
 * 
 */
      __pyx_t_4 = __pyx_f_4cupy_4core_4core__guess_routine_from_dtype(__pyx_v_ops, __pyx_v_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 685, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_op, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/elementwise.pxi":686
 *         if op is ():
 *             op = _guess_routine_from_dtype(ops, dtype)
 *             cache[dtype] = op             # <<<<<<<<<<<<<<
 * 
 *     if op:
 */
      if (unlikely(__pyx_v_cache == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(1, 686, __pyx_L1_error)
      }
      if (unlikely(PyDict_SetItem(__pyx_v_cache, __pyx_v_dtype, __pyx_v_op) < 0)) __PYX_ERR(1, 686, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":684
 *     else:
 *         op = cache.get(dtype, ())
 *         if op is ():             # <<<<<<<<<<<<<<
 *             op = _guess_routine_from_dtype(ops, dtype)
 *             cache[dtype] = op
 */
    }
  }
  __pyx_L3:;

  /* "cupy/core/elementwise.pxi":688
 *             cache[dtype] = op
 * 
 *     if op:             # <<<<<<<<<<<<<<
 *         return op
 *     if dtype is None:
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_op); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 688, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":689
 * 
 *     if op:
 *         return op             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         dtype = tuple([i.dtype.type for i in in_args])
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(PyTuple_CheckExact(__pyx_v_op))||((__pyx_v_op) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_op)->tp_name), 0))) __PYX_ERR(1, 689, __pyx_L1_error)
    __Pyx_INCREF(__pyx_v_op);
    __pyx_r = ((PyObject*)__pyx_v_op);
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":688
 *             cache[dtype] = op
 * 
 *     if op:             # <<<<<<<<<<<<<<
 *         return op
 *     if dtype is None:
 */
  }

  /* "cupy/core/elementwise.pxi":690
 *     if op:
 *         return op
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         dtype = tuple([i.dtype.type for i in in_args])
 *     raise TypeError('Wrong type (%s) of arguments for %s' %
 */
  __pyx_t_2 = (__pyx_v_dtype == Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/elementwise.pxi":691
 *         return op
 *     if dtype is None:
 *         dtype = tuple([i.dtype.type for i in in_args])             # <<<<<<<<<<<<<<
 *     raise TypeError('Wrong type (%s) of arguments for %s' %
 *                     (dtype, name))
 */
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 691, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__pyx_v_in_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 691, __pyx_L1_error)
    }
    __pyx_t_3 = __pyx_v_in_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
    for (;;) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_7 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 691, __pyx_L1_error)
      #else
      __pyx_t_7 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 691, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_i, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 691, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 691, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_6))) __PYX_ERR(1, 691, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyList_AsTuple(((PyObject*)__pyx_t_4)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 691, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":690
 *     if op:
 *         return op
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         dtype = tuple([i.dtype.type for i in in_args])
 *     raise TypeError('Wrong type (%s) of arguments for %s' %
 */
  }

  /* "cupy/core/elementwise.pxi":693
 *         dtype = tuple([i.dtype.type for i in in_args])
 *     raise TypeError('Wrong type (%s) of arguments for %s' %
 *                     (dtype, name))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 693, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_dtype);
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_name);

  /* "cupy/core/elementwise.pxi":692
 *     if dtype is None:
 *         dtype = tuple([i.dtype.type for i in in_args])
 *     raise TypeError('Wrong type (%s) of arguments for %s' %             # <<<<<<<<<<<<<<
 *                     (dtype, name))
 * 
 */
  __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_type_s_of_arguments_for_s, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 692, __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_TypeError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 692, __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, 692, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":668
 * 
 * 
 * cdef tuple _guess_routine(str name, dict cache, list ops, list in_args, dtype):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         use_raw_value = _check_should_use_min_scalar(in_args)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core._guess_routine", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_op);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":708
 *     """
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                  default_casting=None):
 *         self.name = name
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_5ufunc___init__[] = "ufunc.__init__(self, name, nin, nout, ops, preamble='', doc='', default_casting=None)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_5ufunc_1__init__ = {"__init__", (PyCFunction)__pyx_pw_4cupy_4core_4core_5ufunc_1__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_5ufunc___init__};
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_nin = 0;
  PyObject *__pyx_v_nout = 0;
  PyObject *__pyx_v_ops = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_doc = 0;
  PyObject *__pyx_v_default_casting = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_name,&__pyx_n_s_nin,&__pyx_n_s_nout,&__pyx_n_s_ops,&__pyx_n_s_preamble,&__pyx_n_s_doc,&__pyx_n_s_default_casting,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    values[5] = ((PyObject *)((PyObject*)__pyx_kp_s__6));
    values[6] = ((PyObject *)((PyObject*)__pyx_kp_s__6));

    /* "cupy/core/elementwise.pxi":709
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',
 *                  default_casting=None):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.nin = nin
 */
    values[7] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_self)) != 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("__init__", 0, 5, 8, 1); __PYX_ERR(1, 708, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_nin)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 8, 2); __PYX_ERR(1, 708, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_nout)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 8, 3); __PYX_ERR(1, 708, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ops)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 8, 4); __PYX_ERR(1, 708, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_preamble);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_doc);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default_casting);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(1, 708, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 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_self = values[0];
    __pyx_v_name = values[1];
    __pyx_v_nin = values[2];
    __pyx_v_nout = values[3];
    __pyx_v_ops = values[4];
    __pyx_v_preamble = values[5];
    __pyx_v_doc = values[6];
    __pyx_v_default_casting = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 708, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ufunc.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_5ufunc___init__(__pyx_self, __pyx_v_self, __pyx_v_name, __pyx_v_nin, __pyx_v_nout, __pyx_v_ops, __pyx_v_preamble, __pyx_v_doc, __pyx_v_default_casting);

  /* "cupy/core/elementwise.pxi":708
 *     """
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                  default_casting=None):
 *         self.name = name
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4cupy_4core_4core_5ufunc_8__init___2generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "cupy/core/elementwise.pxi":722
 *             self._default_casting = default_casting
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)             # <<<<<<<<<<<<<<
 *             for i in range(nin))
 *         _out_params = tuple(
 */

static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_8__init___genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_3_genexpr(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_3_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(1, 722, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4cupy_4core_4core_5ufunc_8__init___2generator1, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_ufunc___init___locals_genexpr, __pyx_n_s_cupy_core_core); if (unlikely(!gen)) __PYX_ERR(1, 722, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.core.core.ufunc.__init__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_4cupy_4core_4core_5ufunc_8__init___2generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 722, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":723
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)
 *             for i in range(nin))             # <<<<<<<<<<<<<<
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_nin)) { __Pyx_RaiseClosureNameError("nin"); __PYX_ERR(1, 723, __pyx_L1_error) }
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_nin); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 723, __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, 723, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  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_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 723, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 723, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_3 >= 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_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 723, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 723, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_4(__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(1, 723, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_i);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_i, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":722
 *             self._default_casting = default_casting
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)             # <<<<<<<<<<<<<<
 *             for i in range(nin))
 *         _out_params = tuple(
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_T_in_d, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_INCREF(Py_True);
    __Pyx_GIVEREF(Py_True);
    PyTuple_SET_ITEM(__pyx_t_5, 1, Py_True);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ParameterInfo), __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_XGIVEREF(__pyx_t_2);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_4;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_2);
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 722, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":723
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)
 *             for i in range(nin))             # <<<<<<<<<<<<<<
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "cupy/core/elementwise.pxi":722
 *             self._default_casting = default_casting
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)             # <<<<<<<<<<<<<<
 *             for i in range(nin))
 *         _out_params = tuple(
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4cupy_4core_4core_5ufunc_8__init___5generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "cupy/core/elementwise.pxi":725
 *             for i in range(nin))
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)             # <<<<<<<<<<<<<<
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 */

static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_8__init___3genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_4_genexpr(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_4_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(1, 725, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4cupy_4core_4core_5ufunc_8__init___5generator2, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_ufunc___init___locals_genexpr, __pyx_n_s_cupy_core_core); if (unlikely(!gen)) __PYX_ERR(1, 725, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.core.core.ufunc.__init__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_4cupy_4core_4core_5ufunc_8__init___5generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 725, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":726
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)
 *             for i in range(nout))             # <<<<<<<<<<<<<<
 *         self._params = _in_params + _out_params + (
 *             ParameterInfo('CIndexer _ind', False),)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_nout)) { __Pyx_RaiseClosureNameError("nout"); __PYX_ERR(1, 726, __pyx_L1_error) }
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_nout); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 726, __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, 726, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  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_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 726, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 726, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_3 >= 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_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 726, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 726, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_4(__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(1, 726, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_i);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_i, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":725
 *             for i in range(nin))
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)             # <<<<<<<<<<<<<<
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_T_out_d, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 725, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 725, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_INCREF(Py_False);
    __Pyx_GIVEREF(Py_False);
    PyTuple_SET_ITEM(__pyx_t_5, 1, Py_False);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ParameterInfo), __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 725, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_XGIVEREF(__pyx_t_2);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_4;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_2);
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 725, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":726
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)
 *             for i in range(nout))             # <<<<<<<<<<<<<<
 *         self._params = _in_params + _out_params + (
 *             ParameterInfo('CIndexer _ind', False),)
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "cupy/core/elementwise.pxi":725
 *             for i in range(nin))
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)             # <<<<<<<<<<<<<<
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":708
 *     """
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                  default_casting=None):
 *         self.name = name
 */

static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_nin, PyObject *__pyx_v_nout, PyObject *__pyx_v_ops, PyObject *__pyx_v_preamble, PyObject *__pyx_v_doc, PyObject *__pyx_v_default_casting) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *__pyx_cur_scope;
  PyObject *__pyx_v__in_params = NULL;
  PyObject *__pyx_v__out_params = NULL;
  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;
  __Pyx_RefNannySetupContext("__init__", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_2___init__(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_2___init__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(1, 708, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_nin = __pyx_v_nin;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_nin);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_nin);
  __pyx_cur_scope->__pyx_v_nout = __pyx_v_nout;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_nout);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_nout);

  /* "cupy/core/elementwise.pxi":710
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',
 *                  default_casting=None):
 *         self.name = name             # <<<<<<<<<<<<<<
 *         self.nin = nin
 *         self.nout = nout
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(1, 710, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":711
 *                  default_casting=None):
 *         self.name = name
 *         self.nin = nin             # <<<<<<<<<<<<<<
 *         self.nout = nout
 *         self.nargs = nin + nout
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nin, __pyx_cur_scope->__pyx_v_nin) < 0) __PYX_ERR(1, 711, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":712
 *         self.name = name
 *         self.nin = nin
 *         self.nout = nout             # <<<<<<<<<<<<<<
 *         self.nargs = nin + nout
 *         self._ops = ops
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nout, __pyx_cur_scope->__pyx_v_nout) < 0) __PYX_ERR(1, 712, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":713
 *         self.nin = nin
 *         self.nout = nout
 *         self.nargs = nin + nout             # <<<<<<<<<<<<<<
 *         self._ops = ops
 *         self._preamble = preamble
 */
  __pyx_t_1 = PyNumber_Add(__pyx_cur_scope->__pyx_v_nin, __pyx_cur_scope->__pyx_v_nout); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nargs, __pyx_t_1) < 0) __PYX_ERR(1, 713, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":714
 *         self.nout = nout
 *         self.nargs = nin + nout
 *         self._ops = ops             # <<<<<<<<<<<<<<
 *         self._preamble = preamble
 *         self.__doc__ = doc
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_ops_2, __pyx_v_ops) < 0) __PYX_ERR(1, 714, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":715
 *         self.nargs = nin + nout
 *         self._ops = ops
 *         self._preamble = preamble             # <<<<<<<<<<<<<<
 *         self.__doc__ = doc
 *         if default_casting is None:
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_preamble_2, __pyx_v_preamble) < 0) __PYX_ERR(1, 715, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":716
 *         self._ops = ops
 *         self._preamble = preamble
 *         self.__doc__ = doc             # <<<<<<<<<<<<<<
 *         if default_casting is None:
 *             self._default_casting = 'same_kind'
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_doc_2, __pyx_v_doc) < 0) __PYX_ERR(1, 716, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":717
 *         self._preamble = preamble
 *         self.__doc__ = doc
 *         if default_casting is None:             # <<<<<<<<<<<<<<
 *             self._default_casting = 'same_kind'
 *         else:
 */
  __pyx_t_2 = (__pyx_v_default_casting == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":718
 *         self.__doc__ = doc
 *         if default_casting is None:
 *             self._default_casting = 'same_kind'             # <<<<<<<<<<<<<<
 *         else:
 *             self._default_casting = default_casting
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_default_casting_2, __pyx_n_s_same_kind) < 0) __PYX_ERR(1, 718, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":717
 *         self._preamble = preamble
 *         self.__doc__ = doc
 *         if default_casting is None:             # <<<<<<<<<<<<<<
 *             self._default_casting = 'same_kind'
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/elementwise.pxi":720
 *             self._default_casting = 'same_kind'
 *         else:
 *             self._default_casting = default_casting             # <<<<<<<<<<<<<<
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)
 */
  /*else*/ {
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_default_casting_2, __pyx_v_default_casting) < 0) __PYX_ERR(1, 720, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "cupy/core/elementwise.pxi":722
 *             self._default_casting = default_casting
 *         _in_params = tuple(
 *             ParameterInfo('T in%d' % i, True)             # <<<<<<<<<<<<<<
 *             for i in range(nin))
 *         _out_params = tuple(
 */
  __pyx_t_1 = __pyx_pf_4cupy_4core_4core_5ufunc_8__init___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":721
 *         else:
 *             self._default_casting = default_casting
 *         _in_params = tuple(             # <<<<<<<<<<<<<<
 *             ParameterInfo('T in%d' % i, True)
 *             for i in range(nin))
 */
  __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v__in_params = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/elementwise.pxi":725
 *             for i in range(nin))
 *         _out_params = tuple(
 *             ParameterInfo('T out%d' % i, False)             # <<<<<<<<<<<<<<
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 */
  __pyx_t_4 = __pyx_pf_4cupy_4core_4core_5ufunc_8__init___3genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/elementwise.pxi":724
 *             ParameterInfo('T in%d' % i, True)
 *             for i in range(nin))
 *         _out_params = tuple(             # <<<<<<<<<<<<<<
 *             ParameterInfo('T out%d' % i, False)
 *             for i in range(nout))
 */
  __pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 724, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v__out_params = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":727
 *             ParameterInfo('T out%d' % i, False)
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (             # <<<<<<<<<<<<<<
 *             ParameterInfo('CIndexer _ind', False),)
 *         self._routine_cache = {}
 */
  __pyx_t_1 = PyNumber_Add(__pyx_v__in_params, __pyx_v__out_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 727, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":728
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 *             ParameterInfo('CIndexer _ind', False),)             # <<<<<<<<<<<<<<
 *         self._routine_cache = {}
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ParameterInfo), __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 728, __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;

  /* "cupy/core/elementwise.pxi":727
 *             ParameterInfo('T out%d' % i, False)
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (             # <<<<<<<<<<<<<<
 *             ParameterInfo('CIndexer _ind', False),)
 *         self._routine_cache = {}
 */
  __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 727, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_params_2, __pyx_t_4) < 0) __PYX_ERR(1, 727, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/elementwise.pxi":729
 *         self._params = _in_params + _out_params + (
 *             ParameterInfo('CIndexer _ind', False),)
 *         self._routine_cache = {}             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_routine_cache, __pyx_t_4) < 0) __PYX_ERR(1, 729, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/elementwise.pxi":708
 *     """
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                  default_casting=None):
 *         self.name = name
 */

  /* 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_AddTraceback("cupy.core.core.ufunc.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__in_params);
  __Pyx_XDECREF(__pyx_v__out_params);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":731
 *         self._routine_cache = {}
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<ufunc '%s'>" % self.name
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_3__repr__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4cupy_4core_4core_5ufunc_2__repr__[] = "ufunc.__repr__(self)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_5ufunc_3__repr__ = {"__repr__", (PyCFunction)__pyx_pw_4cupy_4core_4core_5ufunc_3__repr__, METH_O, __pyx_doc_4cupy_4core_4core_5ufunc_2__repr__};
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_3__repr__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_5ufunc_2__repr__(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_2__repr__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "cupy/core/elementwise.pxi":732
 * 
 *     def __repr__(self):
 *         return "<ufunc '%s'>" % self.name             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_ufunc_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 732, __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;

  /* "cupy/core/elementwise.pxi":731
 *         self._routine_cache = {}
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<ufunc '%s'>" % self.name
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.ufunc.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":735
 * 
 *     @property
 *     def types(self):             # <<<<<<<<<<<<<<
 *         """A list of type signatures.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_5types(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4cupy_4core_4core_5ufunc_4types[] = "ufunc.types(self)\nA list of type signatures.\n\n        Each type signature is represented by type character codes of inputs\n        and outputs separated by '->'.\n\n        ";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_5ufunc_5types = {"types", (PyCFunction)__pyx_pw_4cupy_4core_4core_5ufunc_5types, METH_O, __pyx_doc_4cupy_4core_4core_5ufunc_4types};
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_5types(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("types (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_5ufunc_4types(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_4types(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_types = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_v_in_str = NULL;
  PyObject *__pyx_v_out_str = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("types", 0);

  /* "cupy/core/elementwise.pxi":742
 * 
 *         """
 *         types = []             # <<<<<<<<<<<<<<
 *         for in_types, out_types, _ in self._ops:
 *             in_str = ''.join([<str>get_dtype(t).char for t in in_types])
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":743
 *         """
 *         types = []
 *         for in_types, out_types, _ in self._ops:             # <<<<<<<<<<<<<<
 *             in_str = ''.join([<str>get_dtype(t).char for t in in_types])
 *             out_str = ''.join([<str>get_dtype(t).char for t in out_types])
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ops_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 743, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 743, __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, 743, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  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_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 743, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 743, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_3 >= 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_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 743, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 743, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_4(__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(1, 743, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(1, 743, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 743, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 743, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 743, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 743, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 2; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 3) < 0) __PYX_ERR(1, 743, __pyx_L1_error)
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(1, 743, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_in_types, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_out_types, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":744
 *         types = []
 *         for in_types, out_types, _ in self._ops:
 *             in_str = ''.join([<str>get_dtype(t).char for t in in_types])             # <<<<<<<<<<<<<<
 *             out_str = ''.join([<str>get_dtype(t).char for t in out_types])
 *             types.append('%s->%s' % (in_str, out_str))
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 744, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (likely(PyList_CheckExact(__pyx_v_in_types)) || PyTuple_CheckExact(__pyx_v_in_types)) {
      __pyx_t_7 = __pyx_v_in_types; __Pyx_INCREF(__pyx_t_7); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_in_types); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 744, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_11 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 744, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_11)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_6 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 744, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_7, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 744, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 744, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_7, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 744, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        }
      } else {
        __pyx_t_6 = __pyx_t_11(__pyx_t_7);
        if (unlikely(!__pyx_t_6)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(1, 744, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_t, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 744, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_char); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 744, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)((PyObject*)__pyx_t_5)))) __PYX_ERR(1, 744, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyString_Join(__pyx_kp_s__6, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 744, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_in_str, ((PyObject*)__pyx_t_7));
    __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":745
 *         for in_types, out_types, _ in self._ops:
 *             in_str = ''.join([<str>get_dtype(t).char for t in in_types])
 *             out_str = ''.join([<str>get_dtype(t).char for t in out_types])             # <<<<<<<<<<<<<<
 *             types.append('%s->%s' % (in_str, out_str))
 *         return types
 */
    __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 745, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (likely(PyList_CheckExact(__pyx_v_out_types)) || PyTuple_CheckExact(__pyx_v_out_types)) {
      __pyx_t_1 = __pyx_v_out_types; __Pyx_INCREF(__pyx_t_1); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_out_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 745, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 745, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_11)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 745, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 745, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 745, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 745, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        }
      } else {
        __pyx_t_5 = __pyx_t_11(__pyx_t_1);
        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, 745, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_t, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 745, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_char); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 745, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_7, (PyObject*)((PyObject*)__pyx_t_6)))) __PYX_ERR(1, 745, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 745, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_out_str, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":746
 *             in_str = ''.join([<str>get_dtype(t).char for t in in_types])
 *             out_str = ''.join([<str>get_dtype(t).char for t in out_types])
 *             types.append('%s->%s' % (in_str, out_str))             # <<<<<<<<<<<<<<
 *         return types
 * 
 */
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_in_str);
    __Pyx_GIVEREF(__pyx_v_in_str);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_in_str);
    __Pyx_INCREF(__pyx_v_out_str);
    __Pyx_GIVEREF(__pyx_v_out_str);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_out_str);
    __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_s_s, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_types, __pyx_t_7); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(1, 746, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":743
 *         """
 *         types = []
 *         for in_types, out_types, _ in self._ops:             # <<<<<<<<<<<<<<
 *             in_str = ''.join([<str>get_dtype(t).char for t in in_types])
 *             out_str = ''.join([<str>get_dtype(t).char for t in out_types])
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":747
 *             out_str = ''.join([<str>get_dtype(t).char for t in out_types])
 *             types.append('%s->%s' % (in_str, out_str))
 *         return types             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, *args, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_types);
  __pyx_r = __pyx_v_types;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":735
 * 
 *     @property
 *     def types(self):             # <<<<<<<<<<<<<<
 *         """A list of type signatures.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.core.core.ufunc.types", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_in_str);
  __Pyx_XDECREF(__pyx_v_out_str);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":749
 *         return types
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Applies the universal function to arguments elementwise.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_7__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_5ufunc_6__call__[] = "ufunc.__call__(self, *args, **kwargs)\nApplies the universal function to arguments elementwise.\n\n        Args:\n            args: Input arguments. Each of them can be a :class:`cupy.ndarray`\n                object or a scalar. The output arguments can be omitted or be\n                specified by the ``out`` argument.\n            out (cupy.ndarray): Output array. It outputs to new arrays\n                default.\n            dtype: Data type specifier.\n\n        Returns:\n            Output array or a tuple of output arrays.\n\n        ";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_5ufunc_7__call__ = {"__call__", (PyCFunction)__pyx_pw_4cupy_4core_4core_5ufunc_7__call__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_5ufunc_6__call__};
static PyObject *__pyx_pw_4cupy_4core_4core_5ufunc_7__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,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) {
        default:
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "__call__") < 0)) __PYX_ERR(1, 749, __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_self = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 749, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("cupy.core.core.ufunc.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_5ufunc_6__call__(__pyx_self, __pyx_v_self, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_5ufunc_6__call__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4cupy_4cuda_8function_Function *__pyx_v_kern = 0;
  PyObject *__pyx_v_out = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_casting = NULL;
  Py_ssize_t __pyx_v_n_args;
  PyObject *__pyx_v_in_args = NULL;
  PyObject *__pyx_v_out_args = NULL;
  struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_broad = NULL;
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_v_routine = NULL;
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_v_inout_args = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_x = NULL;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_indexer = NULL;
  PyObject *__pyx_v_args_info = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  int __pyx_t_13;
  __Pyx_RefNannySetupContext("__call__", 0);
  __Pyx_INCREF(__pyx_v_args);

  /* "cupy/core/elementwise.pxi":767
 *         cdef function.Function kern
 * 
 *         out = kwargs.pop('out', None)             # <<<<<<<<<<<<<<
 *         dtype = kwargs.pop('dtype', None)
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_out, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_out = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":768
 * 
 *         out = kwargs.pop('out', None)
 *         dtype = kwargs.pop('dtype', None)             # <<<<<<<<<<<<<<
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 *         casting = kwargs.pop('casting', self._default_casting)
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_dtype, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 768, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_dtype = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":770
 *         dtype = kwargs.pop('dtype', None)
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 *         casting = kwargs.pop('casting', self._default_casting)             # <<<<<<<<<<<<<<
 *         if dtype is not None:
 *             dtype = get_dtype(dtype).type
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_default_casting_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_casting, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_casting = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":771
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 *         casting = kwargs.pop('casting', self._default_casting)
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             dtype = get_dtype(dtype).type
 *         if kwargs:
 */
  __pyx_t_3 = (__pyx_v_dtype != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/elementwise.pxi":772
 *         casting = kwargs.pop('casting', self._default_casting)
 *         if dtype is not None:
 *             dtype = get_dtype(dtype).type             # <<<<<<<<<<<<<<
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)
 */
    __pyx_t_2 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/elementwise.pxi":771
 *         # Note default behavior of casting is 'same_kind' on numpy>=1.10
 *         casting = kwargs.pop('casting', self._default_casting)
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             dtype = get_dtype(dtype).type
 *         if kwargs:
 */
  }

  /* "cupy/core/elementwise.pxi":773
 *         if dtype is not None:
 *             dtype = get_dtype(dtype).type
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 773, __pyx_L1_error)
  if (unlikely(__pyx_t_4)) {

    /* "cupy/core/elementwise.pxi":774
 *             dtype = get_dtype(dtype).type
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)             # <<<<<<<<<<<<<<
 * 
 *         n_args = len(args)
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_arguments_s, __pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 774, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 774, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(1, 774, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":773
 *         if dtype is not None:
 *             dtype = get_dtype(dtype).type
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":776
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 *         n_args = len(args)             # <<<<<<<<<<<<<<
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 */
  __pyx_t_5 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 776, __pyx_L1_error)
  __pyx_v_n_args = __pyx_t_5;

  /* "cupy/core/elementwise.pxi":777
 * 
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 */
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_n_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 777, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 777, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_4 = __pyx_t_3;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_n_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_6, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 777, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 777, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __pyx_t_3;
  __pyx_L6_bool_binop_done:;
  if (unlikely(__pyx_t_4)) {

    /* "cupy/core/elementwise.pxi":778
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)             # <<<<<<<<<<<<<<
 * 
 *         args = _preprocess_args(args)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 778, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_number_of_arguments_for_s, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 778, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 778, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(1, 778, __pyx_L1_error)

    /* "cupy/core/elementwise.pxi":777
 * 
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":780
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 *         args = _preprocess_args(args)             # <<<<<<<<<<<<<<
 *         if out is None:
 *             in_args = args[:self.nin]
 */
  __pyx_t_2 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_v_args, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":781
 * 
 *         args = _preprocess_args(args)
 *         if out is None:             # <<<<<<<<<<<<<<
 *             in_args = args[:self.nin]
 *             out_args = args[self.nin:]
 */
  __pyx_t_4 = (__pyx_v_out == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":782
 *         args = _preprocess_args(args)
 *         if out is None:
 *             in_args = args[:self.nin]             # <<<<<<<<<<<<<<
 *             out_args = args[self.nin:]
 *         else:
 */
    if (unlikely(__pyx_v_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 782, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 782, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyList_GetSlice(__pyx_v_args, 0, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_in_args = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":783
 *         if out is None:
 *             in_args = args[:self.nin]
 *             out_args = args[self.nin:]             # <<<<<<<<<<<<<<
 *         else:
 *             if self.nout != 1:
 */
    if (unlikely(__pyx_v_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 783, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 783, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 783, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyList_GetSlice(__pyx_v_args, __pyx_t_5, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 783, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_out_args = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":781
 * 
 *         args = _preprocess_args(args)
 *         if out is None:             # <<<<<<<<<<<<<<
 *             in_args = args[:self.nin]
 *             out_args = args[self.nin:]
 */
    goto __pyx_L8;
  }

  /* "cupy/core/elementwise.pxi":785
 *             out_args = args[self.nin:]
 *         else:
 *             if self.nout != 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)
 *             if n_args != self.nin:
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nout); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 785, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 785, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 785, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(__pyx_t_3)) {

      /* "cupy/core/elementwise.pxi":786
 *         else:
 *             if self.nout != 1:
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)             # <<<<<<<<<<<<<<
 *             if n_args != self.nin:
 *                 raise ValueError("Cannot specify 'out' as both "
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 786, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Cannot_use_out_in_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 786, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 786, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(1, 786, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":785
 *             out_args = args[self.nin:]
 *         else:
 *             if self.nout != 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)
 *             if n_args != self.nin:
 */
    }

    /* "cupy/core/elementwise.pxi":787
 *             if self.nout != 1:
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)
 *             if n_args != self.nin:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Cannot specify 'out' as both "
 *                                  "a positional and keyword argument")
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_n_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 787, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 787, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 787, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 787, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_t_3)) {

      /* "cupy/core/elementwise.pxi":788
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)
 *             if n_args != self.nin:
 *                 raise ValueError("Cannot specify 'out' as both "             # <<<<<<<<<<<<<<
 *                                  "a positional and keyword argument")
 * 
 */
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 788, __pyx_L1_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, 788, __pyx_L1_error)

      /* "cupy/core/elementwise.pxi":787
 *             if self.nout != 1:
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)
 *             if n_args != self.nin:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Cannot specify 'out' as both "
 *                                  "a positional and keyword argument")
 */
    }

    /* "cupy/core/elementwise.pxi":791
 *                                  "a positional and keyword argument")
 * 
 *             in_args = list(args)             # <<<<<<<<<<<<<<
 *             out_args = _preprocess_args((out,))
 *             args += out_args
 */
    __pyx_t_6 = PySequence_List(__pyx_v_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 791, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_in_args = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":792
 * 
 *             in_args = list(args)
 *             out_args = _preprocess_args((out,))             # <<<<<<<<<<<<<<
 *             args += out_args
 * 
 */
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 792, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_out);
    __pyx_t_2 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_t_6, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 792, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_out_args = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":793
 *             in_args = list(args)
 *             out_args = _preprocess_args((out,))
 *             args += out_args             # <<<<<<<<<<<<<<
 * 
 *         broad = broadcast(*args)
 */
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_args, __pyx_v_out_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 793, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_2);
    __pyx_t_2 = 0;
  }
  __pyx_L8:;

  /* "cupy/core/elementwise.pxi":795
 *             args += out_args
 * 
 *         broad = broadcast(*args)             # <<<<<<<<<<<<<<
 *         shape = broad.shape
 * 
 */
  __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 795, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 795, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_broad = ((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":796
 * 
 *         broad = broadcast(*args)
 *         shape = broad.shape             # <<<<<<<<<<<<<<
 * 
 *         in_types, out_types, routine = _guess_routine(
 */
  __pyx_t_6 = __pyx_v_broad->shape;
  __Pyx_INCREF(__pyx_t_6);
  __pyx_v_shape = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":799
 * 
 *         in_types, out_types, routine = _guess_routine(
 *             self.name, self._routine_cache, self._ops, in_args, dtype)             # <<<<<<<<<<<<<<
 * 
 *         out_args = _get_out_args(out_args, out_types, shape, casting)
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 799, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (!(likely(PyString_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(1, 799, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_routine_cache); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 799, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(1, 799, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ops_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 799, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 799, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":798
 *         shape = broad.shape
 * 
 *         in_types, out_types, routine = _guess_routine(             # <<<<<<<<<<<<<<
 *             self.name, self._routine_cache, self._ops, in_args, dtype)
 * 
 */
  __pyx_t_7 = __pyx_f_4cupy_4core_4core__guess_routine(((PyObject*)__pyx_t_6), ((PyObject*)__pyx_t_2), ((PyObject*)__pyx_t_1), __pyx_v_in_args, __pyx_v_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_7 != Py_None)) {
    PyObject* sequence = __pyx_t_7;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(1, 798, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_6);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 798, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 798, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 798, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 798, __pyx_L1_error)
  }
  __pyx_v_in_types = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_out_types = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_routine = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":801
 *             self.name, self._routine_cache, self._ops, in_args, dtype)
 * 
 *         out_args = _get_out_args(out_args, out_types, shape, casting)             # <<<<<<<<<<<<<<
 *         if self.nout == 1:
 *             ret = out_args[0]
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_out_types))||((__pyx_v_out_types) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_out_types)->tp_name), 0))) __PYX_ERR(1, 801, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_shape))||((__pyx_v_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_shape)->tp_name), 0))) __PYX_ERR(1, 801, __pyx_L1_error)
  if (!(likely(PyString_CheckExact(__pyx_v_casting))||((__pyx_v_casting) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_casting)->tp_name), 0))) __PYX_ERR(1, 801, __pyx_L1_error)
  __pyx_t_7 = __pyx_f_4cupy_4core_4core__get_out_args(__pyx_v_out_args, ((PyObject*)__pyx_v_out_types), ((PyObject*)__pyx_v_shape), ((PyObject*)__pyx_v_casting)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_7));
  __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":802
 * 
 *         out_args = _get_out_args(out_args, out_types, shape, casting)
 *         if self.nout == 1:             # <<<<<<<<<<<<<<
 *             ret = out_args[0]
 *         else:
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nout); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 802, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_t_7, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 802, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 802, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":803
 *         out_args = _get_out_args(out_args, out_types, shape, casting)
 *         if self.nout == 1:
 *             ret = out_args[0]             # <<<<<<<<<<<<<<
 *         else:
 *             ret = tuple(out_args)
 */
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 803, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_ret = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":802
 * 
 *         out_args = _get_out_args(out_args, out_types, shape, casting)
 *         if self.nout == 1:             # <<<<<<<<<<<<<<
 *             ret = out_args[0]
 *         else:
 */
    goto __pyx_L11;
  }

  /* "cupy/core/elementwise.pxi":805
 *             ret = out_args[0]
 *         else:
 *             ret = tuple(out_args)             # <<<<<<<<<<<<<<
 * 
 *         if 0 in shape:
 */
  /*else*/ {
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 805, __pyx_L1_error)
    }
    __pyx_t_6 = PyList_AsTuple(__pyx_v_out_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 805, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_ret = __pyx_t_6;
    __pyx_t_6 = 0;
  }
  __pyx_L11:;

  /* "cupy/core/elementwise.pxi":807
 *             ret = tuple(out_args)
 * 
 *         if 0 in shape:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_int_0, __pyx_v_shape, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 807, __pyx_L1_error)
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/elementwise.pxi":808
 * 
 *         if 0 in shape:
 *             return ret             # <<<<<<<<<<<<<<
 * 
 *         inout_args = []
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_ret);
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":807
 *             ret = tuple(out_args)
 * 
 *         if 0 in shape:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":810
 *             return ret
 * 
 *         inout_args = []             # <<<<<<<<<<<<<<
 *         for i, t in enumerate(in_types):
 *             x = broad.values[i]
 */
  __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 810, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_inout_args = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":811
 * 
 *         inout_args = []
 *         for i, t in enumerate(in_types):             # <<<<<<<<<<<<<<
 *             x = broad.values[i]
 *             inout_args.append(x if isinstance(x, ndarray) else t(x))
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_6 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_in_types)) || PyTuple_CheckExact(__pyx_v_in_types)) {
    __pyx_t_7 = __pyx_v_in_types; __Pyx_INCREF(__pyx_t_7); __pyx_t_5 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_in_types); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 811, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 811, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_7))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 811, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_7, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 811, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 811, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_7, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 811, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_8(__pyx_t_7);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 811, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_6);
    __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_6, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 811, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6);
    __pyx_t_6 = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":812
 *         inout_args = []
 *         for i, t in enumerate(in_types):
 *             x = broad.values[i]             # <<<<<<<<<<<<<<
 *             inout_args.append(x if isinstance(x, ndarray) else t(x))
 *         inout_args.extend(out_args)
 */
    if (unlikely(__pyx_v_broad->values == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 812, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_broad->values, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 812, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":813
 *         for i, t in enumerate(in_types):
 *             x = broad.values[i]
 *             inout_args.append(x if isinstance(x, ndarray) else t(x))             # <<<<<<<<<<<<<<
 *         inout_args.extend(out_args)
 *         inout_args, shape = _reduce_dims(inout_args, self._params, shape)
 */
    __pyx_t_4 = __Pyx_TypeCheck(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_4 != 0)) {
      __Pyx_INCREF(__pyx_v_x);
      __pyx_t_2 = __pyx_v_x;
    } else {
      __Pyx_INCREF(__pyx_v_t);
      __pyx_t_9 = __pyx_v_t; __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 813, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_x};
          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 813, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_x};
          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 813, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 813, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_x);
          __Pyx_GIVEREF(__pyx_v_x);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_x);
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 813, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_2 = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    __pyx_t_12 = __Pyx_PyObject_Append(__pyx_v_inout_args, __pyx_t_2); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(1, 813, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":811
 * 
 *         inout_args = []
 *         for i, t in enumerate(in_types):             # <<<<<<<<<<<<<<
 *             x = broad.values[i]
 *             inout_args.append(x if isinstance(x, ndarray) else t(x))
 */
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":814
 *             x = broad.values[i]
 *             inout_args.append(x if isinstance(x, ndarray) else t(x))
 *         inout_args.extend(out_args)             # <<<<<<<<<<<<<<
 *         inout_args, shape = _reduce_dims(inout_args, self._params, shape)
 *         indexer = Indexer(shape)
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_inout_args, __pyx_n_s_extend); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 814, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_out_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 814, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_out_args};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 814, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_out_args};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 814, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 814, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(__pyx_v_out_args);
      __Pyx_GIVEREF(__pyx_v_out_args);
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_out_args);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 814, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":815
 *             inout_args.append(x if isinstance(x, ndarray) else t(x))
 *         inout_args.extend(out_args)
 *         inout_args, shape = _reduce_dims(inout_args, self._params, shape)             # <<<<<<<<<<<<<<
 *         indexer = Indexer(shape)
 *         inout_args.append(indexer)
 */
  if (!(likely(PyList_CheckExact(__pyx_v_inout_args))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_inout_args)->tp_name), 0))) __PYX_ERR(1, 815, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 815, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (!(likely(PyTuple_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(1, 815, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_shape))||((__pyx_v_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_shape)->tp_name), 0))) __PYX_ERR(1, 815, __pyx_L1_error)
  __pyx_t_7 = __pyx_f_4cupy_4core_4core__reduce_dims(((PyObject*)__pyx_v_inout_args), ((PyObject*)__pyx_t_6), ((PyObject*)__pyx_v_shape), 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 815, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (likely(__pyx_t_7 != Py_None)) {
    PyObject* sequence = __pyx_t_7;
    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, 815, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_1);
    #else
    __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 815, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 815, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 815, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_inout_args, __pyx_t_6);
  __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_shape, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":816
 *         inout_args.extend(out_args)
 *         inout_args, shape = _reduce_dims(inout_args, self._params, shape)
 *         indexer = Indexer(shape)             # <<<<<<<<<<<<<<
 *         inout_args.append(indexer)
 *         args_info = _get_args_info(inout_args)
 */
  __pyx_t_7 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_v_shape); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 816, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_v_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":817
 *         inout_args, shape = _reduce_dims(inout_args, self._params, shape)
 *         indexer = Indexer(shape)
 *         inout_args.append(indexer)             # <<<<<<<<<<<<<<
 *         args_info = _get_args_info(inout_args)
 * 
 */
  __pyx_t_12 = __Pyx_PyObject_Append(__pyx_v_inout_args, ((PyObject *)__pyx_v_indexer)); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(1, 817, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":818
 *         indexer = Indexer(shape)
 *         inout_args.append(indexer)
 *         args_info = _get_args_info(inout_args)             # <<<<<<<<<<<<<<
 * 
 *         kern = _get_ufunc_kernel(
 */
  if (!(likely(PyList_CheckExact(__pyx_v_inout_args))||((__pyx_v_inout_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_inout_args)->tp_name), 0))) __PYX_ERR(1, 818, __pyx_L1_error)
  __pyx_t_7 = __pyx_f_4cupy_4core_4core__get_args_info(((PyObject*)__pyx_v_inout_args), 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 818, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_v_args_info = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":820
 *         args_info = _get_args_info(inout_args)
 * 
 *         kern = _get_ufunc_kernel(             # <<<<<<<<<<<<<<
 *             in_types, out_types, routine, args_info,
 *             self._params, self.name, self._preamble)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_ufunc_kernel); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 820, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":822
 *         kern = _get_ufunc_kernel(
 *             in_types, out_types, routine, args_info,
 *             self._params, self.name, self._preamble)             # <<<<<<<<<<<<<<
 * 
 *         kern.linear_launch(indexer.size, inout_args)
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 822, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 822, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_preamble_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 822, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_11 = NULL;
  __pyx_t_13 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_13 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_11, __pyx_v_in_types, __pyx_v_out_types, __pyx_v_routine, __pyx_v_args_info, __pyx_t_6, __pyx_t_2, __pyx_t_9};
    __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_13, 7+__pyx_t_13); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 820, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_11, __pyx_v_in_types, __pyx_v_out_types, __pyx_v_routine, __pyx_v_args_info, __pyx_t_6, __pyx_t_2, __pyx_t_9};
    __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_13, 7+__pyx_t_13); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 820, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(7+__pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 820, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_11) {
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL;
    }
    __Pyx_INCREF(__pyx_v_in_types);
    __Pyx_GIVEREF(__pyx_v_in_types);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_13, __pyx_v_in_types);
    __Pyx_INCREF(__pyx_v_out_types);
    __Pyx_GIVEREF(__pyx_v_out_types);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_13, __pyx_v_out_types);
    __Pyx_INCREF(__pyx_v_routine);
    __Pyx_GIVEREF(__pyx_v_routine);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_13, __pyx_v_routine);
    __Pyx_INCREF(__pyx_v_args_info);
    __Pyx_GIVEREF(__pyx_v_args_info);
    PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_13, __pyx_v_args_info);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 4+__pyx_t_13, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_10, 5+__pyx_t_13, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_10, 6+__pyx_t_13, __pyx_t_9);
    __pyx_t_6 = 0;
    __pyx_t_2 = 0;
    __pyx_t_9 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 820, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":820
 *         args_info = _get_args_info(inout_args)
 * 
 *         kern = _get_ufunc_kernel(             # <<<<<<<<<<<<<<
 *             in_types, out_types, routine, args_info,
 *             self._params, self.name, self._preamble)
 */
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4cuda_8function_Function))))) __PYX_ERR(1, 820, __pyx_L1_error)
  __pyx_v_kern = ((struct __pyx_obj_4cupy_4cuda_8function_Function *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":824
 *             self._params, self.name, self._preamble)
 * 
 *         kern.linear_launch(indexer.size, inout_args)             # <<<<<<<<<<<<<<
 *         return ret
 * 
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Function *)__pyx_v_kern->__pyx_vtab)->linear_launch(__pyx_v_kern, __pyx_v_indexer->size, __pyx_v_inout_args, 0, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 824, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":825
 * 
 *         kern.linear_launch(indexer.size, inout_args)
 *         return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":749
 *         return types
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Applies the universal function to arguments elementwise.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core.ufunc.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF((PyObject *)__pyx_v_kern);
  __Pyx_XDECREF(__pyx_v_out);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_casting);
  __Pyx_XDECREF(__pyx_v_in_args);
  __Pyx_XDECREF(__pyx_v_out_args);
  __Pyx_XDECREF((PyObject *)__pyx_v_broad);
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v_routine);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_inout_args);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_indexer);
  __Pyx_XDECREF(__pyx_v_args_info);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/elementwise.pxi":828
 * 
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                    default_casting=None):
 *     _ops = []
 */

static PyObject *__pyx_pw_4cupy_4core_4core_31create_ufunc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_create_ufunc(PyObject *__pyx_v_name, PyObject *__pyx_v_ops, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_create_ufunc *__pyx_optional_args) {
  PyObject *__pyx_v_routine = ((PyObject *)Py_None);
  PyObject *__pyx_v_preamble = ((PyObject *)__pyx_kp_s__6);
  PyObject *__pyx_v_doc = ((PyObject *)__pyx_kp_s__6);

  /* "cupy/core/elementwise.pxi":829
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc='',
 *                    default_casting=None):             # <<<<<<<<<<<<<<
 *     _ops = []
 *     for t in ops:
 */
  PyObject *__pyx_v_default_casting = ((PyObject *)Py_None);
  PyObject *__pyx_v__ops = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_typ = NULL;
  PyObject *__pyx_v_rt = NULL;
  PyObject *__pyx_v_types = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  int __pyx_t_13;
  __Pyx_RefNannySetupContext("create_ufunc", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_routine = __pyx_optional_args->routine;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_preamble = __pyx_optional_args->preamble;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_doc = __pyx_optional_args->doc;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_default_casting = __pyx_optional_args->default_casting;
          }
        }
      }
    }
  }

  /* "cupy/core/elementwise.pxi":830
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc='',
 *                    default_casting=None):
 *     _ops = []             # <<<<<<<<<<<<<<
 *     for t in ops:
 *         if not isinstance(t, tuple):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 830, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__ops = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":831
 *                    default_casting=None):
 *     _ops = []
 *     for t in ops:             # <<<<<<<<<<<<<<
 *         if not isinstance(t, tuple):
 *             typ = t
 */
  if (likely(PyList_CheckExact(__pyx_v_ops)) || PyTuple_CheckExact(__pyx_v_ops)) {
    __pyx_t_1 = __pyx_v_ops; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_ops); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 831, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 831, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 831, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 831, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 831, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 831, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 831, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/elementwise.pxi":832
 *     _ops = []
 *     for t in ops:
 *         if not isinstance(t, tuple):             # <<<<<<<<<<<<<<
 *             typ = t
 *             rt = routine
 */
    __pyx_t_5 = PyTuple_Check(__pyx_v_t); 
    __pyx_t_6 = ((!(__pyx_t_5 != 0)) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/elementwise.pxi":833
 *     for t in ops:
 *         if not isinstance(t, tuple):
 *             typ = t             # <<<<<<<<<<<<<<
 *             rt = routine
 *         else:
 */
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_XDECREF_SET(__pyx_v_typ, __pyx_v_t);

      /* "cupy/core/elementwise.pxi":834
 *         if not isinstance(t, tuple):
 *             typ = t
 *             rt = routine             # <<<<<<<<<<<<<<
 *         else:
 *             typ, rt = t
 */
      __Pyx_INCREF(__pyx_v_routine);
      __Pyx_XDECREF_SET(__pyx_v_rt, __pyx_v_routine);

      /* "cupy/core/elementwise.pxi":832
 *     _ops = []
 *     for t in ops:
 *         if not isinstance(t, tuple):             # <<<<<<<<<<<<<<
 *             typ = t
 *             rt = routine
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":836
 *             rt = routine
 *         else:
 *             typ, rt = t             # <<<<<<<<<<<<<<
 * 
 *         types = typ.split('->')
 */
    /*else*/ {
      if ((likely(PyTuple_CheckExact(__pyx_v_t))) || (PyList_CheckExact(__pyx_v_t))) {
        PyObject* sequence = __pyx_v_t;
        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, 836, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 836, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 836, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      } else {
        Py_ssize_t index = -1;
        __pyx_t_8 = PyObject_GetIter(__pyx_v_t); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 836, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(1, 836, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(1, 836, __pyx_L1_error)
        __pyx_L7_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_typ, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_rt, __pyx_t_7);
      __pyx_t_7 = 0;
    }
    __pyx_L5:;

    /* "cupy/core/elementwise.pxi":838
 *             typ, rt = t
 * 
 *         types = typ.split('->')             # <<<<<<<<<<<<<<
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_typ, __pyx_n_s_split); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__72, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_types, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/elementwise.pxi":839
 * 
 *         types = typ.split('->')
 *         if len(types) == 1:             # <<<<<<<<<<<<<<
 *             in_types = out_types = tuple(types)
 *         else:
 */
    __pyx_t_10 = PyObject_Length(__pyx_v_types); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(1, 839, __pyx_L1_error)
    __pyx_t_6 = ((__pyx_t_10 == 1) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/elementwise.pxi":840
 *         types = typ.split('->')
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)             # <<<<<<<<<<<<<<
 *         else:
 *             in_types, out_types = map(tuple, types)
 */
      __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_v_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 840, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_in_types, __pyx_t_4);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_out_types, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/elementwise.pxi":839
 * 
 *         types = typ.split('->')
 *         if len(types) == 1:             # <<<<<<<<<<<<<<
 *             in_types = out_types = tuple(types)
 *         else:
 */
      goto __pyx_L8;
    }

    /* "cupy/core/elementwise.pxi":842
 *             in_types = out_types = tuple(types)
 *         else:
 *             in_types, out_types = map(tuple, types)             # <<<<<<<<<<<<<<
 *         in_types = tuple([get_dtype(t).type for t in in_types])
 *         out_types = tuple([get_dtype(t).type for t in out_types])
 */
    /*else*/ {
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 842, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)(&PyTuple_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyTuple_Type)));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyTuple_Type)));
      __Pyx_INCREF(__pyx_v_types);
      __Pyx_GIVEREF(__pyx_v_types);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_types);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 842, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
        PyObject* sequence = __pyx_t_7;
        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, 842, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 842, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 842, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 842, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_9(__pyx_t_11); if (unlikely(!__pyx_t_4)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_8 = __pyx_t_9(__pyx_t_11); if (unlikely(!__pyx_t_8)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_11), 2) < 0) __PYX_ERR(1, 842, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L10_unpacking_done;
        __pyx_L9_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(1, 842, __pyx_L1_error)
        __pyx_L10_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_in_types, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_out_types, __pyx_t_8);
      __pyx_t_8 = 0;
    }
    __pyx_L8:;

    /* "cupy/core/elementwise.pxi":843
 *         else:
 *             in_types, out_types = map(tuple, types)
 *         in_types = tuple([get_dtype(t).type for t in in_types])             # <<<<<<<<<<<<<<
 *         out_types = tuple([get_dtype(t).type for t in out_types])
 *         _ops.append((in_types, out_types, rt))
 */
    __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 843, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (likely(PyList_CheckExact(__pyx_v_in_types)) || PyTuple_CheckExact(__pyx_v_in_types)) {
      __pyx_t_8 = __pyx_v_in_types; __Pyx_INCREF(__pyx_t_8); __pyx_t_10 = 0;
      __pyx_t_12 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_in_types); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 843, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_12 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 843, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_12)) {
        if (likely(PyList_CheckExact(__pyx_t_8))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 843, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 843, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 843, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 843, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_12(__pyx_t_8);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(1, 843, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_t, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 843, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_type); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 843, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_7, (PyObject*)__pyx_t_11))) __PYX_ERR(1, 843, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyList_AsTuple(((PyObject*)__pyx_t_7)); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 843, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF_SET(__pyx_v_in_types, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/elementwise.pxi":844
 *             in_types, out_types = map(tuple, types)
 *         in_types = tuple([get_dtype(t).type for t in in_types])
 *         out_types = tuple([get_dtype(t).type for t in out_types])             # <<<<<<<<<<<<<<
 *         _ops.append((in_types, out_types, rt))
 * 
 */
    __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 844, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (likely(PyList_CheckExact(__pyx_v_out_types)) || PyTuple_CheckExact(__pyx_v_out_types)) {
      __pyx_t_7 = __pyx_v_out_types; __Pyx_INCREF(__pyx_t_7); __pyx_t_10 = 0;
      __pyx_t_12 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_out_types); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 844, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_12 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 844, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_12)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_11 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_10); __Pyx_INCREF(__pyx_t_11); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 844, __pyx_L1_error)
          #else
          __pyx_t_11 = PySequence_ITEM(__pyx_t_7, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 844, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_10); __Pyx_INCREF(__pyx_t_11); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 844, __pyx_L1_error)
          #else
          __pyx_t_11 = PySequence_ITEM(__pyx_t_7, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 844, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          #endif
        }
      } else {
        __pyx_t_11 = __pyx_t_12(__pyx_t_7);
        if (unlikely(!__pyx_t_11)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(1, 844, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_11);
      }
      __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_11);
      __pyx_t_11 = 0;
      __pyx_t_11 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_t, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 844, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 844, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_t_4))) __PYX_ERR(1, 844, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyList_AsTuple(((PyObject*)__pyx_t_8)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 844, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF_SET(__pyx_v_out_types, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":845
 *         in_types = tuple([get_dtype(t).type for t in in_types])
 *         out_types = tuple([get_dtype(t).type for t in out_types])
 *         _ops.append((in_types, out_types, rt))             # <<<<<<<<<<<<<<
 * 
 *     ret = ufunc(name, len(_ops[0][0]), len(_ops[0][1]), _ops, preamble, doc,
 */
    __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 845, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_in_types);
    __Pyx_GIVEREF(__pyx_v_in_types);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_in_types);
    __Pyx_INCREF(__pyx_v_out_types);
    __Pyx_GIVEREF(__pyx_v_out_types);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_out_types);
    __Pyx_INCREF(__pyx_v_rt);
    __Pyx_GIVEREF(__pyx_v_rt);
    PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_v_rt);
    __pyx_t_13 = __Pyx_PyList_Append(__pyx_v__ops, __pyx_t_7); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(1, 845, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":831
 *                    default_casting=None):
 *     _ops = []
 *     for t in ops:             # <<<<<<<<<<<<<<
 *         if not isinstance(t, tuple):
 *             typ = t
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":847
 *         _ops.append((in_types, out_types, rt))
 * 
 *     ret = ufunc(name, len(_ops[0][0]), len(_ops[0][1]), _ops, preamble, doc,             # <<<<<<<<<<<<<<
 *                 default_casting=default_casting)
 *     return ret
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ufunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v__ops, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_7, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_2 = PyObject_Length(__pyx_t_8); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(1, 847, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v__ops, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_7, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_2 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(1, 847, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = PyTuple_New(6); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_name);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_4);
  __Pyx_INCREF(__pyx_v__ops);
  __Pyx_GIVEREF(__pyx_v__ops);
  PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_v__ops);
  __Pyx_INCREF(__pyx_v_preamble);
  __Pyx_GIVEREF(__pyx_v_preamble);
  PyTuple_SET_ITEM(__pyx_t_7, 4, __pyx_v_preamble);
  __Pyx_INCREF(__pyx_v_doc);
  __Pyx_GIVEREF(__pyx_v_doc);
  PyTuple_SET_ITEM(__pyx_t_7, 5, __pyx_v_doc);
  __pyx_t_8 = 0;
  __pyx_t_4 = 0;

  /* "cupy/core/elementwise.pxi":848
 * 
 *     ret = ufunc(name, len(_ops[0][0]), len(_ops[0][1]), _ops, preamble, doc,
 *                 default_casting=default_casting)             # <<<<<<<<<<<<<<
 *     return ret
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 848, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_default_casting, __pyx_v_default_casting) < 0) __PYX_ERR(1, 848, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":847
 *         _ops.append((in_types, out_types, rt))
 * 
 *     ret = ufunc(name, len(_ops[0][0]), len(_ops[0][1]), _ops, preamble, doc,             # <<<<<<<<<<<<<<
 *                 default_casting=default_casting)
 *     return ret
 */
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_ret = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":849
 *     ret = ufunc(name, len(_ops[0][0]), len(_ops[0][1]), _ops, preamble, doc,
 *                 default_casting=default_casting)
 *     return ret             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":828
 * 
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                    default_casting=None):
 *     _ops = []
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core.create_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__ops);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_typ);
  __Pyx_XDECREF(__pyx_v_rt);
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_31create_ufunc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_30create_ufunc[] = "create_ufunc(name, ops, routine=None, preamble='', doc='', default_casting=None)";
static PyObject *__pyx_pw_4cupy_4core_4core_31create_ufunc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_ops = 0;
  PyObject *__pyx_v_routine = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_doc = 0;
  PyObject *__pyx_v_default_casting = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_ufunc (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_ops,&__pyx_n_s_routine,&__pyx_n_s_preamble,&__pyx_n_s_doc,&__pyx_n_s_default_casting,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)__pyx_kp_s__6);
    values[4] = ((PyObject *)__pyx_kp_s__6);

    /* "cupy/core/elementwise.pxi":829
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc='',
 *                    default_casting=None):             # <<<<<<<<<<<<<<
 *     _ops = []
 *     for t in ops:
 */
    values[5] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_name)) != 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_ops)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_ufunc", 0, 2, 6, 1); __PYX_ERR(1, 828, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_routine);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_preamble);
          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_doc);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default_casting);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_ufunc") < 0)) __PYX_ERR(1, 828, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_name = values[0];
    __pyx_v_ops = values[1];
    __pyx_v_routine = values[2];
    __pyx_v_preamble = values[3];
    __pyx_v_doc = values[4];
    __pyx_v_default_casting = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_ufunc", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 828, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.create_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_30create_ufunc(__pyx_self, __pyx_v_name, __pyx_v_ops, __pyx_v_routine, __pyx_v_preamble, __pyx_v_doc, __pyx_v_default_casting);

  /* "cupy/core/elementwise.pxi":828
 * 
 * 
 * cpdef create_ufunc(name, ops, routine=None, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                    default_casting=None):
 *     _ops = []
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_30create_ufunc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_ops, PyObject *__pyx_v_routine, PyObject *__pyx_v_preamble, PyObject *__pyx_v_doc, PyObject *__pyx_v_default_casting) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_create_ufunc __pyx_t_2;
  __Pyx_RefNannySetupContext("create_ufunc", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.routine = __pyx_v_routine;
  __pyx_t_2.preamble = __pyx_v_preamble;
  __pyx_t_2.doc = __pyx_v_doc;
  __pyx_t_2.default_casting = __pyx_v_default_casting;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_v_name, __pyx_v_ops, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.create_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":10
 * 
 * 
 * cpdef _get_simple_reduction_kernel(             # <<<<<<<<<<<<<<
 *         name, block_size, reduce_type, params, identity,
 *         pre_map_expr, reduce_expr, post_map_expr,
 */

static PyObject *__pyx_pw_4cupy_4core_4core_33_get_simple_reduction_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_simple_reduction_kernel(PyObject *__pyx_v_name, PyObject *__pyx_v_block_size, PyObject *__pyx_v_reduce_type, PyObject *__pyx_v_params, PyObject *__pyx_v_identity, PyObject *__pyx_v_pre_map_expr, PyObject *__pyx_v_reduce_expr, PyObject *__pyx_v_post_map_expr, PyObject *__pyx_v_type_preamble, PyObject *__pyx_v_input_expr, PyObject *__pyx_v_output_expr, PyObject *__pyx_v_preamble, PyObject *__pyx_v_options, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_module_code = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_v_module = NULL;
  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;
  struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache __pyx_t_6;
  __Pyx_RefNannySetupContext("_get_simple_reduction_kernel", 0);
  __Pyx_INCREF(__pyx_v_identity);

  /* "cupy/core/reduction.pxi":14
 *         pre_map_expr, reduce_expr, post_map_expr,
 *         type_preamble, input_expr, output_expr, preamble, options):
 *     if identity is None:             # <<<<<<<<<<<<<<
 *         identity = ''
 *     module_code = string.Template('''
 */
  __pyx_t_1 = (__pyx_v_identity == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/reduction.pxi":15
 *         type_preamble, input_expr, output_expr, preamble, options):
 *     if identity is None:
 *         identity = ''             # <<<<<<<<<<<<<<
 *     module_code = string.Template('''
 *     ${type_preamble}
 */
    __Pyx_INCREF(__pyx_kp_s__6);
    __Pyx_DECREF_SET(__pyx_v_identity, __pyx_kp_s__6);

    /* "cupy/core/reduction.pxi":14
 *         pre_map_expr, reduce_expr, post_map_expr,
 *         type_preamble, input_expr, output_expr, preamble, options):
 *     if identity is None:             # <<<<<<<<<<<<<<
 *         identity = ''
 *     module_code = string.Template('''
 */
  }

  /* "cupy/core/reduction.pxi":16
 *     if identity is None:
 *         identity = ''
 *     module_code = string.Template('''             # <<<<<<<<<<<<<<
 *     ${type_preamble}
 *     ${preamble}
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_string); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Template); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":92
 *         }
 *       }
 *     }''').substitute(             # <<<<<<<<<<<<<<
 *         name=name,
 *         block_size=block_size,
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_substitute); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 92, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":93
 *       }
 *     }''').substitute(
 *         name=name,             # <<<<<<<<<<<<<<
 *         block_size=block_size,
 *         reduce_type=reduce_type,
 */
  __pyx_t_3 = __Pyx_PyDict_NewPresized(12); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 93, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":94
 *     }''').substitute(
 *         name=name,
 *         block_size=block_size,             # <<<<<<<<<<<<<<
 *         reduce_type=reduce_type,
 *         params=params,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_block_size, __pyx_v_block_size) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":95
 *         name=name,
 *         block_size=block_size,
 *         reduce_type=reduce_type,             # <<<<<<<<<<<<<<
 *         params=params,
 *         identity=identity,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reduce_type, __pyx_v_reduce_type) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":96
 *         block_size=block_size,
 *         reduce_type=reduce_type,
 *         params=params,             # <<<<<<<<<<<<<<
 *         identity=identity,
 *         reduce_expr=reduce_expr,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_params, __pyx_v_params) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":97
 *         reduce_type=reduce_type,
 *         params=params,
 *         identity=identity,             # <<<<<<<<<<<<<<
 *         reduce_expr=reduce_expr,
 *         pre_map_expr=pre_map_expr,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_identity, __pyx_v_identity) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":98
 *         params=params,
 *         identity=identity,
 *         reduce_expr=reduce_expr,             # <<<<<<<<<<<<<<
 *         pre_map_expr=pre_map_expr,
 *         post_map_expr=post_map_expr,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reduce_expr, __pyx_v_reduce_expr) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":99
 *         identity=identity,
 *         reduce_expr=reduce_expr,
 *         pre_map_expr=pre_map_expr,             # <<<<<<<<<<<<<<
 *         post_map_expr=post_map_expr,
 *         type_preamble=type_preamble,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_pre_map_expr, __pyx_v_pre_map_expr) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":100
 *         reduce_expr=reduce_expr,
 *         pre_map_expr=pre_map_expr,
 *         post_map_expr=post_map_expr,             # <<<<<<<<<<<<<<
 *         type_preamble=type_preamble,
 *         input_expr=input_expr,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_post_map_expr, __pyx_v_post_map_expr) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":101
 *         pre_map_expr=pre_map_expr,
 *         post_map_expr=post_map_expr,
 *         type_preamble=type_preamble,             # <<<<<<<<<<<<<<
 *         input_expr=input_expr,
 *         output_expr=output_expr,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_type_preamble, __pyx_v_type_preamble) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":102
 *         post_map_expr=post_map_expr,
 *         type_preamble=type_preamble,
 *         input_expr=input_expr,             # <<<<<<<<<<<<<<
 *         output_expr=output_expr,
 *         preamble=preamble)
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_input_expr, __pyx_v_input_expr) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":103
 *         type_preamble=type_preamble,
 *         input_expr=input_expr,
 *         output_expr=output_expr,             # <<<<<<<<<<<<<<
 *         preamble=preamble)
 *     module = compile_with_cache(module_code, options)
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_output_expr, __pyx_v_output_expr) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":104
 *         input_expr=input_expr,
 *         output_expr=output_expr,
 *         preamble=preamble)             # <<<<<<<<<<<<<<
 *     module = compile_with_cache(module_code, options)
 *     return module.get_function(name)
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_preamble, __pyx_v_preamble) < 0) __PYX_ERR(5, 93, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":92
 *         }
 *       }
 *     }''').substitute(             # <<<<<<<<<<<<<<
 *         name=name,
 *         block_size=block_size,
 */
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 92, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_module_code = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":105
 *         output_expr=output_expr,
 *         preamble=preamble)
 *     module = compile_with_cache(module_code, options)             # <<<<<<<<<<<<<<
 *     return module.get_function(name)
 * 
 */
  if (!(likely(PyString_CheckExact(__pyx_v_module_code))||((__pyx_v_module_code) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_module_code)->tp_name), 0))) __PYX_ERR(5, 105, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_options))||((__pyx_v_options) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_options)->tp_name), 0))) __PYX_ERR(5, 105, __pyx_L1_error)
  __pyx_t_6.__pyx_n = 1;
  __pyx_t_6.options = ((PyObject*)__pyx_v_options);
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(((PyObject*)__pyx_v_module_code), 0, &__pyx_t_6)); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_module = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":106
 *         preamble=preamble)
 *     module = compile_with_cache(module_code, options)
 *     return module.get_function(name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(5, 106, __pyx_L1_error)
  __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *)__pyx_v_module->__pyx_vtab)->get_function(__pyx_v_module, ((PyObject*)__pyx_v_name), 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":10
 * 
 * 
 * cpdef _get_simple_reduction_kernel(             # <<<<<<<<<<<<<<
 *         name, block_size, reduce_type, params, identity,
 *         pre_map_expr, reduce_expr, post_map_expr,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core._get_simple_reduction_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_module_code);
  __Pyx_XDECREF((PyObject *)__pyx_v_module);
  __Pyx_XDECREF(__pyx_v_identity);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_33_get_simple_reduction_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_32_get_simple_reduction_kernel[] = "_get_simple_reduction_kernel(name, block_size, reduce_type, params, identity, pre_map_expr, reduce_expr, post_map_expr, type_preamble, input_expr, output_expr, preamble, options)";
static PyObject *__pyx_pw_4cupy_4core_4core_33_get_simple_reduction_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_block_size = 0;
  PyObject *__pyx_v_reduce_type = 0;
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_identity = 0;
  PyObject *__pyx_v_pre_map_expr = 0;
  PyObject *__pyx_v_reduce_expr = 0;
  PyObject *__pyx_v_post_map_expr = 0;
  PyObject *__pyx_v_type_preamble = 0;
  PyObject *__pyx_v_input_expr = 0;
  PyObject *__pyx_v_output_expr = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_simple_reduction_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_block_size,&__pyx_n_s_reduce_type,&__pyx_n_s_params,&__pyx_n_s_identity,&__pyx_n_s_pre_map_expr,&__pyx_n_s_reduce_expr,&__pyx_n_s_post_map_expr,&__pyx_n_s_type_preamble,&__pyx_n_s_input_expr,&__pyx_n_s_output_expr,&__pyx_n_s_preamble,&__pyx_n_s_options,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,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 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_name)) != 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_block_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 1); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reduce_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 2); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 3); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_identity)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 4); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pre_map_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 5); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reduce_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 6); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_post_map_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 7); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_type_preamble)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 8); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_input_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 9); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_output_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 10); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_preamble)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 11); __PYX_ERR(5, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 12:
        if (likely((values[12] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_options)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, 12); __PYX_ERR(5, 10, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_simple_reduction_kernel") < 0)) __PYX_ERR(5, 10, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 13) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
      values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
      values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
    }
    __pyx_v_name = values[0];
    __pyx_v_block_size = values[1];
    __pyx_v_reduce_type = values[2];
    __pyx_v_params = values[3];
    __pyx_v_identity = values[4];
    __pyx_v_pre_map_expr = values[5];
    __pyx_v_reduce_expr = values[6];
    __pyx_v_post_map_expr = values[7];
    __pyx_v_type_preamble = values[8];
    __pyx_v_input_expr = values[9];
    __pyx_v_output_expr = values[10];
    __pyx_v_preamble = values[11];
    __pyx_v_options = values[12];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_kernel", 1, 13, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 10, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_simple_reduction_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_32_get_simple_reduction_kernel(__pyx_self, __pyx_v_name, __pyx_v_block_size, __pyx_v_reduce_type, __pyx_v_params, __pyx_v_identity, __pyx_v_pre_map_expr, __pyx_v_reduce_expr, __pyx_v_post_map_expr, __pyx_v_type_preamble, __pyx_v_input_expr, __pyx_v_output_expr, __pyx_v_preamble, __pyx_v_options);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_32_get_simple_reduction_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_block_size, PyObject *__pyx_v_reduce_type, PyObject *__pyx_v_params, PyObject *__pyx_v_identity, PyObject *__pyx_v_pre_map_expr, PyObject *__pyx_v_reduce_expr, PyObject *__pyx_v_post_map_expr, PyObject *__pyx_v_type_preamble, PyObject *__pyx_v_input_expr, PyObject *__pyx_v_output_expr, PyObject *__pyx_v_preamble, PyObject *__pyx_v_options) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_simple_reduction_kernel", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_simple_reduction_kernel(__pyx_v_name, __pyx_v_block_size, __pyx_v_reduce_type, __pyx_v_params, __pyx_v_identity, __pyx_v_pre_map_expr, __pyx_v_reduce_expr, __pyx_v_post_map_expr, __pyx_v_type_preamble, __pyx_v_input_expr, __pyx_v_output_expr, __pyx_v_preamble, __pyx_v_options, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_simple_reduction_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":109
 * 
 * 
 * cpdef tuple _get_axis(object axis, Py_ssize_t ndim):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t dim
 *     if axis is None:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_35_get_axis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_axis(PyObject *__pyx_v_axis, Py_ssize_t __pyx_v_ndim, CYTHON_UNUSED int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_dim;
  PyObject *__pyx_v_raxis = NULL;
  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 *);
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  __Pyx_RefNannySetupContext("_get_axis", 0);
  __Pyx_INCREF(__pyx_v_axis);

  /* "cupy/core/reduction.pxi":111
 * cpdef tuple _get_axis(object axis, Py_ssize_t ndim):
 *     cdef Py_ssize_t dim
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         axis = tuple(range(ndim))
 *     elif isinstance(axis, collections.Sequence):
 */
  __pyx_t_1 = (__pyx_v_axis == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/reduction.pxi":112
 *     cdef Py_ssize_t dim
 *     if axis is None:
 *         axis = tuple(range(ndim))             # <<<<<<<<<<<<<<
 *     elif isinstance(axis, collections.Sequence):
 *         axis = tuple(axis)
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":111
 * cpdef tuple _get_axis(object axis, Py_ssize_t ndim):
 *     cdef Py_ssize_t dim
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         axis = tuple(range(ndim))
 *     elif isinstance(axis, collections.Sequence):
 */
    goto __pyx_L3;
  }

  /* "cupy/core/reduction.pxi":113
 *     if axis is None:
 *         axis = tuple(range(ndim))
 *     elif isinstance(axis, collections.Sequence):             # <<<<<<<<<<<<<<
 *         axis = tuple(axis)
 *     else:
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_collections); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Sequence); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_axis, __pyx_t_4); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(5, 113, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":114
 *         axis = tuple(range(ndim))
 *     elif isinstance(axis, collections.Sequence):
 *         axis = tuple(axis)             # <<<<<<<<<<<<<<
 *     else:
 *         axis = axis,
 */
    __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_v_axis); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 114, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":113
 *     if axis is None:
 *         axis = tuple(range(ndim))
 *     elif isinstance(axis, collections.Sequence):             # <<<<<<<<<<<<<<
 *         axis = tuple(axis)
 *     else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/reduction.pxi":116
 *         axis = tuple(axis)
 *     else:
 *         axis = axis,             # <<<<<<<<<<<<<<
 * 
 *     for dim in axis:
 */
  /*else*/ {
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 116, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_axis);
    __Pyx_GIVEREF(__pyx_v_axis);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_axis);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_4);
    __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/reduction.pxi":118
 *         axis = axis,
 * 
 *     for dim in axis:             # <<<<<<<<<<<<<<
 *         if dim < -ndim or dim >= ndim:
 *             raise ValueError('Axis overrun')
 */
  if (likely(PyList_CheckExact(__pyx_v_axis)) || PyTuple_CheckExact(__pyx_v_axis)) {
    __pyx_t_4 = __pyx_v_axis; __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_axis); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 118, __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(5, 118, __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_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(5, 118, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 118, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(5, 118, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 118, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_6(__pyx_t_4);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(5, 118, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 118, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_dim = __pyx_t_7;

    /* "cupy/core/reduction.pxi":119
 * 
 *     for dim in axis:
 *         if dim < -ndim or dim >= ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError('Axis overrun')
 *     axis = tuple(sorted([dim % ndim for dim in axis]))
 */
    __pyx_t_2 = ((__pyx_v_dim < (-__pyx_v_ndim)) != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_dim >= __pyx_v_ndim) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L7_bool_binop_done:;
    if (unlikely(__pyx_t_1)) {

      /* "cupy/core/reduction.pxi":120
 *     for dim in axis:
 *         if dim < -ndim or dim >= ndim:
 *             raise ValueError('Axis overrun')             # <<<<<<<<<<<<<<
 *     axis = tuple(sorted([dim % ndim for dim in axis]))
 *     raxis = tuple([dim for dim in range(ndim) if dim not in axis])
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__74, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 120, __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(5, 120, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":119
 * 
 *     for dim in axis:
 *         if dim < -ndim or dim >= ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError('Axis overrun')
 *     axis = tuple(sorted([dim % ndim for dim in axis]))
 */
    }

    /* "cupy/core/reduction.pxi":118
 *         axis = axis,
 * 
 *     for dim in axis:             # <<<<<<<<<<<<<<
 *         if dim < -ndim or dim >= ndim:
 *             raise ValueError('Axis overrun')
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":121
 *         if dim < -ndim or dim >= ndim:
 *             raise ValueError('Axis overrun')
 *     axis = tuple(sorted([dim % ndim for dim in axis]))             # <<<<<<<<<<<<<<
 *     raxis = tuple([dim for dim in range(ndim) if dim not in axis])
 *     return axis, raxis
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 121, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (likely(PyList_CheckExact(__pyx_v_axis)) || PyTuple_CheckExact(__pyx_v_axis)) {
    __pyx_t_8 = __pyx_v_axis; __Pyx_INCREF(__pyx_t_8); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_axis); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 121, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_8))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(5, 121, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 121, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(5, 121, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 121, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      }
    } else {
      __pyx_t_9 = __pyx_t_6(__pyx_t_8);
      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(5, 121, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_9);
    }
    __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 121, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_dim = __pyx_t_7;
    if (unlikely(__pyx_v_ndim == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(5, 121, __pyx_L1_error)
    }
    __pyx_t_9 = PyInt_FromSsize_t(__Pyx_mod_Py_ssize_t(__pyx_v_dim, __pyx_v_ndim)); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_9))) __PYX_ERR(5, 121, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_4 = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_10 = PyList_Sort(__pyx_t_4); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(5, 121, __pyx_L1_error)
  if (unlikely(__pyx_t_4 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(5, 121, __pyx_L1_error)
  }
  __pyx_t_3 = PyList_AsTuple(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 121, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":122
 *             raise ValueError('Axis overrun')
 *     axis = tuple(sorted([dim % ndim for dim in axis]))
 *     raxis = tuple([dim for dim in range(ndim) if dim not in axis])             # <<<<<<<<<<<<<<
 *     return axis, raxis
 * 
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 122, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __pyx_v_ndim;
  __pyx_t_7 = __pyx_t_5;
  for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_7; __pyx_t_11+=1) {
    __pyx_v_dim = __pyx_t_11;
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_t_4, __pyx_v_axis, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(5, 122, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 122, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_4))) __PYX_ERR(5, 122, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __pyx_t_4 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 122, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_raxis = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":123
 *     axis = tuple(sorted([dim % ndim for dim in axis]))
 *     raxis = tuple([dim for dim in range(ndim) if dim not in axis])
 *     return axis, raxis             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_axis);
  __Pyx_GIVEREF(__pyx_v_axis);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_axis);
  __Pyx_INCREF(__pyx_v_raxis);
  __Pyx_GIVEREF(__pyx_v_raxis);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_raxis);
  __pyx_r = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":109
 * 
 * 
 * cpdef tuple _get_axis(object axis, Py_ssize_t ndim):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t dim
 *     if axis is None:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core._get_axis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_raxis);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_35_get_axis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_34_get_axis[] = "_get_axis(axis, Py_ssize_t ndim) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_35_get_axis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  Py_ssize_t __pyx_v_ndim;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_axis (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_ndim,0};
    PyObject* values[2] = {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  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_axis)) != 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_ndim)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_axis", 1, 2, 2, 1); __PYX_ERR(5, 109, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_axis") < 0)) __PYX_ERR(5, 109, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_axis = values[0];
    __pyx_v_ndim = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_ndim == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 109, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_axis", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 109, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_axis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_34_get_axis(__pyx_self, __pyx_v_axis, __pyx_v_ndim);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_34_get_axis(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_axis, Py_ssize_t __pyx_v_ndim) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_axis", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_axis(__pyx_v_axis, __pyx_v_ndim, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_axis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":126
 * 
 * 
 * cpdef tuple _get_out_shape(             # <<<<<<<<<<<<<<
 *         tuple shape, tuple axis, tuple raxis, bint keepdims):
 *     if keepdims:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_37_get_out_shape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_out_shape(PyObject *__pyx_v_shape, PyObject *__pyx_v_axis, PyObject *__pyx_v_raxis, int __pyx_v_keepdims, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_out_shape = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("_get_out_shape", 0);

  /* "cupy/core/reduction.pxi":128
 * cpdef tuple _get_out_shape(
 *         tuple shape, tuple axis, tuple raxis, bint keepdims):
 *     if keepdims:             # <<<<<<<<<<<<<<
 *         out_shape = list(shape)
 *         for i in axis:
 */
  __pyx_t_1 = (__pyx_v_keepdims != 0);
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":129
 *         tuple shape, tuple axis, tuple raxis, bint keepdims):
 *     if keepdims:
 *         out_shape = list(shape)             # <<<<<<<<<<<<<<
 *         for i in axis:
 *             out_shape[i] = 1
 */
    __pyx_t_2 = PySequence_List(__pyx_v_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_out_shape = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":130
 *     if keepdims:
 *         out_shape = list(shape)
 *         for i in axis:             # <<<<<<<<<<<<<<
 *             out_shape[i] = 1
 *         return tuple(out_shape)
 */
    if (unlikely(__pyx_v_axis == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(5, 130, __pyx_L1_error)
    }
    __pyx_t_2 = __pyx_v_axis; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    for (;;) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(5, 130, __pyx_L1_error)
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 130, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/reduction.pxi":131
 *         out_shape = list(shape)
 *         for i in axis:
 *             out_shape[i] = 1             # <<<<<<<<<<<<<<
 *         return tuple(out_shape)
 *     return tuple([shape[i] for i in raxis])
 */
      if (unlikely(PyObject_SetItem(__pyx_v_out_shape, __pyx_v_i, __pyx_int_1) < 0)) __PYX_ERR(5, 131, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":130
 *     if keepdims:
 *         out_shape = list(shape)
 *         for i in axis:             # <<<<<<<<<<<<<<
 *             out_shape[i] = 1
 *         return tuple(out_shape)
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":132
 *         for i in axis:
 *             out_shape[i] = 1
 *         return tuple(out_shape)             # <<<<<<<<<<<<<<
 *     return tuple([shape[i] for i in raxis])
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyList_AsTuple(__pyx_v_out_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 132, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":128
 * cpdef tuple _get_out_shape(
 *         tuple shape, tuple axis, tuple raxis, bint keepdims):
 *     if keepdims:             # <<<<<<<<<<<<<<
 *         out_shape = list(shape)
 *         for i in axis:
 */
  }

  /* "cupy/core/reduction.pxi":133
 *             out_shape[i] = 1
 *         return tuple(out_shape)
 *     return tuple([shape[i] for i in raxis])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(__pyx_v_raxis == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(5, 133, __pyx_L1_error)
  }
  __pyx_t_4 = __pyx_v_raxis; __Pyx_INCREF(__pyx_t_4); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(5, 133, __pyx_L1_error)
    #else
    __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_5);
    __pyx_t_5 = 0;
    if (unlikely(__pyx_v_shape == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(5, 133, __pyx_L1_error)
    }
    __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_shape, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) __PYX_ERR(5, 133, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":126
 * 
 * 
 * cpdef tuple _get_out_shape(             # <<<<<<<<<<<<<<
 *         tuple shape, tuple axis, tuple raxis, bint keepdims):
 *     if keepdims:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core._get_out_shape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_37_get_out_shape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_36_get_out_shape[] = "_get_out_shape(tuple shape, tuple axis, tuple raxis, bool keepdims) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_37_get_out_shape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_raxis = 0;
  int __pyx_v_keepdims;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_out_shape (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_axis,&__pyx_n_s_raxis,&__pyx_n_s_keepdims,0};
    PyObject* values[4] = {0,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  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_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_out_shape", 1, 4, 4, 1); __PYX_ERR(5, 126, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_raxis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_out_shape", 1, 4, 4, 2); __PYX_ERR(5, 126, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_keepdims)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_out_shape", 1, 4, 4, 3); __PYX_ERR(5, 126, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_out_shape") < 0)) __PYX_ERR(5, 126, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_shape = ((PyObject*)values[0]);
    __pyx_v_axis = ((PyObject*)values[1]);
    __pyx_v_raxis = ((PyObject*)values[2]);
    __pyx_v_keepdims = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_keepdims == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 127, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_out_shape", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 126, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_out_shape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(5, 127, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_axis), (&PyTuple_Type), 1, "axis", 1))) __PYX_ERR(5, 127, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_raxis), (&PyTuple_Type), 1, "raxis", 1))) __PYX_ERR(5, 127, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_36_get_out_shape(__pyx_self, __pyx_v_shape, __pyx_v_axis, __pyx_v_raxis, __pyx_v_keepdims);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_36_get_out_shape(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_shape, PyObject *__pyx_v_axis, PyObject *__pyx_v_raxis, int __pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_out_shape", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_out_shape(__pyx_v_shape, __pyx_v_axis, __pyx_v_raxis, __pyx_v_keepdims, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_out_shape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":136
 * 
 * 
 * cpdef tuple _get_trans_args(list args, tuple trans, tuple shape, tuple params):             # <<<<<<<<<<<<<<
 *     cdef ParameterInfo p
 *     if trans == tuple(range(len(shape))):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_39_get_trans_args(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_trans_args(PyObject *__pyx_v_args, PyObject *__pyx_v_trans, PyObject *__pyx_v_shape, PyObject *__pyx_v_params, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__pyx_v_p = 0;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("_get_trans_args", 0);
  __Pyx_INCREF(__pyx_v_args);
  __Pyx_INCREF(__pyx_v_shape);

  /* "cupy/core/reduction.pxi":138
 * cpdef tuple _get_trans_args(list args, tuple trans, tuple shape, tuple params):
 *     cdef ParameterInfo p
 *     if trans == tuple(range(len(shape))):             # <<<<<<<<<<<<<<
 *         return args, shape
 *     if params is not None:
 */
  if (unlikely(__pyx_v_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(5, 138, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(5, 138, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_trans, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 138, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(5, 138, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/reduction.pxi":139
 *     cdef ParameterInfo p
 *     if trans == tuple(range(len(shape))):
 *         return args, shape             # <<<<<<<<<<<<<<
 *     if params is not None:
 *         for p in params:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 139, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_args);
    __Pyx_GIVEREF(__pyx_v_args);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_args);
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_shape);
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":138
 * cpdef tuple _get_trans_args(list args, tuple trans, tuple shape, tuple params):
 *     cdef ParameterInfo p
 *     if trans == tuple(range(len(shape))):             # <<<<<<<<<<<<<<
 *         return args, shape
 *     if params is not None:
 */
  }

  /* "cupy/core/reduction.pxi":140
 *     if trans == tuple(range(len(shape))):
 *         return args, shape
 *     if params is not None:             # <<<<<<<<<<<<<<
 *         for p in params:
 *             if p.raw:
 */
  __pyx_t_4 = (__pyx_v_params != ((PyObject*)Py_None));
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "cupy/core/reduction.pxi":141
 *         return args, shape
 *     if params is not None:
 *         for p in params:             # <<<<<<<<<<<<<<
 *             if p.raw:
 *                 raise NotImplementedError('Illegal conditions')
 */
    if (unlikely(__pyx_v_params == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(5, 141, __pyx_L1_error)
    }
    __pyx_t_3 = __pyx_v_params; __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_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(5, 141, __pyx_L1_error)
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ParameterInfo))))) __PYX_ERR(5, 141, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_p, ((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_t_2));
      __pyx_t_2 = 0;

      /* "cupy/core/reduction.pxi":142
 *     if params is not None:
 *         for p in params:
 *             if p.raw:             # <<<<<<<<<<<<<<
 *                 raise NotImplementedError('Illegal conditions')
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a
 */
      __pyx_t_5 = (__pyx_v_p->raw != 0);
      if (unlikely(__pyx_t_5)) {

        /* "cupy/core/reduction.pxi":143
 *         for p in params:
 *             if p.raw:
 *                 raise NotImplementedError('Illegal conditions')             # <<<<<<<<<<<<<<
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a
 *             for a in args]
 */
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__75, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 143, __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(5, 143, __pyx_L1_error)

        /* "cupy/core/reduction.pxi":142
 *     if params is not None:
 *         for p in params:
 *             if p.raw:             # <<<<<<<<<<<<<<
 *                 raise NotImplementedError('Illegal conditions')
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a
 */
      }

      /* "cupy/core/reduction.pxi":141
 *         return args, shape
 *     if params is not None:
 *         for p in params:             # <<<<<<<<<<<<<<
 *             if p.raw:
 *                 raise NotImplementedError('Illegal conditions')
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":140
 *     if trans == tuple(range(len(shape))):
 *         return args, shape
 *     if params is not None:             # <<<<<<<<<<<<<<
 *         for p in params:
 *             if p.raw:
 */
  }

  /* "cupy/core/reduction.pxi":144
 *             if p.raw:
 *                 raise NotImplementedError('Illegal conditions')
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a             # <<<<<<<<<<<<<<
 *             for a in args]
 *     shape = tuple([shape[i] for i in trans])
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/reduction.pxi":145
 *                 raise NotImplementedError('Illegal conditions')
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a
 *             for a in args]             # <<<<<<<<<<<<<<
 *     shape = tuple([shape[i] for i in trans])
 *     return args, shape
 */
  if (unlikely(__pyx_v_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(5, 145, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_v_args; __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_6); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(5, 145, __pyx_L1_error)
    #else
    __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 145, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/reduction.pxi":144
 *             if p.raw:
 *                 raise NotImplementedError('Illegal conditions')
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a             # <<<<<<<<<<<<<<
 *             for a in args]
 *     shape = tuple([shape[i] for i in trans])
 */
    __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_5 != 0)) {
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 144, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (!__pyx_t_9) {
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_trans); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 144, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_trans};
          __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 144, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_trans};
          __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 144, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else
        #endif
        {
          __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(5, 144, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
          __Pyx_INCREF(__pyx_v_trans);
          __Pyx_GIVEREF(__pyx_v_trans);
          PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_trans);
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 144, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_6 = __pyx_t_7;
      __pyx_t_7 = 0;
    } else {
      __Pyx_INCREF(__pyx_v_a);
      __pyx_t_6 = __pyx_v_a;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_6))) __PYX_ERR(5, 144, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/reduction.pxi":145
 *                 raise NotImplementedError('Illegal conditions')
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a
 *             for a in args]             # <<<<<<<<<<<<<<
 *     shape = tuple([shape[i] for i in trans])
 *     return args, shape
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_args, ((PyObject*)__pyx_t_3));
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":146
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a
 *             for a in args]
 *     shape = tuple([shape[i] for i in trans])             # <<<<<<<<<<<<<<
 *     return args, shape
 * 
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (unlikely(__pyx_v_trans == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(5, 146, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_v_trans; __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_6); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(5, 146, __pyx_L1_error)
    #else
    __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_6);
    __pyx_t_6 = 0;
    if (unlikely(__pyx_v_shape == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(5, 146, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_shape, __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_6))) __PYX_ERR(5, 146, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __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(5, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_shape, ((PyObject*)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":147
 *             for a in args]
 *     shape = tuple([shape[i] for i in trans])
 *     return args, shape             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_args);
  __Pyx_GIVEREF(__pyx_v_args);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_args);
  __Pyx_INCREF(__pyx_v_shape);
  __Pyx_GIVEREF(__pyx_v_shape);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_shape);
  __pyx_r = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":136
 * 
 * 
 * cpdef tuple _get_trans_args(list args, tuple trans, tuple shape, tuple params):             # <<<<<<<<<<<<<<
 *     cdef ParameterInfo p
 *     if trans == tuple(range(len(shape))):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.core.core._get_trans_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_39_get_trans_args(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_38_get_trans_args[] = "_get_trans_args(list args, tuple trans, tuple shape, tuple params) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_39_get_trans_args(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_trans = 0;
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_trans_args (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_args,&__pyx_n_s_trans,&__pyx_n_s_shape,&__pyx_n_s_params,0};
    PyObject* values[4] = {0,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  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_args)) != 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_trans)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_trans_args", 1, 4, 4, 1); __PYX_ERR(5, 136, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_trans_args", 1, 4, 4, 2); __PYX_ERR(5, 136, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_trans_args", 1, 4, 4, 3); __PYX_ERR(5, 136, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_trans_args") < 0)) __PYX_ERR(5, 136, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_args = ((PyObject*)values[0]);
    __pyx_v_trans = ((PyObject*)values[1]);
    __pyx_v_shape = ((PyObject*)values[2]);
    __pyx_v_params = ((PyObject*)values[3]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_trans_args", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 136, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_trans_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args), (&PyList_Type), 1, "args", 1))) __PYX_ERR(5, 136, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_trans), (&PyTuple_Type), 1, "trans", 1))) __PYX_ERR(5, 136, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(5, 136, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_params), (&PyTuple_Type), 1, "params", 1))) __PYX_ERR(5, 136, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_38_get_trans_args(__pyx_self, __pyx_v_args, __pyx_v_trans, __pyx_v_shape, __pyx_v_params);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_38_get_trans_args(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args, PyObject *__pyx_v_trans, PyObject *__pyx_v_shape, PyObject *__pyx_v_params) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_trans_args", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_trans_args(__pyx_v_args, __pyx_v_trans, __pyx_v_shape, __pyx_v_params, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_trans_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":150
 * 
 * 
 * cpdef list _get_inout_args(             # <<<<<<<<<<<<<<
 *         list in_args, list out_args, Indexer in_indexer, Indexer out_indexer,
 *         object out_clp2_size, tuple params, bint reduce_dims):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_41_get_inout_args(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_inout_args(PyObject *__pyx_v_in_args, PyObject *__pyx_v_out_args, struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_in_indexer, struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_out_indexer, PyObject *__pyx_v_out_clp2_size, PyObject *__pyx_v_params, int __pyx_v_reduce_dims, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_in_shape = NULL;
  PyObject *__pyx_v_out_shape = NULL;
  PyObject *__pyx_v_args = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("_get_inout_args", 0);
  __Pyx_INCREF(__pyx_v_in_args);
  __Pyx_INCREF(__pyx_v_out_args);

  /* "cupy/core/reduction.pxi":153
 *         list in_args, list out_args, Indexer in_indexer, Indexer out_indexer,
 *         object out_clp2_size, tuple params, bint reduce_dims):
 *     if reduce_dims:             # <<<<<<<<<<<<<<
 *         in_args, in_shape = _reduce_dims(
 *             in_args, params, in_indexer.shape)
 */
  __pyx_t_1 = (__pyx_v_reduce_dims != 0);
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":155
 *     if reduce_dims:
 *         in_args, in_shape = _reduce_dims(
 *             in_args, params, in_indexer.shape)             # <<<<<<<<<<<<<<
 *         out_args, out_shape = _reduce_dims(
 *             out_args, params[len(in_args):], out_indexer.shape)
 */
    __pyx_t_2 = __pyx_v_in_indexer->shape;
    __Pyx_INCREF(__pyx_t_2);

    /* "cupy/core/reduction.pxi":154
 *         object out_clp2_size, tuple params, bint reduce_dims):
 *     if reduce_dims:
 *         in_args, in_shape = _reduce_dims(             # <<<<<<<<<<<<<<
 *             in_args, params, in_indexer.shape)
 *         out_args, out_shape = _reduce_dims(
 */
    __pyx_t_3 = __pyx_f_4cupy_4core_4core__reduce_dims(__pyx_v_in_args, __pyx_v_params, ((PyObject*)__pyx_t_2), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    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(5, 154, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 154, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 154, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 154, __pyx_L1_error)
    }
    if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(5, 154, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_in_args, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_v_in_shape = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":157
 *             in_args, params, in_indexer.shape)
 *         out_args, out_shape = _reduce_dims(
 *             out_args, params[len(in_args):], out_indexer.shape)             # <<<<<<<<<<<<<<
 *         in_indexer.shape = in_shape
 *         out_indexer.shape = out_shape
 */
    if (unlikely(__pyx_v_params == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(5, 157, __pyx_L1_error)
    }
    if (unlikely(__pyx_v_in_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(5, 157, __pyx_L1_error)
    }
    __pyx_t_5 = PyList_GET_SIZE(__pyx_v_in_args); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(5, 157, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyTuple_GetSlice(__pyx_v_params, __pyx_t_5, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __pyx_v_out_indexer->shape;
    __Pyx_INCREF(__pyx_t_4);

    /* "cupy/core/reduction.pxi":156
 *         in_args, in_shape = _reduce_dims(
 *             in_args, params, in_indexer.shape)
 *         out_args, out_shape = _reduce_dims(             # <<<<<<<<<<<<<<
 *             out_args, params[len(in_args):], out_indexer.shape)
 *         in_indexer.shape = in_shape
 */
    __pyx_t_2 = __pyx_f_4cupy_4core_4core__reduce_dims(__pyx_v_out_args, ((PyObject*)__pyx_t_3), ((PyObject*)__pyx_t_4), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    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(5, 156, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      #else
      __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 156, __pyx_L1_error)
    }
    if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(5, 156, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;
    __pyx_v_out_shape = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":158
 *         out_args, out_shape = _reduce_dims(
 *             out_args, params[len(in_args):], out_indexer.shape)
 *         in_indexer.shape = in_shape             # <<<<<<<<<<<<<<
 *         out_indexer.shape = out_shape
 *     args = in_args + out_args + [in_indexer, out_indexer,
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v_in_shape))||((__pyx_v_in_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_in_shape)->tp_name), 0))) __PYX_ERR(5, 158, __pyx_L1_error)
    __pyx_t_2 = __pyx_v_in_shape;
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_in_indexer->shape);
    __Pyx_DECREF(__pyx_v_in_indexer->shape);
    __pyx_v_in_indexer->shape = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":159
 *             out_args, params[len(in_args):], out_indexer.shape)
 *         in_indexer.shape = in_shape
 *         out_indexer.shape = out_shape             # <<<<<<<<<<<<<<
 *     args = in_args + out_args + [in_indexer, out_indexer,
 *                                  numpy.int32(out_clp2_size)]
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v_out_shape))||((__pyx_v_out_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_out_shape)->tp_name), 0))) __PYX_ERR(5, 159, __pyx_L1_error)
    __pyx_t_2 = __pyx_v_out_shape;
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_out_indexer->shape);
    __Pyx_DECREF(__pyx_v_out_indexer->shape);
    __pyx_v_out_indexer->shape = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":153
 *         list in_args, list out_args, Indexer in_indexer, Indexer out_indexer,
 *         object out_clp2_size, tuple params, bint reduce_dims):
 *     if reduce_dims:             # <<<<<<<<<<<<<<
 *         in_args, in_shape = _reduce_dims(
 *             in_args, params, in_indexer.shape)
 */
  }

  /* "cupy/core/reduction.pxi":160
 *         in_indexer.shape = in_shape
 *         out_indexer.shape = out_shape
 *     args = in_args + out_args + [in_indexer, out_indexer,             # <<<<<<<<<<<<<<
 *                                  numpy.int32(out_clp2_size)]
 *     return args
 */
  __pyx_t_2 = PyNumber_Add(__pyx_v_in_args, __pyx_v_out_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":161
 *         out_indexer.shape = out_shape
 *     args = in_args + out_args + [in_indexer, out_indexer,
 *                                  numpy.int32(out_clp2_size)]             # <<<<<<<<<<<<<<
 *     return args
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_out_clp2_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 161, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_out_clp2_size};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 161, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_out_clp2_size};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 161, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 161, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(__pyx_v_out_clp2_size);
      __Pyx_GIVEREF(__pyx_v_out_clp2_size);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_out_clp2_size);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 161, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":160
 *         in_indexer.shape = in_shape
 *         out_indexer.shape = out_shape
 *     args = in_args + out_args + [in_indexer, out_indexer,             # <<<<<<<<<<<<<<
 *                                  numpy.int32(out_clp2_size)]
 *     return args
 */
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_v_in_indexer));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_in_indexer));
  PyList_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_in_indexer));
  __Pyx_INCREF(((PyObject *)__pyx_v_out_indexer));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_out_indexer));
  PyList_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_out_indexer));
  __Pyx_GIVEREF(__pyx_t_3);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_args = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":162
 *     args = in_args + out_args + [in_indexer, out_indexer,
 *                                  numpy.int32(out_clp2_size)]
 *     return args             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_args);
  __pyx_r = __pyx_v_args;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":150
 * 
 * 
 * cpdef list _get_inout_args(             # <<<<<<<<<<<<<<
 *         list in_args, list out_args, Indexer in_indexer, Indexer out_indexer,
 *         object out_clp2_size, tuple params, bint reduce_dims):
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core._get_inout_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_in_shape);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_in_args);
  __Pyx_XDECREF(__pyx_v_out_args);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_41_get_inout_args(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_40_get_inout_args[] = "_get_inout_args(list in_args, list out_args, Indexer in_indexer, Indexer out_indexer, out_clp2_size, tuple params, bool reduce_dims) -> list";
static PyObject *__pyx_pw_4cupy_4core_4core_41_get_inout_args(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_in_args = 0;
  PyObject *__pyx_v_out_args = 0;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_in_indexer = 0;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_out_indexer = 0;
  PyObject *__pyx_v_out_clp2_size = 0;
  PyObject *__pyx_v_params = 0;
  int __pyx_v_reduce_dims;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_inout_args (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_args,&__pyx_n_s_out_args,&__pyx_n_s_in_indexer,&__pyx_n_s_out_indexer,&__pyx_n_s_out_clp2_size,&__pyx_n_s_params,&__pyx_n_s_reduce_dims,0};
    PyObject* values[7] = {0,0,0,0,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  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_in_args)) != 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_out_args)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_inout_args", 1, 7, 7, 1); __PYX_ERR(5, 150, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_in_indexer)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_inout_args", 1, 7, 7, 2); __PYX_ERR(5, 150, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out_indexer)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_inout_args", 1, 7, 7, 3); __PYX_ERR(5, 150, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out_clp2_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_inout_args", 1, 7, 7, 4); __PYX_ERR(5, 150, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_inout_args", 1, 7, 7, 5); __PYX_ERR(5, 150, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reduce_dims)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_inout_args", 1, 7, 7, 6); __PYX_ERR(5, 150, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_inout_args") < 0)) __PYX_ERR(5, 150, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
    }
    __pyx_v_in_args = ((PyObject*)values[0]);
    __pyx_v_out_args = ((PyObject*)values[1]);
    __pyx_v_in_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)values[2]);
    __pyx_v_out_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)values[3]);
    __pyx_v_out_clp2_size = values[4];
    __pyx_v_params = ((PyObject*)values[5]);
    __pyx_v_reduce_dims = __Pyx_PyObject_IsTrue(values[6]); if (unlikely((__pyx_v_reduce_dims == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 152, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_inout_args", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 150, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_inout_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_in_args), (&PyList_Type), 1, "in_args", 1))) __PYX_ERR(5, 151, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_args), (&PyList_Type), 1, "out_args", 1))) __PYX_ERR(5, 151, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_in_indexer), __pyx_ptype_4cupy_4core_4core_Indexer, 1, "in_indexer", 0))) __PYX_ERR(5, 151, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_indexer), __pyx_ptype_4cupy_4core_4core_Indexer, 1, "out_indexer", 0))) __PYX_ERR(5, 151, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_params), (&PyTuple_Type), 1, "params", 1))) __PYX_ERR(5, 152, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_40_get_inout_args(__pyx_self, __pyx_v_in_args, __pyx_v_out_args, __pyx_v_in_indexer, __pyx_v_out_indexer, __pyx_v_out_clp2_size, __pyx_v_params, __pyx_v_reduce_dims);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_40_get_inout_args(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_in_args, PyObject *__pyx_v_out_args, struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_in_indexer, struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_out_indexer, PyObject *__pyx_v_out_clp2_size, PyObject *__pyx_v_params, int __pyx_v_reduce_dims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_inout_args", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_inout_args(__pyx_v_in_args, __pyx_v_out_args, __pyx_v_in_indexer, __pyx_v_out_indexer, __pyx_v_out_clp2_size, __pyx_v_params, __pyx_v_reduce_dims, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_inout_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":166
 * 
 * @util.memoize(for_each_device=True)
 * def _get_simple_reduction_function(             # <<<<<<<<<<<<<<
 *         routine, params, args_info, in_arg_dtype, out_arg_dtype, out_types,
 *         name, block_size, identity, input_expr, output_expr, _preamble,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_43_get_simple_reduction_function(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_42_get_simple_reduction_function[] = "_get_simple_reduction_function(routine, params, args_info, in_arg_dtype, out_arg_dtype, out_types, name, block_size, identity, input_expr, output_expr, _preamble, options)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_43_get_simple_reduction_function = {"_get_simple_reduction_function", (PyCFunction)__pyx_pw_4cupy_4core_4core_43_get_simple_reduction_function, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_42_get_simple_reduction_function};
static PyObject *__pyx_pw_4cupy_4core_4core_43_get_simple_reduction_function(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_routine = 0;
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_args_info = 0;
  PyObject *__pyx_v_in_arg_dtype = 0;
  PyObject *__pyx_v_out_arg_dtype = 0;
  PyObject *__pyx_v_out_types = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_block_size = 0;
  PyObject *__pyx_v_identity = 0;
  PyObject *__pyx_v_input_expr = 0;
  PyObject *__pyx_v_output_expr = 0;
  PyObject *__pyx_v__preamble = 0;
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_simple_reduction_function (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_routine,&__pyx_n_s_params,&__pyx_n_s_args_info,&__pyx_n_s_in_arg_dtype,&__pyx_n_s_out_arg_dtype,&__pyx_n_s_out_types,&__pyx_n_s_name,&__pyx_n_s_block_size,&__pyx_n_s_identity,&__pyx_n_s_input_expr,&__pyx_n_s_output_expr,&__pyx_n_s_preamble_2,&__pyx_n_s_options,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,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 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_routine)) != 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_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 1); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args_info)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 2); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_in_arg_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 3); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out_arg_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 4); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out_types)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 5); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 6); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_block_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 7); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_identity)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 8); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_input_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 9); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_output_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 10); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_preamble_2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 11); __PYX_ERR(5, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 12:
        if (likely((values[12] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_options)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, 12); __PYX_ERR(5, 166, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_simple_reduction_function") < 0)) __PYX_ERR(5, 166, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 13) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
      values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
      values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
    }
    __pyx_v_routine = values[0];
    __pyx_v_params = values[1];
    __pyx_v_args_info = values[2];
    __pyx_v_in_arg_dtype = values[3];
    __pyx_v_out_arg_dtype = values[4];
    __pyx_v_out_types = values[5];
    __pyx_v_name = values[6];
    __pyx_v_block_size = values[7];
    __pyx_v_identity = values[8];
    __pyx_v_input_expr = values[9];
    __pyx_v_output_expr = values[10];
    __pyx_v__preamble = values[11];
    __pyx_v_options = values[12];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_simple_reduction_function", 1, 13, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 166, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_simple_reduction_function", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_42_get_simple_reduction_function(__pyx_self, __pyx_v_routine, __pyx_v_params, __pyx_v_args_info, __pyx_v_in_arg_dtype, __pyx_v_out_arg_dtype, __pyx_v_out_types, __pyx_v_name, __pyx_v_block_size, __pyx_v_identity, __pyx_v_input_expr, __pyx_v_output_expr, __pyx_v__preamble, __pyx_v_options);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_42_get_simple_reduction_function(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_routine, PyObject *__pyx_v_params, PyObject *__pyx_v_args_info, PyObject *__pyx_v_in_arg_dtype, PyObject *__pyx_v_out_arg_dtype, PyObject *__pyx_v_out_types, PyObject *__pyx_v_name, PyObject *__pyx_v_block_size, PyObject *__pyx_v_identity, PyObject *__pyx_v_input_expr, PyObject *__pyx_v_output_expr, PyObject *__pyx_v__preamble, PyObject *__pyx_v_options) {
  PyObject *__pyx_v_reduce_type = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_type_preamble = NULL;
  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;
  __Pyx_RefNannySetupContext("_get_simple_reduction_function", 0);
  __Pyx_INCREF(__pyx_v_params);

  /* "cupy/core/reduction.pxi":170
 *         name, block_size, identity, input_expr, output_expr, _preamble,
 *         options):
 *     reduce_type = routine[3]             # <<<<<<<<<<<<<<
 *     if reduce_type is None:
 *         reduce_type = _get_typename(out_types[0])
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_routine, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_reduce_type = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":171
 *         options):
 *     reduce_type = routine[3]
 *     if reduce_type is None:             # <<<<<<<<<<<<<<
 *         reduce_type = _get_typename(out_types[0])
 * 
 */
  __pyx_t_2 = (__pyx_v_reduce_type == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/reduction.pxi":172
 *     reduce_type = routine[3]
 *     if reduce_type is None:
 *         reduce_type = _get_typename(out_types[0])             # <<<<<<<<<<<<<<
 * 
 *     t = (_get_typename(in_arg_dtype), _get_typename(out_arg_dtype))
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_out_types, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_t_1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_reduce_type, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":171
 *         options):
 *     reduce_type = routine[3]
 *     if reduce_type is None:             # <<<<<<<<<<<<<<
 *         reduce_type = _get_typename(out_types[0])
 * 
 */
  }

  /* "cupy/core/reduction.pxi":174
 *         reduce_type = _get_typename(out_types[0])
 * 
 *     t = (_get_typename(in_arg_dtype), _get_typename(out_arg_dtype))             # <<<<<<<<<<<<<<
 *     type_preamble = 'typedef %s type_in0_raw; typedef %s type_out0_raw;' % t
 * 
 */
  __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_in_arg_dtype, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_out_arg_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 174, __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_t_4 = 0;
  __pyx_t_1 = 0;
  __pyx_v_t = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":175
 * 
 *     t = (_get_typename(in_arg_dtype), _get_typename(out_arg_dtype))
 *     type_preamble = 'typedef %s type_in0_raw; typedef %s type_out0_raw;' % t             # <<<<<<<<<<<<<<
 * 
 *     params = _get_kernel_params(params, args_info)
 */
  __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_typedef_s_type_in0_raw_typedef_s, __pyx_v_t); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_type_preamble = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":177
 *     type_preamble = 'typedef %s type_in0_raw; typedef %s type_out0_raw;' % t
 * 
 *     params = _get_kernel_params(params, args_info)             # <<<<<<<<<<<<<<
 *     return _get_simple_reduction_kernel(
 *         name, block_size, reduce_type, params, identity,
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_params))||((__pyx_v_params) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_params)->tp_name), 0))) __PYX_ERR(5, 177, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_args_info))||((__pyx_v_args_info) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args_info)->tp_name), 0))) __PYX_ERR(5, 177, __pyx_L1_error)
  __pyx_t_5 = __pyx_f_4cupy_4core_4core__get_kernel_params(((PyObject*)__pyx_v_params), ((PyObject*)__pyx_v_args_info), 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF_SET(__pyx_v_params, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":178
 * 
 *     params = _get_kernel_params(params, args_info)
 *     return _get_simple_reduction_kernel(             # <<<<<<<<<<<<<<
 *         name, block_size, reduce_type, params, identity,
 *         routine[0], routine[1], routine[2],
 */
  __Pyx_XDECREF(__pyx_r);

  /* "cupy/core/reduction.pxi":180
 *     return _get_simple_reduction_kernel(
 *         name, block_size, reduce_type, params, identity,
 *         routine[0], routine[1], routine[2],             # <<<<<<<<<<<<<<
 *         type_preamble, input_expr, output_expr, _preamble, options)
 * 
 */
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_routine, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_routine, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_routine, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/reduction.pxi":178
 * 
 *     params = _get_kernel_params(params, args_info)
 *     return _get_simple_reduction_kernel(             # <<<<<<<<<<<<<<
 *         name, block_size, reduce_type, params, identity,
 *         routine[0], routine[1], routine[2],
 */
  __pyx_t_6 = __pyx_f_4cupy_4core_4core__get_simple_reduction_kernel(__pyx_v_name, __pyx_v_block_size, __pyx_v_reduce_type, __pyx_v_params, __pyx_v_identity, __pyx_t_5, __pyx_t_1, __pyx_t_4, __pyx_v_type_preamble, __pyx_v_input_expr, __pyx_v_output_expr, __pyx_v__preamble, __pyx_v_options, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":166
 * 
 * @util.memoize(for_each_device=True)
 * def _get_simple_reduction_function(             # <<<<<<<<<<<<<<
 *         routine, params, args_info, in_arg_dtype, out_arg_dtype, out_types,
 *         name, block_size, identity, input_expr, output_expr, _preamble,
 */

  /* 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("cupy.core.core._get_simple_reduction_function", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_reduce_type);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_type_preamble);
  __Pyx_XDECREF(__pyx_v_params);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":188
 *     _block_size = 512
 * 
 *     def __init__(self, name, ops, identity, preamble):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self._ops = ops
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_25simple_reduction_function_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_25simple_reduction_function___init__[] = "simple_reduction_function.__init__(self, name, ops, identity, preamble)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_25simple_reduction_function_1__init__ = {"__init__", (PyCFunction)__pyx_pw_4cupy_4core_4core_25simple_reduction_function_1__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_25simple_reduction_function___init__};
static PyObject *__pyx_pw_4cupy_4core_4core_25simple_reduction_function_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_ops = 0;
  PyObject *__pyx_v_identity = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_name,&__pyx_n_s_ops,&__pyx_n_s_identity,&__pyx_n_s_preamble,0};
    PyObject* values[5] = {0,0,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  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_self)) != 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("__init__", 1, 5, 5, 1); __PYX_ERR(5, 188, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ops)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); __PYX_ERR(5, 188, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_identity)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); __PYX_ERR(5, 188, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_preamble)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); __PYX_ERR(5, 188, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(5, 188, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_self = values[0];
    __pyx_v_name = values[1];
    __pyx_v_ops = values[2];
    __pyx_v_identity = values[3];
    __pyx_v_preamble = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 188, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.simple_reduction_function.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_25simple_reduction_function___init__(__pyx_self, __pyx_v_self, __pyx_v_name, __pyx_v_ops, __pyx_v_identity, __pyx_v_preamble);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_25simple_reduction_function___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_ops, PyObject *__pyx_v_identity, PyObject *__pyx_v_preamble) {
  PyObject *__pyx_v_in_params = NULL;
  PyObject *__pyx_v_out_params = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/reduction.pxi":189
 * 
 *     def __init__(self, name, ops, identity, preamble):
 *         self.name = name             # <<<<<<<<<<<<<<
 *         self._ops = ops
 *         self.identity = identity
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(5, 189, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":190
 *     def __init__(self, name, ops, identity, preamble):
 *         self.name = name
 *         self._ops = ops             # <<<<<<<<<<<<<<
 *         self.identity = identity
 *         self._preamble = preamble
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_ops_2, __pyx_v_ops) < 0) __PYX_ERR(5, 190, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":191
 *         self.name = name
 *         self._ops = ops
 *         self.identity = identity             # <<<<<<<<<<<<<<
 *         self._preamble = preamble
 *         self.nin = 1
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_identity, __pyx_v_identity) < 0) __PYX_ERR(5, 191, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":192
 *         self._ops = ops
 *         self.identity = identity
 *         self._preamble = preamble             # <<<<<<<<<<<<<<
 *         self.nin = 1
 *         self.nout = 1
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_preamble_2, __pyx_v_preamble) < 0) __PYX_ERR(5, 192, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":193
 *         self.identity = identity
 *         self._preamble = preamble
 *         self.nin = 1             # <<<<<<<<<<<<<<
 *         self.nout = 1
 *         in_params = _get_param_info('T in0', True)
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nin, __pyx_int_1) < 0) __PYX_ERR(5, 193, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":194
 *         self._preamble = preamble
 *         self.nin = 1
 *         self.nout = 1             # <<<<<<<<<<<<<<
 *         in_params = _get_param_info('T in0', True)
 *         out_params = _get_param_info('T out0', False)
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nout, __pyx_int_1) < 0) __PYX_ERR(5, 194, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":195
 *         self.nin = 1
 *         self.nout = 1
 *         in_params = _get_param_info('T in0', True)             # <<<<<<<<<<<<<<
 *         out_params = _get_param_info('T out0', False)
 *         self._params = (
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_in_params = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":196
 *         self.nout = 1
 *         in_params = _get_param_info('T in0', True)
 *         out_params = _get_param_info('T out0', False)             # <<<<<<<<<<<<<<
 *         self._params = (
 *             in_params + out_params +
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_out_params = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":198
 *         out_params = _get_param_info('T out0', False)
 *         self._params = (
 *             in_params + out_params +             # <<<<<<<<<<<<<<
 *             _get_param_info(
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +
 */
  __pyx_t_1 = PyNumber_Add(__pyx_v_in_params, __pyx_v_out_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":199
 *         self._params = (
 *             in_params + out_params +
 *             _get_param_info(             # <<<<<<<<<<<<<<
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":200
 *             in_params + out_params +
 *             _get_param_info(
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +             # <<<<<<<<<<<<<<
 *             _get_param_info('int32 _block_stride', True))
 *         self._input_expr = 'const type_in0_raw in0 = _raw_in0[_in_ind.get()];'
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":198
 *         out_params = _get_param_info('T out0', False)
 *         self._params = (
 *             in_params + out_params +             # <<<<<<<<<<<<<<
 *             _get_param_info(
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +
 */
  __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":201
 *             _get_param_info(
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))             # <<<<<<<<<<<<<<
 *         self._input_expr = 'const type_in0_raw in0 = _raw_in0[_in_ind.get()];'
 *         self._output_expr = 'type_out0_raw &out0 = _raw_out0[_out_ind.get()];'
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":200
 *             in_params + out_params +
 *             _get_param_info(
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +             # <<<<<<<<<<<<<<
 *             _get_param_info('int32 _block_stride', True))
 *         self._input_expr = 'const type_in0_raw in0 = _raw_in0[_in_ind.get()];'
 */
  __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":197
 *         in_params = _get_param_info('T in0', True)
 *         out_params = _get_param_info('T out0', False)
 *         self._params = (             # <<<<<<<<<<<<<<
 *             in_params + out_params +
 *             _get_param_info(
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_params_2, __pyx_t_3) < 0) __PYX_ERR(5, 197, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":202
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))
 *         self._input_expr = 'const type_in0_raw in0 = _raw_in0[_in_ind.get()];'             # <<<<<<<<<<<<<<
 *         self._output_expr = 'type_out0_raw &out0 = _raw_out0[_out_ind.get()];'
 *         self._routine_cache = {}
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_input_expr_2, __pyx_kp_s_const_type_in0_raw_in0__raw_in0) < 0) __PYX_ERR(5, 202, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":203
 *             _get_param_info('int32 _block_stride', True))
 *         self._input_expr = 'const type_in0_raw in0 = _raw_in0[_in_ind.get()];'
 *         self._output_expr = 'type_out0_raw &out0 = _raw_out0[_out_ind.get()];'             # <<<<<<<<<<<<<<
 *         self._routine_cache = {}
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_output_expr_2, __pyx_kp_s_type_out0_raw_out0__raw_out0__ou) < 0) __PYX_ERR(5, 203, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":204
 *         self._input_expr = 'const type_in0_raw in0 = _raw_in0[_in_ind.get()];'
 *         self._output_expr = 'type_out0_raw &out0 = _raw_out0[_out_ind.get()];'
 *         self._routine_cache = {}             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,
 */
  __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_routine_cache, __pyx_t_3) < 0) __PYX_ERR(5, 204, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":188
 *     _block_size = 512
 * 
 *     def __init__(self, name, ops, identity, preamble):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self._ops = ops
 */

  /* 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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.simple_reduction_function.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_in_params);
  __Pyx_XDECREF(__pyx_v_out_params);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":206
 *         self._routine_cache = {}
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,             # <<<<<<<<<<<<<<
 *                  bint keepdims=False):
 *         cdef list in_args, out_args
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_25simple_reduction_function_3__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_25simple_reduction_function_2__call__[] = "simple_reduction_function.__call__(self, ndarray a, axis=None, dtype=None, ndarray out=None, bool keepdims=False)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_25simple_reduction_function_3__call__ = {"__call__", (PyCFunction)__pyx_pw_4cupy_4core_4core_25simple_reduction_function_3__call__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_25simple_reduction_function_2__call__};
static PyObject *__pyx_pw_4cupy_4core_4core_25simple_reduction_function_3__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = 0;
  int __pyx_v_keepdims;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_a,&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_keepdims,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[2] = ((PyObject *)((PyObject *)Py_None));
    values[3] = ((PyObject *)((PyObject *)Py_None));
    values[4] = (PyObject *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_self)) != 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_a)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 6, 1); __PYX_ERR(5, 206, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          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_out);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) __PYX_ERR(5, 206, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_axis = values[2];
    __pyx_v_dtype = values[3];
    __pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
    if (values[5]) {
      __pyx_v_keepdims = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_keepdims == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 207, __pyx_L3_error)
    } else {

      /* "cupy/core/reduction.pxi":207
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,
 *                  bint keepdims=False):             # <<<<<<<<<<<<<<
 *         cdef list in_args, out_args
 *         cdef tuple in_sahpe, laxis, raxis
 */
      __pyx_v_keepdims = ((int)((int)0));
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 206, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.simple_reduction_function.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(5, 206, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(5, 206, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_25simple_reduction_function_2__call__(__pyx_self, __pyx_v_self, __pyx_v_a, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims);

  /* "cupy/core/reduction.pxi":206
 *         self._routine_cache = {}
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,             # <<<<<<<<<<<<<<
 *                  bint keepdims=False):
 *         cdef list in_args, out_args
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_25simple_reduction_function_2__call__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out, int __pyx_v_keepdims) {
  PyObject *__pyx_v_in_args = 0;
  PyObject *__pyx_v_out_args = 0;
  PyObject *__pyx_v_laxis = 0;
  PyObject *__pyx_v_raxis = 0;
  PyObject *__pyx_v_a_shape = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_v_routine = NULL;
  PyObject *__pyx_v_out_shape = NULL;
  PyObject *__pyx_v_in_shape = NULL;
  PyObject *__pyx_v_block_size = NULL;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_in_indexer = NULL;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_out_indexer = NULL;
  PyObject *__pyx_v_clp2_count = NULL;
  PyObject *__pyx_v_block_stride = NULL;
  PyObject *__pyx_v_inout_args = NULL;
  PyObject *__pyx_v_args_info = NULL;
  PyObject *__pyx_v_kern = NULL;
  PyObject *__pyx_v_shared_mem = NULL;
  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;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  long __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  __Pyx_RefNannySetupContext("__call__", 0);
  __Pyx_INCREF(__pyx_v_axis);
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/reduction.pxi":210
 *         cdef list in_args, out_args
 *         cdef tuple in_sahpe, laxis, raxis
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             dtype = get_dtype(dtype).type
 * 
 */
  __pyx_t_1 = (__pyx_v_dtype != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/reduction.pxi":211
 *         cdef tuple in_sahpe, laxis, raxis
 *         if dtype is not None:
 *             dtype = get_dtype(dtype).type             # <<<<<<<<<<<<<<
 * 
 *         in_args = [a]
 */
    __pyx_t_3 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 211, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 211, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":210
 *         cdef list in_args, out_args
 *         cdef tuple in_sahpe, laxis, raxis
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             dtype = get_dtype(dtype).type
 * 
 */
  }

  /* "cupy/core/reduction.pxi":213
 *             dtype = get_dtype(dtype).type
 * 
 *         in_args = [a]             # <<<<<<<<<<<<<<
 *         a_shape = a.shape
 *         if out is None:
 */
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_a));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_a));
  __pyx_v_in_args = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":214
 * 
 *         in_args = [a]
 *         a_shape = a.shape             # <<<<<<<<<<<<<<
 *         if out is None:
 *             _preprocess_args((a,))
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 214, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_a_shape = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":215
 *         in_args = [a]
 *         a_shape = a.shape
 *         if out is None:             # <<<<<<<<<<<<<<
 *             _preprocess_args((a,))
 *             out_args = []
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_out) == Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":216
 *         a_shape = a.shape
 *         if out is None:
 *             _preprocess_args((a,))             # <<<<<<<<<<<<<<
 *             out_args = []
 *         else:
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 216, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_a));
    __pyx_t_3 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_t_4, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 216, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":217
 *         if out is None:
 *             _preprocess_args((a,))
 *             out_args = []             # <<<<<<<<<<<<<<
 *         else:
 *             _preprocess_args((a, out))
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 217, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_out_args = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":215
 *         in_args = [a]
 *         a_shape = a.shape
 *         if out is None:             # <<<<<<<<<<<<<<
 *             _preprocess_args((a,))
 *             out_args = []
 */
    goto __pyx_L4;
  }

  /* "cupy/core/reduction.pxi":219
 *             out_args = []
 *         else:
 *             _preprocess_args((a, out))             # <<<<<<<<<<<<<<
 *             out_args = [out]
 * 
 */
  /*else*/ {
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 219, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_a));
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
    PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_out));
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_t_3, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 219, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":220
 *         else:
 *             _preprocess_args((a, out))
 *             out_args = [out]             # <<<<<<<<<<<<<<
 * 
 *         in_types, out_types, routine = _guess_routine(
 */
    __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 220, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
    PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_out));
    __pyx_v_out_args = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/reduction.pxi":223
 * 
 *         in_types, out_types, routine = _guess_routine(
 *             self.name, self._routine_cache, self._ops, in_args, dtype)             # <<<<<<<<<<<<<<
 * 
 *         laxis, raxis = _get_axis(axis, a._shape.size())
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(5, 223, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_routine_cache); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(PyDict_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(5, 223, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ops_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(5, 223, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":222
 *             out_args = [out]
 * 
 *         in_types, out_types, routine = _guess_routine(             # <<<<<<<<<<<<<<
 *             self.name, self._routine_cache, self._ops, in_args, dtype)
 * 
 */
  __pyx_t_6 = __pyx_f_4cupy_4core_4core__guess_routine(((PyObject*)__pyx_t_4), ((PyObject*)__pyx_t_3), ((PyObject*)__pyx_t_5), __pyx_v_in_args, __pyx_v_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(__pyx_t_6 != Py_None)) {
    PyObject* sequence = __pyx_t_6;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(5, 222, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 222, __pyx_L1_error)
  }
  __pyx_v_in_types = __pyx_t_5;
  __pyx_t_5 = 0;
  __pyx_v_out_types = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_routine = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":225
 *             self.name, self._routine_cache, self._ops, in_args, dtype)
 * 
 *         laxis, raxis = _get_axis(axis, a._shape.size())             # <<<<<<<<<<<<<<
 *         del axis  # to avoid bug
 *         out_shape = _get_out_shape(a_shape, laxis, raxis, keepdims)
 */
  __pyx_t_6 = __pyx_f_4cupy_4core_4core__get_axis(__pyx_v_axis, __pyx_v_a->_shape.size(), 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 225, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (likely(__pyx_t_6 != Py_None)) {
    PyObject* sequence = __pyx_t_6;
    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(5, 225, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 225, __pyx_L1_error)
  }
  if (!(likely(PyTuple_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(5, 225, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(5, 225, __pyx_L1_error)
  __pyx_v_laxis = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_v_raxis = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":226
 * 
 *         laxis, raxis = _get_axis(axis, a._shape.size())
 *         del axis  # to avoid bug             # <<<<<<<<<<<<<<
 *         out_shape = _get_out_shape(a_shape, laxis, raxis, keepdims)
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 */
  __Pyx_DECREF(__pyx_v_axis);
  __pyx_v_axis = NULL;

  /* "cupy/core/reduction.pxi":227
 *         laxis, raxis = _get_axis(axis, a._shape.size())
 *         del axis  # to avoid bug
 *         out_shape = _get_out_shape(a_shape, laxis, raxis, keepdims)             # <<<<<<<<<<<<<<
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if out_args[0].size == 0:
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_a_shape))||((__pyx_v_a_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_a_shape)->tp_name), 0))) __PYX_ERR(5, 227, __pyx_L1_error)
  __pyx_t_6 = __pyx_f_4cupy_4core_4core__get_out_shape(((PyObject*)__pyx_v_a_shape), __pyx_v_laxis, __pyx_v_raxis, __pyx_v_keepdims, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 227, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_out_shape = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":228
 *         del axis  # to avoid bug
 *         out_shape = _get_out_shape(a_shape, laxis, raxis, keepdims)
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')             # <<<<<<<<<<<<<<
 *         if out_args[0].size == 0:
 *             if len(out_args) == 1:
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_out_types))||((__pyx_v_out_types) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_out_types)->tp_name), 0))) __PYX_ERR(5, 228, __pyx_L1_error)
  __pyx_t_6 = __pyx_f_4cupy_4core_4core__get_out_args(__pyx_v_out_args, ((PyObject*)__pyx_v_out_types), __pyx_v_out_shape, __pyx_n_s_unsafe); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_6));
  __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":229
 *         out_shape = _get_out_shape(a_shape, laxis, raxis, keepdims)
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if out_args[0].size == 0:             # <<<<<<<<<<<<<<
 *             if len(out_args) == 1:
 *                 return out_args[0]
 */
  if (unlikely(__pyx_v_out_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(5, 229, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(5, 229, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":230
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if out_args[0].size == 0:
 *             if len(out_args) == 1:             # <<<<<<<<<<<<<<
 *                 return out_args[0]
 *             return tuple(out_args)
 */
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(5, 230, __pyx_L1_error)
    }
    __pyx_t_7 = PyList_GET_SIZE(__pyx_v_out_args); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(5, 230, __pyx_L1_error)
    __pyx_t_1 = ((__pyx_t_7 == 1) != 0);
    if (__pyx_t_1) {

      /* "cupy/core/reduction.pxi":231
 *         if out_args[0].size == 0:
 *             if len(out_args) == 1:
 *                 return out_args[0]             # <<<<<<<<<<<<<<
 *             return tuple(out_args)
 *         if a.size == 0 and self.identity is None:
 */
      __Pyx_XDECREF(__pyx_r);
      if (unlikely(__pyx_v_out_args == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(5, 231, __pyx_L1_error)
      }
      __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 231, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_r = __pyx_t_6;
      __pyx_t_6 = 0;
      goto __pyx_L0;

      /* "cupy/core/reduction.pxi":230
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if out_args[0].size == 0:
 *             if len(out_args) == 1:             # <<<<<<<<<<<<<<
 *                 return out_args[0]
 *             return tuple(out_args)
 */
    }

    /* "cupy/core/reduction.pxi":232
 *             if len(out_args) == 1:
 *                 return out_args[0]
 *             return tuple(out_args)             # <<<<<<<<<<<<<<
 *         if a.size == 0 and self.identity is None:
 *             raise ValueError(('zero-size array to reduction operation'
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(5, 232, __pyx_L1_error)
    }
    __pyx_t_6 = PyList_AsTuple(__pyx_v_out_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 232, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":229
 *         out_shape = _get_out_shape(a_shape, laxis, raxis, keepdims)
 *         out_args = _get_out_args(out_args, out_types, out_shape, 'unsafe')
 *         if out_args[0].size == 0:             # <<<<<<<<<<<<<<
 *             if len(out_args) == 1:
 *                 return out_args[0]
 */
  }

  /* "cupy/core/reduction.pxi":233
 *                 return out_args[0]
 *             return tuple(out_args)
 *         if a.size == 0 and self.identity is None:             # <<<<<<<<<<<<<<
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)
 */
  __pyx_t_2 = ((__pyx_v_a->size == 0) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_identity); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = (__pyx_t_6 == Py_None);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_8 = (__pyx_t_2 != 0);
  __pyx_t_1 = __pyx_t_8;
  __pyx_L8_bool_binop_done:;
  if (unlikely(__pyx_t_1)) {

    /* "cupy/core/reduction.pxi":235
 *         if a.size == 0 and self.identity is None:
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)             # <<<<<<<<<<<<<<
 * 
 *         in_args, in_shape = _get_trans_args(
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_zero_size_array_to_reduction_ope, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/reduction.pxi":234
 *             return tuple(out_args)
 *         if a.size == 0 and self.identity is None:
 *             raise ValueError(('zero-size array to reduction operation'             # <<<<<<<<<<<<<<
 *                               ' %s which has no identity') % self.name)
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(5, 234, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":233
 *                 return out_args[0]
 *             return tuple(out_args)
 *         if a.size == 0 and self.identity is None:             # <<<<<<<<<<<<<<
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)
 */
  }

  /* "cupy/core/reduction.pxi":238
 * 
 *         in_args, in_shape = _get_trans_args(
 *             in_args, laxis + raxis, a_shape, None)             # <<<<<<<<<<<<<<
 * 
 *         block_size = self._block_size
 */
  __pyx_t_6 = PyNumber_Add(__pyx_v_laxis, __pyx_v_raxis); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (!(likely(PyTuple_CheckExact(__pyx_v_a_shape))||((__pyx_v_a_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_a_shape)->tp_name), 0))) __PYX_ERR(5, 238, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":237
 *                               ' %s which has no identity') % self.name)
 * 
 *         in_args, in_shape = _get_trans_args(             # <<<<<<<<<<<<<<
 *             in_args, laxis + raxis, a_shape, None)
 * 
 */
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__get_trans_args(__pyx_v_in_args, ((PyObject*)__pyx_t_6), ((PyObject*)__pyx_v_a_shape), ((PyObject*)Py_None), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  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(5, 237, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 237, __pyx_L1_error)
  }
  if (!(likely(PyList_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(5, 237, __pyx_L1_error)
  __Pyx_DECREF_SET(__pyx_v_in_args, ((PyObject*)__pyx_t_6));
  __pyx_t_6 = 0;
  __pyx_v_in_shape = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":240
 *             in_args, laxis + raxis, a_shape, None)
 * 
 *         block_size = self._block_size             # <<<<<<<<<<<<<<
 *         in_indexer = Indexer(in_shape)
 *         out_indexer = Indexer(out_shape)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_block_size_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_block_size = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":241
 * 
 *         block_size = self._block_size
 *         in_indexer = Indexer(in_shape)             # <<<<<<<<<<<<<<
 *         out_indexer = Indexer(out_shape)
 *         # Rounding Up to the Next Power of 2
 */
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_v_in_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_in_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":242
 *         block_size = self._block_size
 *         in_indexer = Indexer(in_shape)
 *         out_indexer = Indexer(out_shape)             # <<<<<<<<<<<<<<
 *         # Rounding Up to the Next Power of 2
 *         # clp2_count >= in_indexer.size // out_indexer.size
 */
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_v_out_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_out_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":245
 *         # Rounding Up to the Next Power of 2
 *         # clp2_count >= in_indexer.size // out_indexer.size
 *         clp2_count = 1 << int.bit_length(             # <<<<<<<<<<<<<<
 *             int(in_indexer.size // out_indexer.size - 1))
 *         block_stride = max(1, block_size // clp2_count)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyInt_Type)), __pyx_n_s_bit_length); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 245, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/reduction.pxi":246
 *         # clp2_count >= in_indexer.size // out_indexer.size
 *         clp2_count = 1 << int.bit_length(
 *             int(in_indexer.size // out_indexer.size - 1))             # <<<<<<<<<<<<<<
 *         block_stride = max(1, block_size // clp2_count)
 * 
 */
  if (unlikely(__pyx_v_out_indexer->size == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(5, 246, __pyx_L1_error)
  }
  else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_out_indexer->size == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_in_indexer->size))) {
    PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
    __PYX_ERR(5, 246, __pyx_L1_error)
  }
  __pyx_t_6 = PyInt_FromSsize_t((__Pyx_div_Py_ssize_t(__pyx_v_in_indexer->size, __pyx_v_out_indexer->size) - 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyInt_Type)), __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 245, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 245, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 245, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 245, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 245, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":245
 *         # Rounding Up to the Next Power of 2
 *         # clp2_count >= in_indexer.size // out_indexer.size
 *         clp2_count = 1 << int.bit_length(             # <<<<<<<<<<<<<<
 *             int(in_indexer.size // out_indexer.size - 1))
 *         block_stride = max(1, block_size // clp2_count)
 */
  __pyx_t_4 = PyNumber_Lshift(__pyx_int_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 245, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_clp2_count = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":247
 *         clp2_count = 1 << int.bit_length(
 *             int(in_indexer.size // out_indexer.size - 1))
 *         block_stride = max(1, block_size // clp2_count)             # <<<<<<<<<<<<<<
 * 
 *         inout_args = _get_inout_args(
 */
  __pyx_t_4 = PyNumber_FloorDivide(__pyx_v_block_size, __pyx_v_clp2_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = 1;
  __pyx_t_9 = __Pyx_PyInt_From_long(__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_t_9, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 247, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(5, 247, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_1) {
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_3 = __pyx_t_4;
  } else {
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __pyx_t_5;
    __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __pyx_t_3;
  __Pyx_INCREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_block_stride = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":251
 *         inout_args = _get_inout_args(
 *             in_args, out_args, in_indexer, out_indexer, block_stride,
 *             self._params, True)             # <<<<<<<<<<<<<<
 *         args_info = _get_args_info(inout_args)
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(PyTuple_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(5, 251, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":249
 *         block_stride = max(1, block_size // clp2_count)
 * 
 *         inout_args = _get_inout_args(             # <<<<<<<<<<<<<<
 *             in_args, out_args, in_indexer, out_indexer, block_stride,
 *             self._params, True)
 */
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__get_inout_args(__pyx_v_in_args, __pyx_v_out_args, __pyx_v_in_indexer, __pyx_v_out_indexer, __pyx_v_block_stride, ((PyObject*)__pyx_t_4), 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_inout_args = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":252
 *             in_args, out_args, in_indexer, out_indexer, block_stride,
 *             self._params, True)
 *         args_info = _get_args_info(inout_args)             # <<<<<<<<<<<<<<
 * 
 *         kern = _get_simple_reduction_function(
 */
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__get_args_info(__pyx_v_inout_args, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_args_info = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":254
 *         args_info = _get_args_info(inout_args)
 * 
 *         kern = _get_simple_reduction_function(             # <<<<<<<<<<<<<<
 *             routine, self._params, args_info,
 *             in_args[0].dtype.type, out_args[0].dtype.type, out_types,
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_simple_reduction_function); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/reduction.pxi":255
 * 
 *         kern = _get_simple_reduction_function(
 *             routine, self._params, args_info,             # <<<<<<<<<<<<<<
 *             in_args[0].dtype.type, out_args[0].dtype.type, out_types,
 *             self.name, block_size, self.identity,
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/reduction.pxi":256
 *         kern = _get_simple_reduction_function(
 *             routine, self._params, args_info,
 *             in_args[0].dtype.type, out_args[0].dtype.type, out_types,             # <<<<<<<<<<<<<<
 *             self.name, block_size, self.identity,
 *             self._input_expr, self._output_expr, self._preamble, ())
 */
  if (unlikely(__pyx_v_in_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(5, 256, __pyx_L1_error)
  }
  __pyx_t_9 = __Pyx_GetItemInt_List(__pyx_v_in_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(__pyx_v_out_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(5, 256, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_dtype); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/reduction.pxi":257
 *             routine, self._params, args_info,
 *             in_args[0].dtype.type, out_args[0].dtype.type, out_types,
 *             self.name, block_size, self.identity,             # <<<<<<<<<<<<<<
 *             self._input_expr, self._output_expr, self._preamble, ())
 * 
 */
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_identity); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/reduction.pxi":258
 *             in_args[0].dtype.type, out_args[0].dtype.type, out_types,
 *             self.name, block_size, self.identity,
 *             self._input_expr, self._output_expr, self._preamble, ())             # <<<<<<<<<<<<<<
 * 
 *         # TODO(okuta) set actual size
 */
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_input_expr_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_output_expr_2); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_preamble_2); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_16 = NULL;
  __pyx_t_17 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_16)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_16);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_17 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[14] = {__pyx_t_16, __pyx_v_routine, __pyx_t_5, __pyx_v_args_info, __pyx_t_9, __pyx_t_6, __pyx_v_out_types, __pyx_t_11, __pyx_v_block_size, __pyx_t_12, __pyx_t_13, __pyx_t_14, __pyx_t_15, __pyx_empty_tuple};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_17, 13+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 254, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[14] = {__pyx_t_16, __pyx_v_routine, __pyx_t_5, __pyx_v_args_info, __pyx_t_9, __pyx_t_6, __pyx_v_out_types, __pyx_t_11, __pyx_v_block_size, __pyx_t_12, __pyx_t_13, __pyx_t_14, __pyx_t_15, __pyx_empty_tuple};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_17, 13+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 254, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  } else
  #endif
  {
    __pyx_t_18 = PyTuple_New(13+__pyx_t_17); if (unlikely(!__pyx_t_18)) __PYX_ERR(5, 254, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_18);
    if (__pyx_t_16) {
      __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_16); __pyx_t_16 = NULL;
    }
    __Pyx_INCREF(__pyx_v_routine);
    __Pyx_GIVEREF(__pyx_v_routine);
    PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_17, __pyx_v_routine);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_17, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_args_info);
    __Pyx_GIVEREF(__pyx_v_args_info);
    PyTuple_SET_ITEM(__pyx_t_18, 2+__pyx_t_17, __pyx_v_args_info);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_18, 3+__pyx_t_17, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_18, 4+__pyx_t_17, __pyx_t_6);
    __Pyx_INCREF(__pyx_v_out_types);
    __Pyx_GIVEREF(__pyx_v_out_types);
    PyTuple_SET_ITEM(__pyx_t_18, 5+__pyx_t_17, __pyx_v_out_types);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_18, 6+__pyx_t_17, __pyx_t_11);
    __Pyx_INCREF(__pyx_v_block_size);
    __Pyx_GIVEREF(__pyx_v_block_size);
    PyTuple_SET_ITEM(__pyx_t_18, 7+__pyx_t_17, __pyx_v_block_size);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_18, 8+__pyx_t_17, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_18, 9+__pyx_t_17, __pyx_t_13);
    __Pyx_GIVEREF(__pyx_t_14);
    PyTuple_SET_ITEM(__pyx_t_18, 10+__pyx_t_17, __pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_18, 11+__pyx_t_17, __pyx_t_15);
    __Pyx_INCREF(__pyx_empty_tuple);
    __Pyx_GIVEREF(__pyx_empty_tuple);
    PyTuple_SET_ITEM(__pyx_t_18, 12+__pyx_t_17, __pyx_empty_tuple);
    __pyx_t_5 = 0;
    __pyx_t_9 = 0;
    __pyx_t_6 = 0;
    __pyx_t_11 = 0;
    __pyx_t_12 = 0;
    __pyx_t_13 = 0;
    __pyx_t_14 = 0;
    __pyx_t_15 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_18, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 254, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_kern = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":261
 * 
 *         # TODO(okuta) set actual size
 *         shared_mem = 32 * block_size             # <<<<<<<<<<<<<<
 * 
 *         kern.linear_launch(
 */
  __pyx_t_3 = PyNumber_Multiply(__pyx_int_32, __pyx_v_block_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_shared_mem = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":263
 *         shared_mem = 32 * block_size
 * 
 *         kern.linear_launch(             # <<<<<<<<<<<<<<
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,
 *             inout_args, shared_mem, block_size)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_kern, __pyx_n_s_linear_launch); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/reduction.pxi":264
 * 
 *         kern.linear_launch(
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,             # <<<<<<<<<<<<<<
 *             inout_args, shared_mem, block_size)
 * 
 */
  __pyx_t_18 = PyInt_FromSsize_t(__pyx_v_out_indexer->size); if (unlikely(!__pyx_t_18)) __PYX_ERR(5, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_15 = PyNumber_Add(__pyx_t_18, __pyx_v_block_stride); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  __pyx_t_18 = __Pyx_PyInt_SubtractObjC(__pyx_t_15, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_18)) __PYX_ERR(5, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = PyNumber_FloorDivide(__pyx_t_18, __pyx_v_block_stride); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  __pyx_t_18 = PyNumber_Multiply(__pyx_t_15, __pyx_v_block_size); if (unlikely(!__pyx_t_18)) __PYX_ERR(5, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/reduction.pxi":265
 *         kern.linear_launch(
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,
 *             inout_args, shared_mem, block_size)             # <<<<<<<<<<<<<<
 * 
 *         if len(out_args) == 1:
 */
  __pyx_t_15 = NULL;
  __pyx_t_17 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_17 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[5] = {__pyx_t_15, __pyx_t_18, __pyx_v_inout_args, __pyx_v_shared_mem, __pyx_v_block_size};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_17, 4+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 263, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[5] = {__pyx_t_15, __pyx_t_18, __pyx_v_inout_args, __pyx_v_shared_mem, __pyx_v_block_size};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_17, 4+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 263, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(4+__pyx_t_17); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_15) {
      __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_15); __pyx_t_15 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_18);
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_17, __pyx_t_18);
    __Pyx_INCREF(__pyx_v_inout_args);
    __Pyx_GIVEREF(__pyx_v_inout_args);
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_17, __pyx_v_inout_args);
    __Pyx_INCREF(__pyx_v_shared_mem);
    __Pyx_GIVEREF(__pyx_v_shared_mem);
    PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_17, __pyx_v_shared_mem);
    __Pyx_INCREF(__pyx_v_block_size);
    __Pyx_GIVEREF(__pyx_v_block_size);
    PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_17, __pyx_v_block_size);
    __pyx_t_18 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":267
 *             inout_args, shared_mem, block_size)
 * 
 *         if len(out_args) == 1:             # <<<<<<<<<<<<<<
 *             return out_args[0]
 *         return tuple(out_args)
 */
  if (unlikely(__pyx_v_out_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(5, 267, __pyx_L1_error)
  }
  __pyx_t_7 = PyList_GET_SIZE(__pyx_v_out_args); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(5, 267, __pyx_L1_error)
  __pyx_t_1 = ((__pyx_t_7 == 1) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":268
 * 
 *         if len(out_args) == 1:
 *             return out_args[0]             # <<<<<<<<<<<<<<
 *         return tuple(out_args)
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(5, 268, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":267
 *             inout_args, shared_mem, block_size)
 * 
 *         if len(out_args) == 1:             # <<<<<<<<<<<<<<
 *             return out_args[0]
 *         return tuple(out_args)
 */
  }

  /* "cupy/core/reduction.pxi":269
 *         if len(out_args) == 1:
 *             return out_args[0]
 *         return tuple(out_args)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_out_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(5, 269, __pyx_L1_error)
  }
  __pyx_t_3 = PyList_AsTuple(__pyx_v_out_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":206
 *         self._routine_cache = {}
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,             # <<<<<<<<<<<<<<
 *                  bint keepdims=False):
 *         cdef list in_args, out_args
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_AddTraceback("cupy.core.core.simple_reduction_function.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_in_args);
  __Pyx_XDECREF(__pyx_v_out_args);
  __Pyx_XDECREF(__pyx_v_laxis);
  __Pyx_XDECREF(__pyx_v_raxis);
  __Pyx_XDECREF(__pyx_v_a_shape);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v_routine);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_in_shape);
  __Pyx_XDECREF(__pyx_v_block_size);
  __Pyx_XDECREF((PyObject *)__pyx_v_in_indexer);
  __Pyx_XDECREF((PyObject *)__pyx_v_out_indexer);
  __Pyx_XDECREF(__pyx_v_clp2_count);
  __Pyx_XDECREF(__pyx_v_block_stride);
  __Pyx_XDECREF(__pyx_v_inout_args);
  __Pyx_XDECREF(__pyx_v_args_info);
  __Pyx_XDECREF(__pyx_v_kern);
  __Pyx_XDECREF(__pyx_v_shared_mem);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":273
 * 
 * @util.memoize(for_each_device=True)
 * def _get_reduction_kernel(             # <<<<<<<<<<<<<<
 *         params, args_info, types,
 *         name, block_size, reduce_type, identity, map_expr, reduce_expr,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_45_get_reduction_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_44_get_reduction_kernel[] = "_get_reduction_kernel(params, args_info, types, name, block_size, reduce_type, identity, map_expr, reduce_expr, post_map_expr, preamble, options)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_45_get_reduction_kernel = {"_get_reduction_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_45_get_reduction_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_44_get_reduction_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_45_get_reduction_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_params = 0;
  PyObject *__pyx_v_args_info = 0;
  PyObject *__pyx_v_types = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_block_size = 0;
  PyObject *__pyx_v_reduce_type = 0;
  PyObject *__pyx_v_identity = 0;
  PyObject *__pyx_v_map_expr = 0;
  PyObject *__pyx_v_reduce_expr = 0;
  PyObject *__pyx_v_post_map_expr = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_reduction_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_params,&__pyx_n_s_args_info,&__pyx_n_s_types,&__pyx_n_s_name,&__pyx_n_s_block_size,&__pyx_n_s_reduce_type,&__pyx_n_s_identity,&__pyx_n_s_map_expr,&__pyx_n_s_reduce_expr,&__pyx_n_s_post_map_expr,&__pyx_n_s_preamble,&__pyx_n_s_options,0};
    PyObject* values[12] = {0,0,0,0,0,0,0,0,0,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 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_params)) != 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_args_info)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 1); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_types)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 2); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 3); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_block_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 4); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reduce_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 5); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_identity)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 6); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_map_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 7); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reduce_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 8); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_post_map_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 9); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_preamble)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 10); __PYX_ERR(5, 273, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_options)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, 11); __PYX_ERR(5, 273, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_reduction_kernel") < 0)) __PYX_ERR(5, 273, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 12) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
      values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
    }
    __pyx_v_params = values[0];
    __pyx_v_args_info = values[1];
    __pyx_v_types = values[2];
    __pyx_v_name = values[3];
    __pyx_v_block_size = values[4];
    __pyx_v_reduce_type = values[5];
    __pyx_v_identity = values[6];
    __pyx_v_map_expr = values[7];
    __pyx_v_reduce_expr = values[8];
    __pyx_v_post_map_expr = values[9];
    __pyx_v_preamble = values[10];
    __pyx_v_options = values[11];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_reduction_kernel", 1, 12, 12, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 273, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_reduction_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_44_get_reduction_kernel(__pyx_self, __pyx_v_params, __pyx_v_args_info, __pyx_v_types, __pyx_v_name, __pyx_v_block_size, __pyx_v_reduce_type, __pyx_v_identity, __pyx_v_map_expr, __pyx_v_reduce_expr, __pyx_v_post_map_expr, __pyx_v_preamble, __pyx_v_options);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4cupy_4core_4core_21_get_reduction_kernel_2generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "cupy/core/reduction.pxi":281
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)             # <<<<<<<<<<<<<<
 *         for k, v in types)
 *     input_expr = '\n'.join(
 */

static PyObject *__pyx_pf_4cupy_4core_4core_21_get_reduction_kernel_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_6_genexpr(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_6_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 281, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4cupy_4core_4core_21_get_reduction_kernel_2generator3, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_get_reduction_kernel_locals_gen, __pyx_n_s_cupy_core_core); if (unlikely(!gen)) __PYX_ERR(5, 281, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.core.core._get_reduction_kernel.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_4cupy_4core_4core_21_get_reduction_kernel_2generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L8_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 281, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":282
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)
 *         for k, v in types)             # <<<<<<<<<<<<<<
 *     input_expr = '\n'.join(
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types)) { __Pyx_RaiseClosureNameError("types"); __PYX_ERR(5, 282, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_types; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 282, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 282, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(5, 282, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 282, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(5, 282, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 282, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(5, 282, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      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(5, 282, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 282, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 282, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 282, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(5, 282, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(5, 282, __pyx_L1_error)
      __pyx_L7_unpacking_done:;
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_k);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_k, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/reduction.pxi":281
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)             # <<<<<<<<<<<<<<
 *         for k, v in types)
 *     input_expr = '\n'.join(
 */
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_cur_scope->__pyx_v_v, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_k);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_cur_scope->__pyx_v_k);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_typedef_s_s, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L8_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 281, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":282
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)
 *         for k, v in types)             # <<<<<<<<<<<<<<
 *     input_expr = '\n'.join(
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "cupy/core/reduction.pxi":281
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)             # <<<<<<<<<<<<<<
 *         for k, v in types)
 *     input_expr = '\n'.join(
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  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_7);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":273
 * 
 * @util.memoize(for_each_device=True)
 * def _get_reduction_kernel(             # <<<<<<<<<<<<<<
 *         params, args_info, types,
 *         name, block_size, reduce_type, identity, map_expr, reduce_expr,
 */

static PyObject *__pyx_pf_4cupy_4core_4core_44_get_reduction_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_params, PyObject *__pyx_v_args_info, PyObject *__pyx_v_types, PyObject *__pyx_v_name, PyObject *__pyx_v_block_size, PyObject *__pyx_v_reduce_type, PyObject *__pyx_v_identity, PyObject *__pyx_v_map_expr, PyObject *__pyx_v_reduce_expr, PyObject *__pyx_v_post_map_expr, PyObject *__pyx_v_preamble, PyObject *__pyx_v_options) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *__pyx_cur_scope;
  PyObject *__pyx_v_kernel_params = NULL;
  PyObject *__pyx_v_arrays = NULL;
  PyObject *__pyx_v_type_preamble = NULL;
  PyObject *__pyx_v_input_expr = NULL;
  PyObject *__pyx_v_output_expr = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  __Pyx_RefNannySetupContext("_get_reduction_kernel", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 273, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_types = __pyx_v_types;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_types);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_types);

  /* "cupy/core/reduction.pxi":277
 *         name, block_size, reduce_type, identity, map_expr, reduce_expr,
 *         post_map_expr, preamble, options):
 *     kernel_params = _get_kernel_params(params, args_info)             # <<<<<<<<<<<<<<
 *     arrays = [p for p, a in zip(params, args_info)
 *               if not p.raw and a[0] is ndarray]
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_params))||((__pyx_v_params) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_params)->tp_name), 0))) __PYX_ERR(5, 277, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_args_info))||((__pyx_v_args_info) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args_info)->tp_name), 0))) __PYX_ERR(5, 277, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_kernel_params(((PyObject*)__pyx_v_params), ((PyObject*)__pyx_v_args_info), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_kernel_params = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":278
 *         post_map_expr, preamble, options):
 *     kernel_params = _get_kernel_params(params, args_info)
 *     arrays = [p for p, a in zip(params, args_info)             # <<<<<<<<<<<<<<
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_params);
  __Pyx_GIVEREF(__pyx_v_params);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_params);
  __Pyx_INCREF(__pyx_v_args_info);
  __Pyx_GIVEREF(__pyx_v_args_info);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_args_info);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 278, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 278, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 278, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 278, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 278, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 278, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(5, 278, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      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(5, 278, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(5, 278, __pyx_L1_error)
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(5, 278, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/reduction.pxi":279
 *     kernel_params = _get_kernel_params(params, args_info)
 *     arrays = [p for p, a in zip(params, args_info)
 *               if not p.raw and a[0] is ndarray]             # <<<<<<<<<<<<<<
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_raw_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 279, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(5, 279, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_12 = ((!__pyx_t_11) != 0);
    if (__pyx_t_12) {
    } else {
      __pyx_t_10 = __pyx_t_12;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 279, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_12 = (__pyx_t_3 == ((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_11 = (__pyx_t_12 != 0);
    __pyx_t_10 = __pyx_t_11;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_10) {

      /* "cupy/core/reduction.pxi":278
 *         post_map_expr, preamble, options):
 *     kernel_params = _get_kernel_params(params, args_info)
 *     arrays = [p for p, a in zip(params, args_info)             # <<<<<<<<<<<<<<
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 */
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_v_p))) __PYX_ERR(5, 278, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":279
 *     kernel_params = _get_kernel_params(params, args_info)
 *     arrays = [p for p, a in zip(params, args_info)
 *               if not p.raw and a[0] is ndarray]             # <<<<<<<<<<<<<<
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)
 */
    }

    /* "cupy/core/reduction.pxi":278
 *         post_map_expr, preamble, options):
 *     kernel_params = _get_kernel_params(params, args_info)
 *     arrays = [p for p, a in zip(params, args_info)             # <<<<<<<<<<<<<<
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_arrays = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":281
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(
 *         'typedef %s %s;' % (_get_typename(v), k)             # <<<<<<<<<<<<<<
 *         for k, v in types)
 *     input_expr = '\n'.join(
 */
  __pyx_t_1 = __pyx_pf_4cupy_4core_4core_21_get_reduction_kernel_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 281, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":280
 *     arrays = [p for p, a in zip(params, args_info)
 *               if not p.raw and a[0] is ndarray]
 *     type_preamble = '\n'.join(             # <<<<<<<<<<<<<<
 *         'typedef %s %s;' % (_get_typename(v), k)
 *         for k, v in types)
 */
  __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__53, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_type_preamble = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":284
 *         for k, v in types)
 *     input_expr = '\n'.join(
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)             # <<<<<<<<<<<<<<
 *          for p in arrays if p.is_const])
 *     output_expr = '\n'.join(
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":285
 *     input_expr = '\n'.join(
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)
 *          for p in arrays if p.is_const])             # <<<<<<<<<<<<<<
 *     output_expr = '\n'.join(
 *         ['{0} &{1} = _raw_{1}[_i];'.format(p.ctype, p.name)
 */
  __pyx_t_1 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 285, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 285, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_is_const); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 285, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(5, 285, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_10) {

      /* "cupy/core/reduction.pxi":284
 *         for k, v in types)
 *     input_expr = '\n'.join(
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)             # <<<<<<<<<<<<<<
 *          for p in arrays if p.is_const])
 *     output_expr = '\n'.join(
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_const_0_1__raw__1__j, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 284, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 284, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 284, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_13 = NULL;
      __pyx_t_14 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_14 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_6, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 284, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_6, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 284, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_15 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 284, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        if (__pyx_t_13) {
          __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_13); __pyx_t_13 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_14, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_14, __pyx_t_8);
        __pyx_t_6 = 0;
        __pyx_t_8 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 284, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_3))) __PYX_ERR(5, 284, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/reduction.pxi":285
 *     input_expr = '\n'.join(
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)
 *          for p in arrays if p.is_const])             # <<<<<<<<<<<<<<
 *     output_expr = '\n'.join(
 *         ['{0} &{1} = _raw_{1}[_i];'.format(p.ctype, p.name)
 */
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":283
 *         'typedef %s %s;' % (_get_typename(v), k)
 *         for k, v in types)
 *     input_expr = '\n'.join(             # <<<<<<<<<<<<<<
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)
 *          for p in arrays if p.is_const])
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__53, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_input_expr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":287
 *          for p in arrays if p.is_const])
 *     output_expr = '\n'.join(
 *         ['{0} &{1} = _raw_{1}[_i];'.format(p.ctype, p.name)             # <<<<<<<<<<<<<<
 *          for p in arrays if not p.is_const])
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":288
 *     output_expr = '\n'.join(
 *         ['{0} &{1} = _raw_{1}[_i];'.format(p.ctype, p.name)
 *          for p in arrays if not p.is_const])             # <<<<<<<<<<<<<<
 * 
 *     return _get_simple_reduction_kernel(
 */
  __pyx_t_2 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 288, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 288, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_is_const); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 288, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(5, 288, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_11 = ((!__pyx_t_10) != 0);
    if (__pyx_t_11) {

      /* "cupy/core/reduction.pxi":287
 *          for p in arrays if p.is_const])
 *     output_expr = '\n'.join(
 *         ['{0} &{1} = _raw_{1}[_i];'.format(p.ctype, p.name)             # <<<<<<<<<<<<<<
 *          for p in arrays if not p.is_const])
 * 
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_0_1__raw__1__i, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 287, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ctype); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 287, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 287, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_6 = NULL;
      __pyx_t_14 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_14 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_15, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 287, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_15, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 287, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_13 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 287, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        if (__pyx_t_6) {
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_6); __pyx_t_6 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_14, __pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_14, __pyx_t_8);
        __pyx_t_15 = 0;
        __pyx_t_8 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 287, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(5, 287, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/reduction.pxi":288
 *     output_expr = '\n'.join(
 *         ['{0} &{1} = _raw_{1}[_i];'.format(p.ctype, p.name)
 *          for p in arrays if not p.is_const])             # <<<<<<<<<<<<<<
 * 
 *     return _get_simple_reduction_kernel(
 */
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":286
 *         ['const {0} {1} = _raw_{1}[_j];'.format(p.ctype, p.name)
 *          for p in arrays if p.is_const])
 *     output_expr = '\n'.join(             # <<<<<<<<<<<<<<
 *         ['{0} &{1} = _raw_{1}[_i];'.format(p.ctype, p.name)
 *          for p in arrays if not p.is_const])
 */
  __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__53, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_output_expr = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":290
 *          for p in arrays if not p.is_const])
 * 
 *     return _get_simple_reduction_kernel(             # <<<<<<<<<<<<<<
 *         name, block_size, reduce_type, kernel_params, identity,
 *         map_expr, reduce_expr, post_map_expr,
 */
  __Pyx_XDECREF(__pyx_r);

  /* "cupy/core/reduction.pxi":293
 *         name, block_size, reduce_type, kernel_params, identity,
 *         map_expr, reduce_expr, post_map_expr,
 *         type_preamble, input_expr, output_expr, preamble, options)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __pyx_f_4cupy_4core_4core__get_simple_reduction_kernel(__pyx_v_name, __pyx_v_block_size, __pyx_v_reduce_type, __pyx_v_kernel_params, __pyx_v_identity, __pyx_v_map_expr, __pyx_v_reduce_expr, __pyx_v_post_map_expr, __pyx_v_type_preamble, __pyx_v_input_expr, __pyx_v_output_expr, __pyx_v_preamble, __pyx_v_options, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":273
 * 
 * @util.memoize(for_each_device=True)
 * def _get_reduction_kernel(             # <<<<<<<<<<<<<<
 *         params, args_info, types,
 *         name, block_size, reduce_type, identity, map_expr, reduce_expr,
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("cupy.core.core._get_reduction_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_kernel_params);
  __Pyx_XDECREF(__pyx_v_arrays);
  __Pyx_XDECREF(__pyx_v_type_preamble);
  __Pyx_XDECREF(__pyx_v_input_expr);
  __Pyx_XDECREF(__pyx_v_output_expr);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":327
 * 
 *     """
 *     def __init__(self, in_params, out_params,             # <<<<<<<<<<<<<<
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_15ReductionKernel_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_15ReductionKernel___init__[] = "ReductionKernel.__init__(self, in_params, out_params, map_expr, reduce_expr, post_map_expr, identity, name='reduce_kernel', reduce_type=None, reduce_dims=True, preamble='', options=())";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_15ReductionKernel_1__init__ = {"__init__", (PyCFunction)__pyx_pw_4cupy_4core_4core_15ReductionKernel_1__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_15ReductionKernel___init__};
static PyObject *__pyx_pw_4cupy_4core_4core_15ReductionKernel_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_in_params = 0;
  PyObject *__pyx_v_out_params = 0;
  PyObject *__pyx_v_map_expr = 0;
  PyObject *__pyx_v_reduce_expr = 0;
  PyObject *__pyx_v_post_map_expr = 0;
  PyObject *__pyx_v_identity = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_reduce_type = 0;
  PyObject *__pyx_v_reduce_dims = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_in_params,&__pyx_n_s_out_params,&__pyx_n_s_map_expr,&__pyx_n_s_reduce_expr,&__pyx_n_s_post_map_expr,&__pyx_n_s_identity,&__pyx_n_s_name,&__pyx_n_s_reduce_type,&__pyx_n_s_reduce_dims,&__pyx_n_s_preamble,&__pyx_n_s_options,0};
    PyObject* values[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
    values[7] = ((PyObject *)((PyObject*)__pyx_n_s_reduce_kernel));

    /* "cupy/core/reduction.pxi":329
 *     def __init__(self, in_params, out_params,
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,             # <<<<<<<<<<<<<<
 *                  reduce_dims=True, preamble='', options=()):
 *         if not compiler.is_valid_kernel_name(name):
 */
    values[8] = ((PyObject *)((PyObject *)Py_None));

    /* "cupy/core/reduction.pxi":330
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,
 *                  reduce_dims=True, preamble='', options=()):             # <<<<<<<<<<<<<<
 *         if not compiler.is_valid_kernel_name(name):
 *             raise ValueError(
 */
    values[9] = ((PyObject *)((PyObject *)Py_True));
    values[10] = ((PyObject *)((PyObject*)__pyx_kp_s__6));
    values[11] = ((PyObject *)((PyObject*)__pyx_empty_tuple));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_self)) != 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_in_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 12, 1); __PYX_ERR(5, 327, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out_params)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 12, 2); __PYX_ERR(5, 327, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_map_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 12, 3); __PYX_ERR(5, 327, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reduce_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 12, 4); __PYX_ERR(5, 327, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_post_map_expr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 12, 5); __PYX_ERR(5, 327, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_identity)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 12, 6); __PYX_ERR(5, 327, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name);
          if (value) { values[7] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reduce_type);
          if (value) { values[8] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reduce_dims);
          if (value) { values[9] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_preamble);
          if (value) { values[10] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_options);
          if (value) { values[11] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(5, 327, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 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_self = values[0];
    __pyx_v_in_params = values[1];
    __pyx_v_out_params = values[2];
    __pyx_v_map_expr = values[3];
    __pyx_v_reduce_expr = values[4];
    __pyx_v_post_map_expr = values[5];
    __pyx_v_identity = values[6];
    __pyx_v_name = values[7];
    __pyx_v_reduce_type = values[8];
    __pyx_v_reduce_dims = values[9];
    __pyx_v_preamble = values[10];
    __pyx_v_options = values[11];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 12, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 327, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ReductionKernel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_15ReductionKernel___init__(__pyx_self, __pyx_v_self, __pyx_v_in_params, __pyx_v_out_params, __pyx_v_map_expr, __pyx_v_reduce_expr, __pyx_v_post_map_expr, __pyx_v_identity, __pyx_v_name, __pyx_v_reduce_type, __pyx_v_reduce_dims, __pyx_v_preamble, __pyx_v_options);

  /* "cupy/core/reduction.pxi":327
 * 
 *     """
 *     def __init__(self, in_params, out_params,             # <<<<<<<<<<<<<<
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_15ReductionKernel___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_in_params, PyObject *__pyx_v_out_params, PyObject *__pyx_v_map_expr, PyObject *__pyx_v_reduce_expr, PyObject *__pyx_v_post_map_expr, PyObject *__pyx_v_identity, PyObject *__pyx_v_name, PyObject *__pyx_v_reduce_type, PyObject *__pyx_v_reduce_dims, PyObject *__pyx_v_preamble, PyObject *__pyx_v_options) {
  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;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/reduction.pxi":331
 *                  identity, name='reduce_kernel', reduce_type=None,
 *                  reduce_dims=True, preamble='', options=()):
 *         if not compiler.is_valid_kernel_name(name):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'Invalid kernel name: "%s"' % name)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_compiler); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_valid_kernel_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __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);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 331, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_name};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 331, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_name};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 331, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 331, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(__pyx_v_name);
      __Pyx_GIVEREF(__pyx_v_name);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_name);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 331, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(5, 331, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = ((!__pyx_t_5) != 0);
  if (unlikely(__pyx_t_6)) {

    /* "cupy/core/reduction.pxi":333
 *         if not compiler.is_valid_kernel_name(name):
 *             raise ValueError(
 *                 'Invalid kernel name: "%s"' % name)             # <<<<<<<<<<<<<<
 * 
 *         self.in_params = _get_param_info(in_params, True)
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_kernel_name_s, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "cupy/core/reduction.pxi":332
 *                  reduce_dims=True, preamble='', options=()):
 *         if not compiler.is_valid_kernel_name(name):
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'Invalid kernel name: "%s"' % name)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 332, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(5, 332, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":331
 *                  identity, name='reduce_kernel', reduce_type=None,
 *                  reduce_dims=True, preamble='', options=()):
 *         if not compiler.is_valid_kernel_name(name):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'Invalid kernel name: "%s"' % name)
 */
  }

  /* "cupy/core/reduction.pxi":335
 *                 'Invalid kernel name: "%s"' % name)
 * 
 *         self.in_params = _get_param_info(in_params, True)             # <<<<<<<<<<<<<<
 *         self.out_params = _get_param_info(out_params, False)
 *         self.nin = len(self.in_params)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_in_params, Py_True};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 335, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_in_params, Py_True};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 335, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  {
    __pyx_t_2 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 335, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v_in_params);
    __Pyx_GIVEREF(__pyx_v_in_params);
    PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_7, __pyx_v_in_params);
    __Pyx_INCREF(Py_True);
    __Pyx_GIVEREF(Py_True);
    PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_7, Py_True);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 335, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_in_params, __pyx_t_3) < 0) __PYX_ERR(5, 335, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":336
 * 
 *         self.in_params = _get_param_info(in_params, True)
 *         self.out_params = _get_param_info(out_params, False)             # <<<<<<<<<<<<<<
 *         self.nin = len(self.in_params)
 *         self.nout = len(self.out_params)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 336, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_out_params, Py_False};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 336, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_out_params, Py_False};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 336, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  {
    __pyx_t_4 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 336, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_out_params);
    __Pyx_GIVEREF(__pyx_v_out_params);
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, __pyx_v_out_params);
    __Pyx_INCREF(Py_False);
    __Pyx_GIVEREF(Py_False);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, Py_False);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 336, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_out_params, __pyx_t_3) < 0) __PYX_ERR(5, 336, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":337
 *         self.in_params = _get_param_info(in_params, True)
 *         self.out_params = _get_param_info(out_params, False)
 *         self.nin = len(self.in_params)             # <<<<<<<<<<<<<<
 *         self.nout = len(self.out_params)
 *         self.nargs = self.nin + self.nout
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(5, 337, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nin, __pyx_t_3) < 0) __PYX_ERR(5, 337, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":338
 *         self.out_params = _get_param_info(out_params, False)
 *         self.nin = len(self.in_params)
 *         self.nout = len(self.out_params)             # <<<<<<<<<<<<<<
 *         self.nargs = self.nin + self.nout
 *         self.params = (
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(5, 338, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nout, __pyx_t_3) < 0) __PYX_ERR(5, 338, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":339
 *         self.nin = len(self.in_params)
 *         self.nout = len(self.out_params)
 *         self.nargs = self.nin + self.nout             # <<<<<<<<<<<<<<
 *         self.params = (
 *             self.in_params + self.out_params +
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nout); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nargs, __pyx_t_4) < 0) __PYX_ERR(5, 339, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":341
 *         self.nargs = self.nin + self.nout
 *         self.params = (
 *             self.in_params + self.out_params +             # <<<<<<<<<<<<<<
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":342
 *         self.params = (
 *             self.in_params + self.out_params +
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +             # <<<<<<<<<<<<<<
 *             _get_param_info('int32 _block_stride', True))
 *         self.identity = identity
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":341
 *         self.nargs = self.nin + self.nout
 *         self.params = (
 *             self.in_params + self.out_params +             # <<<<<<<<<<<<<<
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))
 */
  __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":343
 *             self.in_params + self.out_params +
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))             # <<<<<<<<<<<<<<
 *         self.identity = identity
 *         self.reduce_expr = reduce_expr
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_param_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":342
 *         self.params = (
 *             self.in_params + self.out_params +
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +             # <<<<<<<<<<<<<<
 *             _get_param_info('int32 _block_stride', True))
 *         self.identity = identity
 */
  __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":340
 *         self.nout = len(self.out_params)
 *         self.nargs = self.nin + self.nout
 *         self.params = (             # <<<<<<<<<<<<<<
 *             self.in_params + self.out_params +
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_params, __pyx_t_4) < 0) __PYX_ERR(5, 340, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/reduction.pxi":344
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))
 *         self.identity = identity             # <<<<<<<<<<<<<<
 *         self.reduce_expr = reduce_expr
 *         self.map_expr = map_expr
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_identity, __pyx_v_identity) < 0) __PYX_ERR(5, 344, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":345
 *             _get_param_info('int32 _block_stride', True))
 *         self.identity = identity
 *         self.reduce_expr = reduce_expr             # <<<<<<<<<<<<<<
 *         self.map_expr = map_expr
 *         self.name = name
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_reduce_expr, __pyx_v_reduce_expr) < 0) __PYX_ERR(5, 345, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":346
 *         self.identity = identity
 *         self.reduce_expr = reduce_expr
 *         self.map_expr = map_expr             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.options = options
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_map_expr, __pyx_v_map_expr) < 0) __PYX_ERR(5, 346, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":347
 *         self.reduce_expr = reduce_expr
 *         self.map_expr = map_expr
 *         self.name = name             # <<<<<<<<<<<<<<
 *         self.options = options
 *         self.reduce_dims = reduce_dims
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(5, 347, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":348
 *         self.map_expr = map_expr
 *         self.name = name
 *         self.options = options             # <<<<<<<<<<<<<<
 *         self.reduce_dims = reduce_dims
 *         self.post_map_expr = post_map_expr
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_options, __pyx_v_options) < 0) __PYX_ERR(5, 348, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":349
 *         self.name = name
 *         self.options = options
 *         self.reduce_dims = reduce_dims             # <<<<<<<<<<<<<<
 *         self.post_map_expr = post_map_expr
 *         if reduce_type is None:
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_reduce_dims, __pyx_v_reduce_dims) < 0) __PYX_ERR(5, 349, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":350
 *         self.options = options
 *         self.reduce_dims = reduce_dims
 *         self.post_map_expr = post_map_expr             # <<<<<<<<<<<<<<
 *         if reduce_type is None:
 *             self.reduce_type = self.out_params[0].ctype
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_post_map_expr, __pyx_v_post_map_expr) < 0) __PYX_ERR(5, 350, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":351
 *         self.reduce_dims = reduce_dims
 *         self.post_map_expr = post_map_expr
 *         if reduce_type is None:             # <<<<<<<<<<<<<<
 *             self.reduce_type = self.out_params[0].ctype
 *         else:
 */
  __pyx_t_6 = (__pyx_v_reduce_type == Py_None);
  __pyx_t_5 = (__pyx_t_6 != 0);
  if (__pyx_t_5) {

    /* "cupy/core/reduction.pxi":352
 *         self.post_map_expr = post_map_expr
 *         if reduce_type is None:
 *             self.reduce_type = self.out_params[0].ctype             # <<<<<<<<<<<<<<
 *         else:
 *             self.reduce_type = reduce_type
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 352, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 352, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ctype); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 352, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_reduce_type, __pyx_t_4) < 0) __PYX_ERR(5, 352, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":351
 *         self.reduce_dims = reduce_dims
 *         self.post_map_expr = post_map_expr
 *         if reduce_type is None:             # <<<<<<<<<<<<<<
 *             self.reduce_type = self.out_params[0].ctype
 *         else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/reduction.pxi":354
 *             self.reduce_type = self.out_params[0].ctype
 *         else:
 *             self.reduce_type = reduce_type             # <<<<<<<<<<<<<<
 *         self.preamble = preamble
 * 
 */
  /*else*/ {
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_reduce_type, __pyx_v_reduce_type) < 0) __PYX_ERR(5, 354, __pyx_L1_error)
  }
  __pyx_L4:;

  /* "cupy/core/reduction.pxi":355
 *         else:
 *             self.reduce_type = reduce_type
 *         self.preamble = preamble             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, *args, **kwargs):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_preamble, __pyx_v_preamble) < 0) __PYX_ERR(5, 355, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":327
 * 
 *     """
 *     def __init__(self, in_params, out_params,             # <<<<<<<<<<<<<<
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,
 */

  /* 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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.ReductionKernel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":357
 *         self.preamble = preamble
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the reduction kernel.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_15ReductionKernel_3__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_15ReductionKernel_2__call__[] = "ReductionKernel.__call__(self, *args, **kwargs)\nCompiles and invokes the reduction kernel.\n\n        The compilation runs only if the kernel is not cached. Note that the\n        kernels with different argument dtypes, ndims, or axis are not\n        compatible. It means that single ReductionKernel object may be compiled\n        into multiple kernel binaries.\n\n        Args:\n            args: Arguments of the kernel.\n\n        Returns:\n            Arrays are returned according to the ``out_params`` argument of the\n            ``__init__`` method.\n\n        ";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_15ReductionKernel_3__call__ = {"__call__", (PyCFunction)__pyx_pw_4cupy_4core_4core_15ReductionKernel_3__call__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_15ReductionKernel_2__call__};
static PyObject *__pyx_pw_4cupy_4core_4core_15ReductionKernel_3__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,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) {
        default:
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "__call__") < 0)) __PYX_ERR(5, 357, __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_self = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 357, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("cupy.core.core.ReductionKernel.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_15ReductionKernel_2__call__(__pyx_self, __pyx_v_self, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_15ReductionKernel_2__call__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_out = NULL;
  PyObject *__pyx_v_axis = NULL;
  PyObject *__pyx_v_keepdims = NULL;
  PyObject *__pyx_v_stream = NULL;
  Py_ssize_t __pyx_v_n_args;
  PyObject *__pyx_v_out_args = NULL;
  PyObject *__pyx_v_in_args = NULL;
  PyObject *__pyx_v_broad_shape = NULL;
  PyObject *__pyx_v_in_ndarray_types = NULL;
  PyObject *__pyx_v_out_ndarray_types = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_v_types = NULL;
  PyObject *__pyx_v_raxis = NULL;
  PyObject *__pyx_v_out_shape = NULL;
  PyObject *__pyx_v_in_shape = NULL;
  PyObject *__pyx_v_block_size = NULL;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_in_indexer = NULL;
  struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_out_indexer = NULL;
  PyObject *__pyx_v_clp2_count = NULL;
  PyObject *__pyx_v_block_stride = NULL;
  PyObject *__pyx_v_inout_args = NULL;
  PyObject *__pyx_v_args_info = NULL;
  PyObject *__pyx_v_kern = NULL;
  PyObject *__pyx_v_shared_mem = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  struct __pyx_opt_args_4cupy_4core_4core__get_out_args_with_params __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  long __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "cupy/core/reduction.pxi":374
 *         """
 * 
 *         out = kwargs.pop('out', None)             # <<<<<<<<<<<<<<
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_out, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_out = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":375
 * 
 *         out = kwargs.pop('out', None)
 *         axis = kwargs.pop('axis', None)             # <<<<<<<<<<<<<<
 *         keepdims = kwargs.pop('keepdims', False)
 *         stream = kwargs.pop('stream', None)
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_axis, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_axis = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":376
 *         out = kwargs.pop('out', None)
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)             # <<<<<<<<<<<<<<
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_keepdims, Py_False); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_keepdims = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":377
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)
 *         stream = kwargs.pop('stream', None)             # <<<<<<<<<<<<<<
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_stream, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_stream = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":378
 *         keepdims = kwargs.pop('keepdims', False)
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(5, 378, __pyx_L1_error)
  if (unlikely(__pyx_t_2)) {

    /* "cupy/core/reduction.pxi":379
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)             # <<<<<<<<<<<<<<
 * 
 *         n_args = len(args)
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_arguments_s, __pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 379, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 379, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(5, 379, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":378
 *         keepdims = kwargs.pop('keepdims', False)
 *         stream = kwargs.pop('stream', None)
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  }

  /* "cupy/core/reduction.pxi":381
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 *         n_args = len(args)             # <<<<<<<<<<<<<<
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 */
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(5, 381, __pyx_L1_error)
  __pyx_v_n_args = __pyx_t_4;

  /* "cupy/core/reduction.pxi":382
 * 
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 */
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_n_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_6) {
  } else {
    __pyx_t_2 = __pyx_t_6;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_n_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(5, 382, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = __pyx_t_6;
  __pyx_L5_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "cupy/core/reduction.pxi":383
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:
 *             raise TypeError('Wrong number of arguments for %s' % self.name)             # <<<<<<<<<<<<<<
 * 
 *         out_args = list(args[self.nin:])
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Wrong_number_of_arguments_for_s, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(5, 383, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":382
 * 
 *         n_args = len(args)
 *         if n_args != self.nin and n_args != self.nargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 */
  }

  /* "cupy/core/reduction.pxi":385
 *             raise TypeError('Wrong number of arguments for %s' % self.name)
 * 
 *         out_args = list(args[self.nin:])             # <<<<<<<<<<<<<<
 *         if out is not None:
 *             if self.nout != 1:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 385, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyTuple_GetSlice(__pyx_v_args, __pyx_t_4, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_out_args = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":386
 * 
 *         out_args = list(args[self.nin:])
 *         if out is not None:             # <<<<<<<<<<<<<<
 *             if self.nout != 1:
 *                 raise NotImplementedError('')
 */
  __pyx_t_2 = (__pyx_v_out != Py_None);
  __pyx_t_6 = (__pyx_t_2 != 0);
  if (__pyx_t_6) {

    /* "cupy/core/reduction.pxi":387
 *         out_args = list(args[self.nin:])
 *         if out is not None:
 *             if self.nout != 1:             # <<<<<<<<<<<<<<
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nout); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 387, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(5, 387, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(__pyx_t_6)) {

      /* "cupy/core/reduction.pxi":388
 *         if out is not None:
 *             if self.nout != 1:
 *                 raise NotImplementedError('')             # <<<<<<<<<<<<<<
 *             if len(out_args) != 0:
 *                 raise ValueError("cannot specify 'out' as both "
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 388, __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(5, 388, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":387
 *         out_args = list(args[self.nin:])
 *         if out is not None:
 *             if self.nout != 1:             # <<<<<<<<<<<<<<
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:
 */
    }

    /* "cupy/core/reduction.pxi":389
 *             if self.nout != 1:
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError("cannot specify 'out' as both "
 *                                  "a positional and keyword argument")
 */
    __pyx_t_4 = PyList_GET_SIZE(__pyx_v_out_args); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(5, 389, __pyx_L1_error)
    __pyx_t_6 = ((__pyx_t_4 != 0) != 0);
    if (unlikely(__pyx_t_6)) {

      /* "cupy/core/reduction.pxi":390
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:
 *                 raise ValueError("cannot specify 'out' as both "             # <<<<<<<<<<<<<<
 *                                  "a positional and keyword argument")
 *             out_args = [out]
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 390, __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(5, 390, __pyx_L1_error)

      /* "cupy/core/reduction.pxi":389
 *             if self.nout != 1:
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError("cannot specify 'out' as both "
 *                                  "a positional and keyword argument")
 */
    }

    /* "cupy/core/reduction.pxi":392
 *                 raise ValueError("cannot specify 'out' as both "
 *                                  "a positional and keyword argument")
 *             out_args = [out]             # <<<<<<<<<<<<<<
 * 
 *         in_args = _preprocess_args(args[:self.nin])
 */
    __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 392, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_out);
    __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":386
 * 
 *         out_args = list(args[self.nin:])
 *         if out is not None:             # <<<<<<<<<<<<<<
 *             if self.nout != 1:
 *                 raise NotImplementedError('')
 */
  }

  /* "cupy/core/reduction.pxi":394
 *             out_args = [out]
 * 
 *         in_args = _preprocess_args(args[:self.nin])             # <<<<<<<<<<<<<<
 *         out_args = _preprocess_args(out_args)
 *         in_args, broad_shape = _broadcast(in_args, self.in_params, False)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 394, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyTuple_GetSlice(__pyx_v_args, 0, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_t_3, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_in_args = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":395
 * 
 *         in_args = _preprocess_args(args[:self.nin])
 *         out_args = _preprocess_args(out_args)             # <<<<<<<<<<<<<<
 *         in_args, broad_shape = _broadcast(in_args, self.in_params, False)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__preprocess_args(__pyx_v_out_args, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":396
 *         in_args = _preprocess_args(args[:self.nin])
 *         out_args = _preprocess_args(out_args)
 *         in_args, broad_shape = _broadcast(in_args, self.in_params, False)             # <<<<<<<<<<<<<<
 * 
 *         if self.identity is None and 0 in broad_shape:
 */
  if (!(likely(PyList_CheckExact(__pyx_v_in_args))||((__pyx_v_in_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_in_args)->tp_name), 0))) __PYX_ERR(5, 396, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(5, 396, __pyx_L1_error)
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__broadcast(((PyObject*)__pyx_v_in_args), ((PyObject*)__pyx_t_1), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  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(5, 396, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 396, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 396, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 396, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_in_args, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_broad_shape = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":398
 *         in_args, broad_shape = _broadcast(in_args, self.in_params, False)
 * 
 *         if self.identity is None and 0 in broad_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_identity); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = (__pyx_t_3 == Py_None);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = (__pyx_t_2 != 0);
  if (__pyx_t_7) {
  } else {
    __pyx_t_6 = __pyx_t_7;
    goto __pyx_L11_bool_binop_done;
  }
  __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_int_0, __pyx_v_broad_shape, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(5, 398, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_7 != 0);
  __pyx_t_6 = __pyx_t_2;
  __pyx_L11_bool_binop_done:;
  if (unlikely(__pyx_t_6)) {

    /* "cupy/core/reduction.pxi":400
 *         if self.identity is None and 0 in broad_shape:
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)             # <<<<<<<<<<<<<<
 * 
 *         in_ndarray_types = tuple(
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 400, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_zero_size_array_to_reduction_ope, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 400, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":399
 * 
 *         if self.identity is None and 0 in broad_shape:
 *             raise ValueError(('zero-size array to reduction operation'             # <<<<<<<<<<<<<<
 *                               ' %s which has no identity') % self.name)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(5, 399, __pyx_L1_error)

    /* "cupy/core/reduction.pxi":398
 *         in_args, broad_shape = _broadcast(in_args, self.in_params, False)
 * 
 *         if self.identity is None and 0 in broad_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError(('zero-size array to reduction operation'
 *                               ' %s which has no identity') % self.name)
 */
  }

  /* "cupy/core/reduction.pxi":403
 * 
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None             # <<<<<<<<<<<<<<
 *              for a in in_args])
 *         out_ndarray_types = tuple(
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/reduction.pxi":404
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])             # <<<<<<<<<<<<<<
 *         out_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 */
  if (likely(PyList_CheckExact(__pyx_v_in_args)) || PyTuple_CheckExact(__pyx_v_in_args)) {
    __pyx_t_5 = __pyx_v_in_args; __Pyx_INCREF(__pyx_t_5); __pyx_t_4 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_in_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 404, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 404, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 404, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 404, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 404, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_8(__pyx_t_5);
      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(5, 404, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/reduction.pxi":403
 * 
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None             # <<<<<<<<<<<<<<
 *              for a in in_args])
 *         out_ndarray_types = tuple(
 */
    __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_6 != 0)) {
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_type); if (unlikely(!__pyx_t_10)) __PYX_ERR(5, 403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_1 = __pyx_t_10;
      __pyx_t_10 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_1 = Py_None;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_1))) __PYX_ERR(5, 403, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/reduction.pxi":404
 *         in_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])             # <<<<<<<<<<<<<<
 *         out_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":402
 *                               ' %s which has no identity') % self.name)
 * 
 *         in_ndarray_types = tuple(             # <<<<<<<<<<<<<<
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])
 */
  __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_in_ndarray_types = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":406
 *              for a in in_args])
 *         out_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None             # <<<<<<<<<<<<<<
 *              for a in out_args])
 *         in_types, out_types, types = _decide_params_type(
 */
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/reduction.pxi":407
 *         out_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in out_args])             # <<<<<<<<<<<<<<
 *         in_types, out_types, types = _decide_params_type(
 *             self.in_params, self.out_params,
 */
  if (unlikely(__pyx_v_out_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(5, 407, __pyx_L1_error)
  }
  __pyx_t_3 = __pyx_v_out_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 407, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/reduction.pxi":406
 *              for a in in_args])
 *         out_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None             # <<<<<<<<<<<<<<
 *              for a in out_args])
 *         in_types, out_types, types = _decide_params_type(
 */
    __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_6 != 0)) {
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_10)) __PYX_ERR(5, 406, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 406, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_1 = __pyx_t_9;
      __pyx_t_9 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_1 = Py_None;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_1))) __PYX_ERR(5, 406, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/reduction.pxi":407
 *         out_ndarray_types = tuple(
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in out_args])             # <<<<<<<<<<<<<<
 *         in_types, out_types, types = _decide_params_type(
 *             self.in_params, self.out_params,
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":405
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in in_args])
 *         out_ndarray_types = tuple(             # <<<<<<<<<<<<<<
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in out_args])
 */
  __pyx_t_3 = PyList_AsTuple(((PyObject*)__pyx_t_5)); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 405, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_out_ndarray_types = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":408
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in out_args])
 *         in_types, out_types, types = _decide_params_type(             # <<<<<<<<<<<<<<
 *             self.in_params, self.out_params,
 *             in_ndarray_types, out_ndarray_types)
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_decide_params_type); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/reduction.pxi":409
 *              for a in out_args])
 *         in_types, out_types, types = _decide_params_type(
 *             self.in_params, self.out_params,             # <<<<<<<<<<<<<<
 *             in_ndarray_types, out_ndarray_types)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/core/reduction.pxi":410
 *         in_types, out_types, types = _decide_params_type(
 *             self.in_params, self.out_params,
 *             in_ndarray_types, out_ndarray_types)             # <<<<<<<<<<<<<<
 * 
 *         axis, raxis = _get_axis(axis, len(broad_shape))
 */
  __pyx_t_10 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_1, __pyx_t_9, __pyx_v_in_ndarray_types, __pyx_v_out_ndarray_types};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_1, __pyx_t_9, __pyx_v_in_ndarray_types, __pyx_v_out_ndarray_types};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(4+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_9);
    __Pyx_INCREF(__pyx_v_in_ndarray_types);
    __Pyx_GIVEREF(__pyx_v_in_ndarray_types);
    PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_v_in_ndarray_types);
    __Pyx_INCREF(__pyx_v_out_ndarray_types);
    __Pyx_GIVEREF(__pyx_v_out_ndarray_types);
    PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_11, __pyx_v_out_ndarray_types);
    __pyx_t_1 = 0;
    __pyx_t_9 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(5, 408, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_12 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_9 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_12);
    __Pyx_INCREF(__pyx_t_9);
    #else
    __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_9 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_13 = Py_TYPE(__pyx_t_1)->tp_iternext;
    index = 0; __pyx_t_5 = __pyx_t_13(__pyx_t_1); if (unlikely(!__pyx_t_5)) goto __pyx_L17_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    index = 1; __pyx_t_12 = __pyx_t_13(__pyx_t_1); if (unlikely(!__pyx_t_12)) goto __pyx_L17_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_12);
    index = 2; __pyx_t_9 = __pyx_t_13(__pyx_t_1); if (unlikely(!__pyx_t_9)) goto __pyx_L17_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_9);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_1), 3) < 0) __PYX_ERR(5, 408, __pyx_L1_error)
    __pyx_t_13 = NULL;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L18_unpacking_done;
    __pyx_L17_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_13 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(5, 408, __pyx_L1_error)
    __pyx_L18_unpacking_done:;
  }

  /* "cupy/core/reduction.pxi":408
 *             [a.dtype.type if isinstance(a, ndarray) else None
 *              for a in out_args])
 *         in_types, out_types, types = _decide_params_type(             # <<<<<<<<<<<<<<
 *             self.in_params, self.out_params,
 *             in_ndarray_types, out_ndarray_types)
 */
  __pyx_v_in_types = __pyx_t_5;
  __pyx_t_5 = 0;
  __pyx_v_out_types = __pyx_t_12;
  __pyx_t_12 = 0;
  __pyx_v_types = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":412
 *             in_ndarray_types, out_ndarray_types)
 * 
 *         axis, raxis = _get_axis(axis, len(broad_shape))             # <<<<<<<<<<<<<<
 *         out_shape = _get_out_shape(broad_shape, axis, raxis, keepdims)
 *         out_args = _get_out_args_with_params(
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_broad_shape); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(5, 412, __pyx_L1_error)
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__get_axis(__pyx_v_axis, __pyx_t_4, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 412, __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(5, 412, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_t_12);
    #else
    __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 412, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_9);
  __pyx_t_9 = 0;
  __pyx_v_raxis = __pyx_t_12;
  __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":413
 * 
 *         axis, raxis = _get_axis(axis, len(broad_shape))
 *         out_shape = _get_out_shape(broad_shape, axis, raxis, keepdims)             # <<<<<<<<<<<<<<
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, out_shape, self.out_params, False)
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_broad_shape))||((__pyx_v_broad_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_broad_shape)->tp_name), 0))) __PYX_ERR(5, 413, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_axis))||((__pyx_v_axis) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_axis)->tp_name), 0))) __PYX_ERR(5, 413, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_raxis))||((__pyx_v_raxis) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_raxis)->tp_name), 0))) __PYX_ERR(5, 413, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_keepdims); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 413, __pyx_L1_error)
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__get_out_shape(((PyObject*)__pyx_v_broad_shape), ((PyObject*)__pyx_v_axis), ((PyObject*)__pyx_v_raxis), __pyx_t_6, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_out_shape = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":415
 *         out_shape = _get_out_shape(broad_shape, axis, raxis, keepdims)
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, out_shape, self.out_params, False)             # <<<<<<<<<<<<<<
 *         if 0 in out_shape:
 *             return out_args[0]
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_out_types))||((__pyx_v_out_types) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_out_types)->tp_name), 0))) __PYX_ERR(5, 415, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(5, 415, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":414
 *         axis, raxis = _get_axis(axis, len(broad_shape))
 *         out_shape = _get_out_shape(broad_shape, axis, raxis, keepdims)
 *         out_args = _get_out_args_with_params(             # <<<<<<<<<<<<<<
 *             out_args, out_types, out_shape, self.out_params, False)
 *         if 0 in out_shape:
 */
  __pyx_t_14.__pyx_n = 1;
  __pyx_t_14.is_size_specified = 0;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core__get_out_args_with_params(__pyx_v_out_args, ((PyObject*)__pyx_v_out_types), __pyx_v_out_shape, ((PyObject*)__pyx_t_3), &__pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_out_args, ((PyObject*)__pyx_t_12));
  __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":416
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, out_shape, self.out_params, False)
 *         if 0 in out_shape:             # <<<<<<<<<<<<<<
 *             return out_args[0]
 * 
 */
  __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_int_0, __pyx_v_out_shape, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(5, 416, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_6 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/reduction.pxi":417
 *             out_args, out_types, out_shape, self.out_params, False)
 *         if 0 in out_shape:
 *             return out_args[0]             # <<<<<<<<<<<<<<
 * 
 *         in_args = [x if isinstance(x, ndarray) else t(x)
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_out_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(5, 417, __pyx_L1_error)
    }
    __pyx_t_12 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_r = __pyx_t_12;
    __pyx_t_12 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":416
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, out_shape, self.out_params, False)
 *         if 0 in out_shape:             # <<<<<<<<<<<<<<
 *             return out_args[0]
 * 
 */
  }

  /* "cupy/core/reduction.pxi":419
 *             return out_args[0]
 * 
 *         in_args = [x if isinstance(x, ndarray) else t(x)             # <<<<<<<<<<<<<<
 *                    for x, t in zip(in_args, in_types)]
 *         in_args, in_shape = _get_trans_args(
 */
  __pyx_t_12 = PyList_New(0); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/reduction.pxi":420
 * 
 *         in_args = [x if isinstance(x, ndarray) else t(x)
 *                    for x, t in zip(in_args, in_types)]             # <<<<<<<<<<<<<<
 *         in_args, in_shape = _get_trans_args(
 *             in_args, axis + raxis, broad_shape, self.in_params)
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_in_args);
  __Pyx_GIVEREF(__pyx_v_in_args);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_in_args);
  __Pyx_INCREF(__pyx_v_in_types);
  __Pyx_GIVEREF(__pyx_v_in_types);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_in_types);
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_3, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_9)) || PyTuple_CheckExact(__pyx_t_9)) {
    __pyx_t_3 = __pyx_t_9; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 420, __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(5, 420, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_4 >= 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_4); __Pyx_INCREF(__pyx_t_9); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 420, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 420, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      } else {
        if (__pyx_t_4 >= 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_4); __Pyx_INCREF(__pyx_t_9); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(5, 420, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 420, __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(5, 420, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_9);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) {
      PyObject* sequence = __pyx_t_9;
      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(5, 420, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_10 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(5, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_13 = Py_TYPE(__pyx_t_10)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_13(__pyx_t_10); if (unlikely(!__pyx_t_5)) goto __pyx_L22_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_1 = __pyx_t_13(__pyx_t_10); if (unlikely(!__pyx_t_1)) goto __pyx_L22_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_10), 2) < 0) __PYX_ERR(5, 420, __pyx_L1_error)
      __pyx_t_13 = NULL;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L23_unpacking_done;
      __pyx_L22_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_13 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(5, 420, __pyx_L1_error)
      __pyx_L23_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/reduction.pxi":419
 *             return out_args[0]
 * 
 *         in_args = [x if isinstance(x, ndarray) else t(x)             # <<<<<<<<<<<<<<
 *                    for x, t in zip(in_args, in_types)]
 *         in_args, in_shape = _get_trans_args(
 */
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray); 
    if ((__pyx_t_2 != 0)) {
      __Pyx_INCREF(__pyx_v_x);
      __pyx_t_9 = __pyx_v_x;
    } else {
      __Pyx_INCREF(__pyx_v_t);
      __pyx_t_5 = __pyx_v_t; __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 419, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_x};
          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 419, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_x};
          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 419, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        {
          __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 419, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_x);
          __Pyx_GIVEREF(__pyx_v_x);
          PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_v_x);
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 419, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_12, (PyObject*)__pyx_t_9))) __PYX_ERR(5, 419, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "cupy/core/reduction.pxi":420
 * 
 *         in_args = [x if isinstance(x, ndarray) else t(x)
 *                    for x, t in zip(in_args, in_types)]             # <<<<<<<<<<<<<<
 *         in_args, in_shape = _get_trans_args(
 *             in_args, axis + raxis, broad_shape, self.in_params)
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_in_args, __pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":422
 *                    for x, t in zip(in_args, in_types)]
 *         in_args, in_shape = _get_trans_args(
 *             in_args, axis + raxis, broad_shape, self.in_params)             # <<<<<<<<<<<<<<
 * 
 *         block_size = 512
 */
  if (!(likely(PyList_CheckExact(__pyx_v_in_args))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_in_args)->tp_name), 0))) __PYX_ERR(5, 422, __pyx_L1_error)
  __pyx_t_12 = PyNumber_Add(__pyx_v_axis, __pyx_v_raxis); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (!(likely(PyTuple_CheckExact(__pyx_t_12))||((__pyx_t_12) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_12)->tp_name), 0))) __PYX_ERR(5, 422, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_broad_shape))||((__pyx_v_broad_shape) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_broad_shape)->tp_name), 0))) __PYX_ERR(5, 422, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(5, 422, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":421
 *         in_args = [x if isinstance(x, ndarray) else t(x)
 *                    for x, t in zip(in_args, in_types)]
 *         in_args, in_shape = _get_trans_args(             # <<<<<<<<<<<<<<
 *             in_args, axis + raxis, broad_shape, self.in_params)
 * 
 */
  __pyx_t_9 = __pyx_f_4cupy_4core_4core__get_trans_args(((PyObject*)__pyx_v_in_args), ((PyObject*)__pyx_t_12), ((PyObject*)__pyx_v_broad_shape), ((PyObject*)__pyx_t_3), 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(__pyx_t_9 != Py_None)) {
    PyObject* sequence = __pyx_t_9;
    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(5, 421, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_12);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    #endif
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(5, 421, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_in_args, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_in_shape = __pyx_t_12;
  __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":424
 *             in_args, axis + raxis, broad_shape, self.in_params)
 * 
 *         block_size = 512             # <<<<<<<<<<<<<<
 *         in_indexer = Indexer(in_shape)
 *         out_indexer = Indexer(out_shape)
 */
  __Pyx_INCREF(__pyx_int_512);
  __pyx_v_block_size = __pyx_int_512;

  /* "cupy/core/reduction.pxi":425
 * 
 *         block_size = 512
 *         in_indexer = Indexer(in_shape)             # <<<<<<<<<<<<<<
 *         out_indexer = Indexer(out_shape)
 *         # Rounding Up to the Next Power of 2
 */
  __pyx_t_9 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_v_in_shape); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_v_in_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":426
 *         block_size = 512
 *         in_indexer = Indexer(in_shape)
 *         out_indexer = Indexer(out_shape)             # <<<<<<<<<<<<<<
 *         # Rounding Up to the Next Power of 2
 *         # clp2_count >= in_indexer.size // out_indexer.size
 */
  __pyx_t_9 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_v_out_shape); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_v_out_indexer = ((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":429
 *         # Rounding Up to the Next Power of 2
 *         # clp2_count >= in_indexer.size // out_indexer.size
 *         clp2_count = 1 << int.bit_length(             # <<<<<<<<<<<<<<
 *             int(in_indexer.size // out_indexer.size - 1))
 *         block_stride = max(1, block_size // clp2_count)
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyInt_Type)), __pyx_n_s_bit_length); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/reduction.pxi":430
 *         # clp2_count >= in_indexer.size // out_indexer.size
 *         clp2_count = 1 << int.bit_length(
 *             int(in_indexer.size // out_indexer.size - 1))             # <<<<<<<<<<<<<<
 *         block_stride = max(1, block_size // clp2_count)
 * 
 */
  if (unlikely(__pyx_v_out_indexer->size == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(5, 430, __pyx_L1_error)
  }
  else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_out_indexer->size == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_in_indexer->size))) {
    PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
    __PYX_ERR(5, 430, __pyx_L1_error)
  }
  __pyx_t_3 = PyInt_FromSsize_t((__Pyx_div_Py_ssize_t(__pyx_v_in_indexer->size, __pyx_v_out_indexer->size) - 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyInt_Type)), __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 430, __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_12))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 429, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 429, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 429, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 429, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 429, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":429
 *         # Rounding Up to the Next Power of 2
 *         # clp2_count >= in_indexer.size // out_indexer.size
 *         clp2_count = 1 << int.bit_length(             # <<<<<<<<<<<<<<
 *             int(in_indexer.size // out_indexer.size - 1))
 *         block_stride = max(1, block_size // clp2_count)
 */
  __pyx_t_12 = PyNumber_Lshift(__pyx_int_1, __pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_clp2_count = __pyx_t_12;
  __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":431
 *         clp2_count = 1 << int.bit_length(
 *             int(in_indexer.size // out_indexer.size - 1))
 *         block_stride = max(1, block_size // clp2_count)             # <<<<<<<<<<<<<<
 * 
 *         inout_args = _get_inout_args(
 */
  __pyx_t_12 = PyNumber_FloorDivide(__pyx_v_block_size, __pyx_v_clp2_count); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_16 = 1;
  __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_t_16); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_12, __pyx_t_5, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 431, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(5, 431, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {
    __Pyx_INCREF(__pyx_t_12);
    __pyx_t_9 = __pyx_t_12;
  } else {
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_t_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 431, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = __pyx_t_9;
  __Pyx_INCREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_block_stride = __pyx_t_12;
  __pyx_t_12 = 0;

  /* "cupy/core/reduction.pxi":434
 * 
 *         inout_args = _get_inout_args(
 *             in_args, out_args, in_indexer, out_indexer, block_stride,             # <<<<<<<<<<<<<<
 *             self.params, self.reduce_dims)
 *         args_info = _get_args_info(inout_args)
 */
  if (!(likely(PyList_CheckExact(__pyx_v_in_args))||((__pyx_v_in_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_in_args)->tp_name), 0))) __PYX_ERR(5, 434, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":435
 *         inout_args = _get_inout_args(
 *             in_args, out_args, in_indexer, out_indexer, block_stride,
 *             self.params, self.reduce_dims)             # <<<<<<<<<<<<<<
 *         args_info = _get_args_info(inout_args)
 * 
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 435, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (!(likely(PyTuple_CheckExact(__pyx_t_12))||((__pyx_t_12) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_12)->tp_name), 0))) __PYX_ERR(5, 435, __pyx_L1_error)
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reduce_dims); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 435, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 435, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":433
 *         block_stride = max(1, block_size // clp2_count)
 * 
 *         inout_args = _get_inout_args(             # <<<<<<<<<<<<<<
 *             in_args, out_args, in_indexer, out_indexer, block_stride,
 *             self.params, self.reduce_dims)
 */
  __pyx_t_9 = __pyx_f_4cupy_4core_4core__get_inout_args(((PyObject*)__pyx_v_in_args), __pyx_v_out_args, __pyx_v_in_indexer, __pyx_v_out_indexer, __pyx_v_block_stride, ((PyObject*)__pyx_t_12), __pyx_t_2, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_v_inout_args = ((PyObject*)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":436
 *             in_args, out_args, in_indexer, out_indexer, block_stride,
 *             self.params, self.reduce_dims)
 *         args_info = _get_args_info(inout_args)             # <<<<<<<<<<<<<<
 * 
 *         kern = _get_reduction_kernel(
 */
  __pyx_t_9 = __pyx_f_4cupy_4core_4core__get_args_info(__pyx_v_inout_args, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 436, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_v_args_info = ((PyObject*)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":438
 *         args_info = _get_args_info(inout_args)
 * 
 *         kern = _get_reduction_kernel(             # <<<<<<<<<<<<<<
 *             self.params, args_info, types,
 *             self.name, block_size, self.reduce_type, self.identity,
 */
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_reduction_kernel); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/reduction.pxi":439
 * 
 *         kern = _get_reduction_kernel(
 *             self.params, args_info, types,             # <<<<<<<<<<<<<<
 *             self.name, block_size, self.reduce_type, self.identity,
 *             self.map_expr, self.reduce_expr, self.post_map_expr,
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":440
 *         kern = _get_reduction_kernel(
 *             self.params, args_info, types,
 *             self.name, block_size, self.reduce_type, self.identity,             # <<<<<<<<<<<<<<
 *             self.map_expr, self.reduce_expr, self.post_map_expr,
 *             self.preamble, self.options)
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reduce_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_identity); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);

  /* "cupy/core/reduction.pxi":441
 *             self.params, args_info, types,
 *             self.name, block_size, self.reduce_type, self.identity,
 *             self.map_expr, self.reduce_expr, self.post_map_expr,             # <<<<<<<<<<<<<<
 *             self.preamble, self.options)
 * 
 */
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_map_expr); if (unlikely(!__pyx_t_10)) __PYX_ERR(5, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reduce_expr); if (unlikely(!__pyx_t_17)) __PYX_ERR(5, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_post_map_expr); if (unlikely(!__pyx_t_18)) __PYX_ERR(5, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);

  /* "cupy/core/reduction.pxi":442
 *             self.name, block_size, self.reduce_type, self.identity,
 *             self.map_expr, self.reduce_expr, self.post_map_expr,
 *             self.preamble, self.options)             # <<<<<<<<<<<<<<
 * 
 *         # TODO(okuta) set actual size
 */
  __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_preamble); if (unlikely(!__pyx_t_19)) __PYX_ERR(5, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_options); if (unlikely(!__pyx_t_20)) __PYX_ERR(5, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __pyx_t_21 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_21)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_21);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_12)) {
    PyObject *__pyx_temp[13] = {__pyx_t_21, __pyx_t_1, __pyx_v_args_info, __pyx_v_types, __pyx_t_5, __pyx_v_block_size, __pyx_t_3, __pyx_t_15, __pyx_t_10, __pyx_t_17, __pyx_t_18, __pyx_t_19, __pyx_t_20};
    __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_11, 12+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 438, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
    PyObject *__pyx_temp[13] = {__pyx_t_21, __pyx_t_1, __pyx_v_args_info, __pyx_v_types, __pyx_t_5, __pyx_v_block_size, __pyx_t_3, __pyx_t_15, __pyx_t_10, __pyx_t_17, __pyx_t_18, __pyx_t_19, __pyx_t_20};
    __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_11, 12+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 438, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  } else
  #endif
  {
    __pyx_t_22 = PyTuple_New(12+__pyx_t_11); if (unlikely(!__pyx_t_22)) __PYX_ERR(5, 438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    if (__pyx_t_21) {
      __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_21); __pyx_t_21 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_22, 0+__pyx_t_11, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_args_info);
    __Pyx_GIVEREF(__pyx_v_args_info);
    PyTuple_SET_ITEM(__pyx_t_22, 1+__pyx_t_11, __pyx_v_args_info);
    __Pyx_INCREF(__pyx_v_types);
    __Pyx_GIVEREF(__pyx_v_types);
    PyTuple_SET_ITEM(__pyx_t_22, 2+__pyx_t_11, __pyx_v_types);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_22, 3+__pyx_t_11, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_block_size);
    __Pyx_GIVEREF(__pyx_v_block_size);
    PyTuple_SET_ITEM(__pyx_t_22, 4+__pyx_t_11, __pyx_v_block_size);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_22, 5+__pyx_t_11, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_22, 6+__pyx_t_11, __pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_22, 7+__pyx_t_11, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_17);
    PyTuple_SET_ITEM(__pyx_t_22, 8+__pyx_t_11, __pyx_t_17);
    __Pyx_GIVEREF(__pyx_t_18);
    PyTuple_SET_ITEM(__pyx_t_22, 9+__pyx_t_11, __pyx_t_18);
    __Pyx_GIVEREF(__pyx_t_19);
    PyTuple_SET_ITEM(__pyx_t_22, 10+__pyx_t_11, __pyx_t_19);
    __Pyx_GIVEREF(__pyx_t_20);
    PyTuple_SET_ITEM(__pyx_t_22, 11+__pyx_t_11, __pyx_t_20);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_3 = 0;
    __pyx_t_15 = 0;
    __pyx_t_10 = 0;
    __pyx_t_17 = 0;
    __pyx_t_18 = 0;
    __pyx_t_19 = 0;
    __pyx_t_20 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_22, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_v_kern = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":445
 * 
 *         # TODO(okuta) set actual size
 *         shared_mem = 32 * block_size             # <<<<<<<<<<<<<<
 * 
 *         kern.linear_launch(
 */
  __pyx_t_9 = PyNumber_Multiply(__pyx_int_32, __pyx_v_block_size); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_v_shared_mem = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":447
 *         shared_mem = 32 * block_size
 * 
 *         kern.linear_launch(             # <<<<<<<<<<<<<<
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,
 *             inout_args, shared_mem, block_size, stream)
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_kern, __pyx_n_s_linear_launch); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/reduction.pxi":448
 * 
 *         kern.linear_launch(
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,             # <<<<<<<<<<<<<<
 *             inout_args, shared_mem, block_size, stream)
 *         return out_args[0]
 */
  __pyx_t_22 = PyInt_FromSsize_t(__pyx_v_out_indexer->size); if (unlikely(!__pyx_t_22)) __PYX_ERR(5, 448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __pyx_t_20 = PyNumber_Add(__pyx_t_22, __pyx_v_block_stride); if (unlikely(!__pyx_t_20)) __PYX_ERR(5, 448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  __pyx_t_22 = __Pyx_PyInt_SubtractObjC(__pyx_t_20, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_22)) __PYX_ERR(5, 448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  __pyx_t_20 = PyNumber_FloorDivide(__pyx_t_22, __pyx_v_block_stride); if (unlikely(!__pyx_t_20)) __PYX_ERR(5, 448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  __pyx_t_22 = PyNumber_Multiply(__pyx_t_20, __pyx_v_block_size); if (unlikely(!__pyx_t_22)) __PYX_ERR(5, 448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;

  /* "cupy/core/reduction.pxi":449
 *         kern.linear_launch(
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,
 *             inout_args, shared_mem, block_size, stream)             # <<<<<<<<<<<<<<
 *         return out_args[0]
 * 
 */
  __pyx_t_20 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_20)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_20);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_12)) {
    PyObject *__pyx_temp[6] = {__pyx_t_20, __pyx_t_22, __pyx_v_inout_args, __pyx_v_shared_mem, __pyx_v_block_size, __pyx_v_stream};
    __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 447, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
    PyObject *__pyx_temp[6] = {__pyx_t_20, __pyx_t_22, __pyx_v_inout_args, __pyx_v_shared_mem, __pyx_v_block_size, __pyx_v_stream};
    __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 447, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  } else
  #endif
  {
    __pyx_t_19 = PyTuple_New(5+__pyx_t_11); if (unlikely(!__pyx_t_19)) __PYX_ERR(5, 447, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    if (__pyx_t_20) {
      __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_20); __pyx_t_20 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_22);
    PyTuple_SET_ITEM(__pyx_t_19, 0+__pyx_t_11, __pyx_t_22);
    __Pyx_INCREF(__pyx_v_inout_args);
    __Pyx_GIVEREF(__pyx_v_inout_args);
    PyTuple_SET_ITEM(__pyx_t_19, 1+__pyx_t_11, __pyx_v_inout_args);
    __Pyx_INCREF(__pyx_v_shared_mem);
    __Pyx_GIVEREF(__pyx_v_shared_mem);
    PyTuple_SET_ITEM(__pyx_t_19, 2+__pyx_t_11, __pyx_v_shared_mem);
    __Pyx_INCREF(__pyx_v_block_size);
    __Pyx_GIVEREF(__pyx_v_block_size);
    PyTuple_SET_ITEM(__pyx_t_19, 3+__pyx_t_11, __pyx_v_block_size);
    __Pyx_INCREF(__pyx_v_stream);
    __Pyx_GIVEREF(__pyx_v_stream);
    PyTuple_SET_ITEM(__pyx_t_19, 4+__pyx_t_11, __pyx_v_stream);
    __pyx_t_22 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_19, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 447, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/reduction.pxi":450
 *             (out_indexer.size + block_stride - 1) // block_stride * block_size,
 *             inout_args, shared_mem, block_size, stream)
 *         return out_args[0]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_out_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(5, 450, __pyx_L1_error)
  }
  __pyx_t_9 = __Pyx_GetItemInt_List(__pyx_v_out_args, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 450, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_r = __pyx_t_9;
  __pyx_t_9 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":357
 *         self.preamble = preamble
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the reduction kernel.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_AddTraceback("cupy.core.core.ReductionKernel.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_out);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XDECREF(__pyx_v_keepdims);
  __Pyx_XDECREF(__pyx_v_stream);
  __Pyx_XDECREF(__pyx_v_out_args);
  __Pyx_XDECREF(__pyx_v_in_args);
  __Pyx_XDECREF(__pyx_v_broad_shape);
  __Pyx_XDECREF(__pyx_v_in_ndarray_types);
  __Pyx_XDECREF(__pyx_v_out_ndarray_types);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XDECREF(__pyx_v_raxis);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_in_shape);
  __Pyx_XDECREF(__pyx_v_block_size);
  __Pyx_XDECREF((PyObject *)__pyx_v_in_indexer);
  __Pyx_XDECREF((PyObject *)__pyx_v_out_indexer);
  __Pyx_XDECREF(__pyx_v_clp2_count);
  __Pyx_XDECREF(__pyx_v_block_stride);
  __Pyx_XDECREF(__pyx_v_inout_args);
  __Pyx_XDECREF(__pyx_v_args_info);
  __Pyx_XDECREF(__pyx_v_kern);
  __Pyx_XDECREF(__pyx_v_shared_mem);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/reduction.pxi":453
 * 
 * 
 * cpdef create_reduction_func(name, ops, routine=None, identity=None,             # <<<<<<<<<<<<<<
 *                             preamble=''):
 *     _ops = []
 */

static PyObject *__pyx_pw_4cupy_4core_4core_47create_reduction_func(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_create_reduction_func(PyObject *__pyx_v_name, PyObject *__pyx_v_ops, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_create_reduction_func *__pyx_optional_args) {
  PyObject *__pyx_v_routine = ((PyObject *)Py_None);
  PyObject *__pyx_v_identity = ((PyObject *)Py_None);
  PyObject *__pyx_v_preamble = ((PyObject *)__pyx_kp_s__6);
  PyObject *__pyx_v__ops = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_typ = NULL;
  PyObject *__pyx_v_rt = NULL;
  PyObject *__pyx_v_types = NULL;
  PyObject *__pyx_v_in_types = NULL;
  PyObject *__pyx_v_out_types = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  int __pyx_t_16;
  __Pyx_RefNannySetupContext("create_reduction_func", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_routine = __pyx_optional_args->routine;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_identity = __pyx_optional_args->identity;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_preamble = __pyx_optional_args->preamble;
        }
      }
    }
  }

  /* "cupy/core/reduction.pxi":455
 * cpdef create_reduction_func(name, ops, routine=None, identity=None,
 *                             preamble=''):
 *     _ops = []             # <<<<<<<<<<<<<<
 *     for t in ops:
 *         if not isinstance(t, tuple):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__ops = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":456
 *                             preamble=''):
 *     _ops = []
 *     for t in ops:             # <<<<<<<<<<<<<<
 *         if not isinstance(t, tuple):
 *             typ = t
 */
  if (likely(PyList_CheckExact(__pyx_v_ops)) || PyTuple_CheckExact(__pyx_v_ops)) {
    __pyx_t_1 = __pyx_v_ops; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_ops); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 456, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(5, 456, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 456, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(5, 456, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 456, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(5, 456, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":457
 *     _ops = []
 *     for t in ops:
 *         if not isinstance(t, tuple):             # <<<<<<<<<<<<<<
 *             typ = t
 *             rt = routine
 */
    __pyx_t_5 = PyTuple_Check(__pyx_v_t); 
    __pyx_t_6 = ((!(__pyx_t_5 != 0)) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/reduction.pxi":458
 *     for t in ops:
 *         if not isinstance(t, tuple):
 *             typ = t             # <<<<<<<<<<<<<<
 *             rt = routine
 *         else:
 */
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_XDECREF_SET(__pyx_v_typ, __pyx_v_t);

      /* "cupy/core/reduction.pxi":459
 *         if not isinstance(t, tuple):
 *             typ = t
 *             rt = routine             # <<<<<<<<<<<<<<
 *         else:
 *             typ, rt = t
 */
      __Pyx_INCREF(__pyx_v_routine);
      __Pyx_XDECREF_SET(__pyx_v_rt, __pyx_v_routine);

      /* "cupy/core/reduction.pxi":457
 *     _ops = []
 *     for t in ops:
 *         if not isinstance(t, tuple):             # <<<<<<<<<<<<<<
 *             typ = t
 *             rt = routine
 */
      goto __pyx_L5;
    }

    /* "cupy/core/reduction.pxi":461
 *             rt = routine
 *         else:
 *             typ, rt = t             # <<<<<<<<<<<<<<
 *             rt = tuple([i or j for i, j in zip(rt, routine)])
 * 
 */
    /*else*/ {
      if ((likely(PyTuple_CheckExact(__pyx_v_t))) || (PyList_CheckExact(__pyx_v_t))) {
        PyObject* sequence = __pyx_v_t;
        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(5, 461, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 461, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 461, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      } else {
        Py_ssize_t index = -1;
        __pyx_t_8 = PyObject_GetIter(__pyx_v_t); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 461, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(5, 461, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(5, 461, __pyx_L1_error)
        __pyx_L7_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_typ, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_rt, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "cupy/core/reduction.pxi":462
 *         else:
 *             typ, rt = t
 *             rt = tuple([i or j for i, j in zip(rt, routine)])             # <<<<<<<<<<<<<<
 * 
 *         types = typ.split('->')
 */
      __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_rt);
      __Pyx_GIVEREF(__pyx_v_rt);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_rt);
      __Pyx_INCREF(__pyx_v_routine);
      __Pyx_GIVEREF(__pyx_v_routine);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_routine);
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) {
        __pyx_t_4 = __pyx_t_8; __Pyx_INCREF(__pyx_t_4); __pyx_t_10 = 0;
        __pyx_t_11 = NULL;
      } else {
        __pyx_t_10 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 462, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_11 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 462, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      for (;;) {
        if (likely(!__pyx_t_11)) {
          if (likely(PyList_CheckExact(__pyx_t_4))) {
            if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_4)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_8 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(5, 462, __pyx_L1_error)
            #else
            __pyx_t_8 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 462, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_8);
            #endif
          } else {
            if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(5, 462, __pyx_L1_error)
            #else
            __pyx_t_8 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 462, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_8);
            #endif
          }
        } else {
          __pyx_t_8 = __pyx_t_11(__pyx_t_4);
          if (unlikely(!__pyx_t_8)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(5, 462, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_8);
        }
        if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
          PyObject* sequence = __pyx_t_8;
          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(5, 462, __pyx_L1_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_13 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_12 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_13 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_13);
          #else
          __pyx_t_12 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 462, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_13 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 462, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          #endif
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_14 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 462, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __pyx_t_9 = Py_TYPE(__pyx_t_14)->tp_iternext;
          index = 0; __pyx_t_12 = __pyx_t_9(__pyx_t_14); if (unlikely(!__pyx_t_12)) goto __pyx_L10_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_12);
          index = 1; __pyx_t_13 = __pyx_t_9(__pyx_t_14); if (unlikely(!__pyx_t_13)) goto __pyx_L10_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_13);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_14), 2) < 0) __PYX_ERR(5, 462, __pyx_L1_error)
          __pyx_t_9 = NULL;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L11_unpacking_done;
          __pyx_L10_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __pyx_t_9 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(5, 462, __pyx_L1_error)
          __pyx_L11_unpacking_done:;
        }
        __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_12);
        __pyx_t_12 = 0;
        __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_13);
        __pyx_t_13 = 0;
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_i); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(5, 462, __pyx_L1_error)
        if (!__pyx_t_6) {
        } else {
          __Pyx_INCREF(__pyx_v_i);
          __pyx_t_8 = __pyx_v_i;
          goto __pyx_L12_bool_binop_done;
        }
        __Pyx_INCREF(__pyx_v_j);
        __pyx_t_8 = __pyx_v_j;
        __pyx_L12_bool_binop_done:;
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_7, (PyObject*)__pyx_t_8))) __PYX_ERR(5, 462, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyList_AsTuple(((PyObject*)__pyx_t_7)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF_SET(__pyx_v_rt, __pyx_t_4);
      __pyx_t_4 = 0;
    }
    __pyx_L5:;

    /* "cupy/core/reduction.pxi":464
 *             rt = tuple([i or j for i, j in zip(rt, routine)])
 * 
 *         types = typ.split('->')             # <<<<<<<<<<<<<<
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_typ, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_types, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/reduction.pxi":465
 * 
 *         types = typ.split('->')
 *         if len(types) == 1:             # <<<<<<<<<<<<<<
 *             in_types = out_types = tuple(types)
 *         else:
 */
    __pyx_t_10 = PyObject_Length(__pyx_v_types); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(5, 465, __pyx_L1_error)
    __pyx_t_6 = ((__pyx_t_10 == 1) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/reduction.pxi":466
 *         types = typ.split('->')
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)             # <<<<<<<<<<<<<<
 *         else:
 *             in_types, out_types = map(tuple, types)
 */
      __pyx_t_7 = __Pyx_PySequence_Tuple(__pyx_v_types); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_XDECREF_SET(__pyx_v_in_types, __pyx_t_7);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_XDECREF_SET(__pyx_v_out_types, __pyx_t_7);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "cupy/core/reduction.pxi":465
 * 
 *         types = typ.split('->')
 *         if len(types) == 1:             # <<<<<<<<<<<<<<
 *             in_types = out_types = tuple(types)
 *         else:
 */
      goto __pyx_L14;
    }

    /* "cupy/core/reduction.pxi":468
 *             in_types = out_types = tuple(types)
 *         else:
 *             in_types, out_types = map(tuple, types)             # <<<<<<<<<<<<<<
 *         in_types = tuple([get_dtype(t).type for t in in_types])
 *         out_types = tuple([get_dtype(t).type for t in out_types])
 */
    /*else*/ {
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 468, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(((PyObject *)(&PyTuple_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyTuple_Type)));
      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)(&PyTuple_Type)));
      __Pyx_INCREF(__pyx_v_types);
      __Pyx_GIVEREF(__pyx_v_types);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_types);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 468, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
        PyObject* sequence = __pyx_t_4;
        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(5, 468, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        #else
        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 468, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 468, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_13 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 468, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_13)->tp_iternext;
        index = 0; __pyx_t_7 = __pyx_t_9(__pyx_t_13); if (unlikely(!__pyx_t_7)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        index = 1; __pyx_t_8 = __pyx_t_9(__pyx_t_13); if (unlikely(!__pyx_t_8)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_13), 2) < 0) __PYX_ERR(5, 468, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L16_unpacking_done;
        __pyx_L15_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(5, 468, __pyx_L1_error)
        __pyx_L16_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_in_types, __pyx_t_7);
      __pyx_t_7 = 0;
      __Pyx_XDECREF_SET(__pyx_v_out_types, __pyx_t_8);
      __pyx_t_8 = 0;
    }
    __pyx_L14:;

    /* "cupy/core/reduction.pxi":469
 *         else:
 *             in_types, out_types = map(tuple, types)
 *         in_types = tuple([get_dtype(t).type for t in in_types])             # <<<<<<<<<<<<<<
 *         out_types = tuple([get_dtype(t).type for t in out_types])
 *         _ops.append((in_types, out_types, rt))
 */
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 469, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (likely(PyList_CheckExact(__pyx_v_in_types)) || PyTuple_CheckExact(__pyx_v_in_types)) {
      __pyx_t_8 = __pyx_v_in_types; __Pyx_INCREF(__pyx_t_8); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_in_types); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 469, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_11 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 469, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_11)) {
        if (likely(PyList_CheckExact(__pyx_t_8))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(5, 469, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 469, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(5, 469, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 469, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        }
      } else {
        __pyx_t_7 = __pyx_t_11(__pyx_t_8);
        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(5, 469, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_7 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_t, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 469, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_type); if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 469, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_13))) __PYX_ERR(5, 469, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyList_AsTuple(((PyObject*)__pyx_t_4)); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 469, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_in_types, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/reduction.pxi":470
 *             in_types, out_types = map(tuple, types)
 *         in_types = tuple([get_dtype(t).type for t in in_types])
 *         out_types = tuple([get_dtype(t).type for t in out_types])             # <<<<<<<<<<<<<<
 *         _ops.append((in_types, out_types, rt))
 * 
 */
    __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 470, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (likely(PyList_CheckExact(__pyx_v_out_types)) || PyTuple_CheckExact(__pyx_v_out_types)) {
      __pyx_t_4 = __pyx_v_out_types; __Pyx_INCREF(__pyx_t_4); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_out_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 470, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 470, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_11)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_13 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_13); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(5, 470, __pyx_L1_error)
          #else
          __pyx_t_13 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 470, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_13 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_13); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(5, 470, __pyx_L1_error)
          #else
          __pyx_t_13 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 470, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          #endif
        }
      } else {
        __pyx_t_13 = __pyx_t_11(__pyx_t_4);
        if (unlikely(!__pyx_t_13)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(5, 470, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_13);
      }
      __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_13);
      __pyx_t_13 = 0;
      __pyx_t_13 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_t, 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 470, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 470, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_t_7))) __PYX_ERR(5, 470, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyList_AsTuple(((PyObject*)__pyx_t_8)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 470, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF_SET(__pyx_v_out_types, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":471
 *         in_types = tuple([get_dtype(t).type for t in in_types])
 *         out_types = tuple([get_dtype(t).type for t in out_types])
 *         _ops.append((in_types, out_types, rt))             # <<<<<<<<<<<<<<
 * 
 *     return simple_reduction_function(name, _ops, identity, preamble)
 */
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 471, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_in_types);
    __Pyx_GIVEREF(__pyx_v_in_types);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_in_types);
    __Pyx_INCREF(__pyx_v_out_types);
    __Pyx_GIVEREF(__pyx_v_out_types);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_out_types);
    __Pyx_INCREF(__pyx_v_rt);
    __Pyx_GIVEREF(__pyx_v_rt);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_rt);
    __pyx_t_15 = __Pyx_PyList_Append(__pyx_v__ops, __pyx_t_4); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(5, 471, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/reduction.pxi":456
 *                             preamble=''):
 *     _ops = []
 *     for t in ops:             # <<<<<<<<<<<<<<
 *         if not isinstance(t, tuple):
 *             typ = t
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":473
 *         _ops.append((in_types, out_types, rt))
 * 
 *     return simple_reduction_function(name, _ops, identity, preamble)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_simple_reduction_function); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 473, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = NULL;
  __pyx_t_16 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_16 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_v_name, __pyx_v__ops, __pyx_v_identity, __pyx_v_preamble};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_16, 4+__pyx_t_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 473, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_v_name, __pyx_v__ops, __pyx_v_identity, __pyx_v_preamble};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_16, 4+__pyx_t_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 473, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(4+__pyx_t_16); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 473, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_INCREF(__pyx_v_name);
    __Pyx_GIVEREF(__pyx_v_name);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_16, __pyx_v_name);
    __Pyx_INCREF(__pyx_v__ops);
    __Pyx_GIVEREF(__pyx_v__ops);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_16, __pyx_v__ops);
    __Pyx_INCREF(__pyx_v_identity);
    __Pyx_GIVEREF(__pyx_v_identity);
    PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_16, __pyx_v_identity);
    __Pyx_INCREF(__pyx_v_preamble);
    __Pyx_GIVEREF(__pyx_v_preamble);
    PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_16, __pyx_v_preamble);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 473, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":453
 * 
 * 
 * cpdef create_reduction_func(name, ops, routine=None, identity=None,             # <<<<<<<<<<<<<<
 *                             preamble=''):
 *     _ops = []
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("cupy.core.core.create_reduction_func", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__ops);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_typ);
  __Pyx_XDECREF(__pyx_v_rt);
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XDECREF(__pyx_v_in_types);
  __Pyx_XDECREF(__pyx_v_out_types);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_47create_reduction_func(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_46create_reduction_func[] = "create_reduction_func(name, ops, routine=None, identity=None, preamble='')";
static PyObject *__pyx_pw_4cupy_4core_4core_47create_reduction_func(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_ops = 0;
  PyObject *__pyx_v_routine = 0;
  PyObject *__pyx_v_identity = 0;
  PyObject *__pyx_v_preamble = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_reduction_func (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_ops,&__pyx_n_s_routine,&__pyx_n_s_identity,&__pyx_n_s_preamble,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)__pyx_kp_s__6);
    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_name)) != 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_ops)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_reduction_func", 0, 2, 5, 1); __PYX_ERR(5, 453, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_routine);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_identity);
          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_preamble);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_reduction_func") < 0)) __PYX_ERR(5, 453, __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);
        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_name = values[0];
    __pyx_v_ops = values[1];
    __pyx_v_routine = values[2];
    __pyx_v_identity = values[3];
    __pyx_v_preamble = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_reduction_func", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 453, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.create_reduction_func", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_46create_reduction_func(__pyx_self, __pyx_v_name, __pyx_v_ops, __pyx_v_routine, __pyx_v_identity, __pyx_v_preamble);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_46create_reduction_func(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_ops, PyObject *__pyx_v_routine, PyObject *__pyx_v_identity, PyObject *__pyx_v_preamble) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_create_reduction_func __pyx_t_2;
  __Pyx_RefNannySetupContext("create_reduction_func", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.routine = __pyx_v_routine;
  __pyx_t_2.identity = __pyx_v_identity;
  __pyx_t_2.preamble = __pyx_v_preamble;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_v_name, __pyx_v_ops, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 453, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.create_reduction_func", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2050
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, str order='K',             # <<<<<<<<<<<<<<
 *                     bint subok=False, Py_ssize_t ndmin=0):
 *     # TODO(beam2d): Support subok options
 */

static PyObject *__pyx_pw_4cupy_4core_4core_49array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_array(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_array *__pyx_optional_args) {
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  int __pyx_v_copy = ((int)1);
  PyObject *__pyx_v_order = ((PyObject*)__pyx_n_s_K);

  /* "cupy/core/core.pyx":2051
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, str order='K',
 *                     bint subok=False, Py_ssize_t ndmin=0):             # <<<<<<<<<<<<<<
 *     # TODO(beam2d): Support subok options
 *     cdef Py_ssize_t nvidem
 */
  int __pyx_v_subok = ((int)0);
  Py_ssize_t __pyx_v_ndmin = ((Py_ssize_t)0);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_src = 0;
  struct __pyx_obj_4cupy_4cuda_6device_Device *__pyx_v_dev = NULL;
  PyObject *__pyx_v_ndim = NULL;
  PyObject *__pyx_v_a_cpu = NULL;
  PyObject *__pyx_v_a_dtype = NULL;
  struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *__pyx_v_mem = NULL;
  PyObject *__pyx_v_src_cpu = NULL;
  PyObject *__pyx_v_stream = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set __pyx_t_14;
  __Pyx_RefNannySetupContext("array", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_dtype = __pyx_optional_args->dtype;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_copy = __pyx_optional_args->copy;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_order = __pyx_optional_args->order;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_subok = __pyx_optional_args->subok;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_ndmin = __pyx_optional_args->ndmin;
            }
          }
        }
      }
    }
  }
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_INCREF(__pyx_v_order);

  /* "cupy/core/core.pyx":2055
 *     cdef Py_ssize_t nvidem
 *     cdef ndarray a, src
 *     if subok:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 *     if isinstance(obj, ndarray):
 */
  __pyx_t_1 = (__pyx_v_subok != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cupy/core/core.pyx":2056
 *     cdef ndarray a, src
 *     if subok:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 *     if isinstance(obj, ndarray):
 *         src = obj
 */
    __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
    __PYX_ERR(0, 2056, __pyx_L1_error)

    /* "cupy/core/core.pyx":2055
 *     cdef Py_ssize_t nvidem
 *     cdef ndarray a, src
 *     if subok:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 *     if isinstance(obj, ndarray):
 */
  }

  /* "cupy/core/core.pyx":2057
 *     if subok:
 *         raise NotImplementedError
 *     if isinstance(obj, ndarray):             # <<<<<<<<<<<<<<
 *         src = obj
 *         if dtype is None:
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_4cupy_4core_4core_ndarray); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2058
 *         raise NotImplementedError
 *     if isinstance(obj, ndarray):
 *         src = obj             # <<<<<<<<<<<<<<
 *         if dtype is None:
 *             dtype = src.dtype
 */
    if (!(likely(((__pyx_v_obj) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_obj, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2058, __pyx_L1_error)
    __pyx_t_3 = __pyx_v_obj;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_src = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2059
 *     if isinstance(obj, ndarray):
 *         src = obj
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             dtype = src.dtype
 *         dev = src.data.device
 */
    __pyx_t_2 = (__pyx_v_dtype == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":2060
 *         src = obj
 *         if dtype is None:
 *             dtype = src.dtype             # <<<<<<<<<<<<<<
 *         dev = src.data.device
 *         if dev is None or dev.id == device.get_device_id():
 */
      __pyx_t_3 = __pyx_v_src->dtype;
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":2059
 *     if isinstance(obj, ndarray):
 *         src = obj
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             dtype = src.dtype
 *         dev = src.data.device
 */
    }

    /* "cupy/core/core.pyx":2061
 *         if dtype is None:
 *             dtype = src.dtype
 *         dev = src.data.device             # <<<<<<<<<<<<<<
 *         if dev is None or dev.id == device.get_device_id():
 *             a = src.astype(dtype, order=order, copy=copy)
 */
    __pyx_t_3 = ((PyObject *)__pyx_v_src->data->device);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_dev = ((struct __pyx_obj_4cupy_4cuda_6device_Device *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2062
 *             dtype = src.dtype
 *         dev = src.data.device
 *         if dev is None or dev.id == device.get_device_id():             # <<<<<<<<<<<<<<
 *             a = src.astype(dtype, order=order, copy=copy)
 *         else:
 */
    __pyx_t_2 = (((PyObject *)__pyx_v_dev) == Py_None);
    __pyx_t_4 = (__pyx_t_2 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_1 = __pyx_t_4;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_5 = __pyx_f_4cupy_4cuda_6device_get_device_id(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2062, __pyx_L1_error)
    __pyx_t_4 = ((__pyx_v_dev->id == __pyx_t_5) != 0);
    __pyx_t_1 = __pyx_t_4;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":2063
 *         dev = src.data.device
 *         if dev is None or dev.id == device.get_device_id():
 *             a = src.astype(dtype, order=order, copy=copy)             # <<<<<<<<<<<<<<
 *         else:
 *             a = src.copy(order=order).astype(dtype, copy=False)
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_src), __pyx_n_s_astype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2063, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2063, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_dtype);
      __pyx_t_7 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2063, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 2063, __pyx_L1_error)
      __pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_v_copy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2063, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_copy, __pyx_t_8) < 0) __PYX_ERR(0, 2063, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2063, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2063, __pyx_L1_error)
      __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8);
      __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":2062
 *             dtype = src.dtype
 *         dev = src.data.device
 *         if dev is None or dev.id == device.get_device_id():             # <<<<<<<<<<<<<<
 *             a = src.astype(dtype, order=order, copy=copy)
 *         else:
 */
      goto __pyx_L6;
    }

    /* "cupy/core/core.pyx":2065
 *             a = src.astype(dtype, order=order, copy=copy)
 *         else:
 *             a = src.copy(order=order).astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 * 
 *         ndim = a._shape.size()
 */
    /*else*/ {
      __pyx_t_9.__pyx_n = 1;
      __pyx_t_9.order = __pyx_v_order;
      __pyx_t_8 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_src->__pyx_vtab)->copy(__pyx_v_src, 0, &__pyx_t_9)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2065, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_astype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2065, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2065, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_dtype);
      __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2065, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 2065, __pyx_L1_error)
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2065, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2065, __pyx_L1_error)
      __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
      __pyx_t_3 = 0;
    }
    __pyx_L6:;

    /* "cupy/core/core.pyx":2067
 *             a = src.copy(order=order).astype(dtype, copy=False)
 * 
 *         ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *         if ndmin > ndim:
 *             if a is obj:
 */
    __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_a->_shape.size()); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2067, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_ndim = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2068
 * 
 *         ndim = a._shape.size()
 *         if ndmin > ndim:             # <<<<<<<<<<<<<<
 *             if a is obj:
 *                 # When `copy` is False, `a` is same as `obj`.
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ndmin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2068, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, __pyx_v_ndim, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2068, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2068, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":2069
 *         ndim = a._shape.size()
 *         if ndmin > ndim:
 *             if a is obj:             # <<<<<<<<<<<<<<
 *                 # When `copy` is False, `a` is same as `obj`.
 *                 a = a.view()
 */
      __pyx_t_1 = (((PyObject *)__pyx_v_a) == __pyx_v_obj);
      __pyx_t_4 = (__pyx_t_1 != 0);
      if (__pyx_t_4) {

        /* "cupy/core/core.pyx":2071
 *             if a is obj:
 *                 # When `copy` is False, `a` is same as `obj`.
 *                 a = a.view()             # <<<<<<<<<<<<<<
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *     else:
 */
        __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2071, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6));
        __pyx_t_6 = 0;

        /* "cupy/core/core.pyx":2069
 *         ndim = a._shape.size()
 *         if ndmin > ndim:
 *             if a is obj:             # <<<<<<<<<<<<<<
 *                 # When `copy` is False, `a` is same as `obj`.
 *                 a = a.view()
 */
      }

      /* "cupy/core/core.pyx":2072
 *                 # When `copy` is False, `a` is same as `obj`.
 *                 a = a.view()
 *             a.shape = (1,) * (ndmin - ndim) + a.shape             # <<<<<<<<<<<<<<
 *     else:
 *         if order == 'K':
 */
      __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_ndmin); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2072, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = PyNumber_Subtract(__pyx_t_6, __pyx_v_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2072, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyNumber_Multiply(__pyx_tuple__85, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2072, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2072, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PyNumber_Add(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2072, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape, __pyx_t_8) < 0) __PYX_ERR(0, 2072, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":2068
 * 
 *         ndim = a._shape.size()
 *         if ndmin > ndim:             # <<<<<<<<<<<<<<
 *             if a is obj:
 *                 # When `copy` is False, `a` is same as `obj`.
 */
    }

    /* "cupy/core/core.pyx":2057
 *     if subok:
 *         raise NotImplementedError
 *     if isinstance(obj, ndarray):             # <<<<<<<<<<<<<<
 *         src = obj
 *         if dtype is None:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":2074
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *     else:
 *         if order == 'K':             # <<<<<<<<<<<<<<
 *             order = 'A'
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,
 */
  /*else*/ {
    __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_order, __pyx_n_s_K, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2074, __pyx_L1_error)
    __pyx_t_1 = (__pyx_t_4 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":2075
 *     else:
 *         if order == 'K':
 *             order = 'A'             # <<<<<<<<<<<<<<
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,
 *                             ndmin=ndmin)
 */
      __Pyx_INCREF(__pyx_n_s_A);
      __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_s_A);

      /* "cupy/core/core.pyx":2074
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *     else:
 *         if order == 'K':             # <<<<<<<<<<<<<<
 *             order = 'A'
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,
 */
    }

    /* "cupy/core/core.pyx":2076
 *         if order == 'K':
 *             order = 'A'
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,             # <<<<<<<<<<<<<<
 *                             ndmin=ndmin)
 *         order = 'C' if a_cpu.flags.c_contiguous else 'F'
 */
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2076, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2076, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2076, __pyx_L1_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_t_6 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2076, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 2076, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 2076, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 2076, __pyx_L1_error)

    /* "cupy/core/core.pyx":2077
 *             order = 'A'
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,
 *                             ndmin=ndmin)             # <<<<<<<<<<<<<<
 *         order = 'C' if a_cpu.flags.c_contiguous else 'F'
 *         a_dtype = a_cpu.dtype
 */
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_ndmin); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2077, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_ndmin, __pyx_t_7) < 0) __PYX_ERR(0, 2076, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2076
 *         if order == 'K':
 *             order = 'A'
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,             # <<<<<<<<<<<<<<
 *                             ndmin=ndmin)
 *         order = 'C' if a_cpu.flags.c_contiguous else 'F'
 */
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2076, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_a_cpu = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2078
 *         a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,
 *                             ndmin=ndmin)
 *         order = 'C' if a_cpu.flags.c_contiguous else 'F'             # <<<<<<<<<<<<<<
 *         a_dtype = a_cpu.dtype
 *         if a_dtype.char not in '?bhilqBHILQefdFD':
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_flags); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2078, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_c_contiguous); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2078, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2078, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__pyx_t_1) {
      __Pyx_INCREF(__pyx_n_s_C);
      __pyx_t_7 = __pyx_n_s_C;
    } else {
      __Pyx_INCREF(__pyx_n_s_F);
      __pyx_t_7 = __pyx_n_s_F;
    }
    __Pyx_DECREF_SET(__pyx_v_order, ((PyObject*)__pyx_t_7));
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2079
 *                             ndmin=ndmin)
 *         order = 'C' if a_cpu.flags.c_contiguous else 'F'
 *         a_dtype = a_cpu.dtype             # <<<<<<<<<<<<<<
 *         if a_dtype.char not in '?bhilqBHILQefdFD':
 *             raise ValueError('Unsupported dtype %s' % a_dtype)
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2079, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_v_a_dtype = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2080
 *         order = 'C' if a_cpu.flags.c_contiguous else 'F'
 *         a_dtype = a_cpu.dtype
 *         if a_dtype.char not in '?bhilqBHILQefdFD':             # <<<<<<<<<<<<<<
 *             raise ValueError('Unsupported dtype %s' % a_dtype)
 *         a = ndarray(a_cpu.shape, dtype=a_dtype, order=order)
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_dtype, __pyx_n_s_char); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2080, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_t_7, __pyx_kp_s_bhilqBHILQefdFD, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2080, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_4 = (__pyx_t_1 != 0);
    if (unlikely(__pyx_t_4)) {

      /* "cupy/core/core.pyx":2081
 *         a_dtype = a_cpu.dtype
 *         if a_dtype.char not in '?bhilqBHILQefdFD':
 *             raise ValueError('Unsupported dtype %s' % a_dtype)             # <<<<<<<<<<<<<<
 *         a = ndarray(a_cpu.shape, dtype=a_dtype, order=order)
 *         if a_cpu.ndim == 0:
 */
      __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Unsupported_dtype_s, __pyx_v_a_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2081, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2081, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(0, 2081, __pyx_L1_error)

      /* "cupy/core/core.pyx":2080
 *         order = 'C' if a_cpu.flags.c_contiguous else 'F'
 *         a_dtype = a_cpu.dtype
 *         if a_dtype.char not in '?bhilqBHILQefdFD':             # <<<<<<<<<<<<<<
 *             raise ValueError('Unsupported dtype %s' % a_dtype)
 *         a = ndarray(a_cpu.shape, dtype=a_dtype, order=order)
 */
    }

    /* "cupy/core/core.pyx":2082
 *         if a_dtype.char not in '?bhilqBHILQefdFD':
 *             raise ValueError('Unsupported dtype %s' % a_dtype)
 *         a = ndarray(a_cpu.shape, dtype=a_dtype, order=order)             # <<<<<<<<<<<<<<
 *         if a_cpu.ndim == 0:
 *             a.fill(a_cpu[()])
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2082, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2082, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2082, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, __pyx_v_a_dtype) < 0) __PYX_ERR(0, 2082, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 2082, __pyx_L1_error)
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2082, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2083
 *             raise ValueError('Unsupported dtype %s' % a_dtype)
 *         a = ndarray(a_cpu.shape, dtype=a_dtype, order=order)
 *         if a_cpu.ndim == 0:             # <<<<<<<<<<<<<<
 *             a.fill(a_cpu[()])
 *             return a
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2083, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = __Pyx_PyInt_EqObjC(__pyx_t_6, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2083, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2083, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":2084
 *         a = ndarray(a_cpu.shape, dtype=a_dtype, order=order)
 *         if a_cpu.ndim == 0:
 *             a.fill(a_cpu[()])             # <<<<<<<<<<<<<<
 *             return a
 *         mem = pinned_memory.alloc_pinned_memory(a.nbytes)
 */
      __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_v_a_cpu, __pyx_empty_tuple); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2084, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_6 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->fill(__pyx_v_a, __pyx_t_8, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2084, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/core.pyx":2085
 *         if a_cpu.ndim == 0:
 *             a.fill(a_cpu[()])
 *             return a             # <<<<<<<<<<<<<<
 *         mem = pinned_memory.alloc_pinned_memory(a.nbytes)
 *         src_cpu = numpy.frombuffer(mem, a_cpu.dtype,
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __pyx_r = __pyx_v_a;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2083
 *             raise ValueError('Unsupported dtype %s' % a_dtype)
 *         a = ndarray(a_cpu.shape, dtype=a_dtype, order=order)
 *         if a_cpu.ndim == 0:             # <<<<<<<<<<<<<<
 *             a.fill(a_cpu[()])
 *             return a
 */
    }

    /* "cupy/core/core.pyx":2086
 *             a.fill(a_cpu[()])
 *             return a
 *         mem = pinned_memory.alloc_pinned_memory(a.nbytes)             # <<<<<<<<<<<<<<
 *         src_cpu = numpy.frombuffer(mem, a_cpu.dtype,
 *                                    a_cpu.size).reshape(a_cpu.shape)
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2086, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2086, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = ((PyObject *)__pyx_f_4cupy_4cuda_13pinned_memory_alloc_pinned_memory(__pyx_t_10, 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2086, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_mem = ((struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2087
 *             return a
 *         mem = pinned_memory.alloc_pinned_memory(a.nbytes)
 *         src_cpu = numpy.frombuffer(mem, a_cpu.dtype,             # <<<<<<<<<<<<<<
 *                                    a_cpu.size).reshape(a_cpu.shape)
 *         src_cpu[...] = a_cpu
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2087, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2087, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2087, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);

    /* "cupy/core/core.pyx":2088
 *         mem = pinned_memory.alloc_pinned_memory(a.nbytes)
 *         src_cpu = numpy.frombuffer(mem, a_cpu.dtype,
 *                                    a_cpu.size).reshape(a_cpu.shape)             # <<<<<<<<<<<<<<
 *         src_cpu[...] = a_cpu
 *         stream = stream_module.get_current_stream()
 */
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_size); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2088, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[4] = {__pyx_t_12, ((PyObject *)__pyx_v_mem), __pyx_t_7, __pyx_t_11};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2087, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[4] = {__pyx_t_12, ((PyObject *)__pyx_v_mem), __pyx_t_7, __pyx_t_11};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2087, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_13 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2087, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (__pyx_t_12) {
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_mem));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mem));
      PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_5, ((PyObject *)__pyx_v_mem));
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_5, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_5, __pyx_t_11);
      __pyx_t_7 = 0;
      __pyx_t_11 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_13, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2087, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2088, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2088, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_13 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_13)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_13) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2088, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_8};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2088, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_8};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2088, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2088, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_13); __pyx_t_13 = NULL;
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_8);
        __pyx_t_8 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2088, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_src_cpu = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2089
 *         src_cpu = numpy.frombuffer(mem, a_cpu.dtype,
 *                                    a_cpu.size).reshape(a_cpu.shape)
 *         src_cpu[...] = a_cpu             # <<<<<<<<<<<<<<
 *         stream = stream_module.get_current_stream()
 *         a.set(src_cpu, stream)
 */
    if (unlikely(PyObject_SetItem(__pyx_v_src_cpu, Py_Ellipsis, __pyx_v_a_cpu) < 0)) __PYX_ERR(0, 2089, __pyx_L1_error)

    /* "cupy/core/core.pyx":2090
 *                                    a_cpu.size).reshape(a_cpu.shape)
 *         src_cpu[...] = a_cpu
 *         stream = stream_module.get_current_stream()             # <<<<<<<<<<<<<<
 *         a.set(src_cpu, stream)
 *         pinned_memory._add_to_watch_list(stream.record(), mem)
 */
    __pyx_t_6 = __pyx_f_4cupy_4cuda_6stream_get_current_stream(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2090, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_stream = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2091
 *         src_cpu[...] = a_cpu
 *         stream = stream_module.get_current_stream()
 *         a.set(src_cpu, stream)             # <<<<<<<<<<<<<<
 *         pinned_memory._add_to_watch_list(stream.record(), mem)
 *     return a
 */
    __pyx_t_14.__pyx_n = 1;
    __pyx_t_14.stream = __pyx_v_stream;
    __pyx_t_6 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->set(__pyx_v_a, __pyx_v_src_cpu, 0, &__pyx_t_14); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2091, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2092
 *         stream = stream_module.get_current_stream()
 *         a.set(src_cpu, stream)
 *         pinned_memory._add_to_watch_list(stream.record(), mem)             # <<<<<<<<<<<<<<
 *     return a
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_stream, __pyx_n_s_record); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2092, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_11) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2092, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else {
      __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2092, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __pyx_f_4cupy_4cuda_13pinned_memory__add_to_watch_list(__pyx_t_6, ((PyObject *)__pyx_v_mem), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2092, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":2093
 *         a.set(src_cpu, stream)
 *         pinned_memory._add_to_watch_list(stream.record(), mem)
 *     return a             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_a));
  __pyx_r = __pyx_v_a;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2050
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, str order='K',             # <<<<<<<<<<<<<<
 *                     bint subok=False, Py_ssize_t ndmin=0):
 *     # TODO(beam2d): Support subok options
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("cupy.core.core.array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_src);
  __Pyx_XDECREF((PyObject *)__pyx_v_dev);
  __Pyx_XDECREF(__pyx_v_ndim);
  __Pyx_XDECREF(__pyx_v_a_cpu);
  __Pyx_XDECREF(__pyx_v_a_dtype);
  __Pyx_XDECREF((PyObject *)__pyx_v_mem);
  __Pyx_XDECREF(__pyx_v_src_cpu);
  __Pyx_XDECREF(__pyx_v_stream);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_order);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_49array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_48array[] = "array(obj, dtype=None, bool copy=True, str order='K', bool subok=False, Py_ssize_t ndmin=0) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_49array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_obj = 0;
  PyObject *__pyx_v_dtype = 0;
  int __pyx_v_copy;
  PyObject *__pyx_v_order = 0;
  int __pyx_v_subok;
  Py_ssize_t __pyx_v_ndmin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("array (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_dtype,&__pyx_n_s_copy,&__pyx_n_s_order,&__pyx_n_s_subok,&__pyx_n_s_ndmin,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[3] = ((PyObject*)__pyx_n_s_K);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_obj)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_copy);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_order);
          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_subok);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ndmin);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "array") < 0)) __PYX_ERR(0, 2050, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_obj = values[0];
    __pyx_v_dtype = values[1];
    if (values[2]) {
      __pyx_v_copy = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_copy == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2050, __pyx_L3_error)
    } else {
      __pyx_v_copy = ((int)1);
    }
    __pyx_v_order = ((PyObject*)values[3]);
    if (values[4]) {
      __pyx_v_subok = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_subok == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2051, __pyx_L3_error)
    } else {

      /* "cupy/core/core.pyx":2051
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, str order='K',
 *                     bint subok=False, Py_ssize_t ndmin=0):             # <<<<<<<<<<<<<<
 *     # TODO(beam2d): Support subok options
 *     cdef Py_ssize_t nvidem
 */
      __pyx_v_subok = ((int)0);
    }
    if (values[5]) {
      __pyx_v_ndmin = __Pyx_PyIndex_AsSsize_t(values[5]); if (unlikely((__pyx_v_ndmin == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2051, __pyx_L3_error)
    } else {
      __pyx_v_ndmin = ((Py_ssize_t)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("array", 0, 1, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2050, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_order), (&PyString_Type), 1, "order", 1))) __PYX_ERR(0, 2050, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_48array(__pyx_self, __pyx_v_obj, __pyx_v_dtype, __pyx_v_copy, __pyx_v_order, __pyx_v_subok, __pyx_v_ndmin);

  /* "cupy/core/core.pyx":2050
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, str order='K',             # <<<<<<<<<<<<<<
 *                     bint subok=False, Py_ssize_t ndmin=0):
 *     # TODO(beam2d): Support subok options
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_48array(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj, PyObject *__pyx_v_dtype, int __pyx_v_copy, PyObject *__pyx_v_order, int __pyx_v_subok, Py_ssize_t __pyx_v_ndmin) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_array __pyx_t_2;
  __Pyx_RefNannySetupContext("array", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 5;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.copy = __pyx_v_copy;
  __pyx_t_2.order = __pyx_v_order;
  __pyx_t_2.subok = __pyx_v_subok;
  __pyx_t_2.ndmin = __pyx_v_ndmin;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_v_obj, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2050, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2096
 * 
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         if a._c_contiguous:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_51ascontiguousarray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_ascontiguousarray(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray *__pyx_optional_args) {
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_newarray = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("ascontiguousarray", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_dtype = __pyx_optional_args->dtype;
    }
  }
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/core.pyx":2097
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         if a._c_contiguous:
 *             return a
 */
  __pyx_t_1 = (__pyx_v_dtype == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2098
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     if dtype is None:
 *         if a._c_contiguous:             # <<<<<<<<<<<<<<
 *             return a
 *         dtype = a.dtype
 */
    __pyx_t_2 = (__pyx_v_a->_c_contiguous != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2099
 *     if dtype is None:
 *         if a._c_contiguous:
 *             return a             # <<<<<<<<<<<<<<
 *         dtype = a.dtype
 *     else:
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __pyx_r = __pyx_v_a;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2098
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     if dtype is None:
 *         if a._c_contiguous:             # <<<<<<<<<<<<<<
 *             return a
 *         dtype = a.dtype
 */
    }

    /* "cupy/core/core.pyx":2100
 *         if a._c_contiguous:
 *             return a
 *         dtype = a.dtype             # <<<<<<<<<<<<<<
 *     else:
 *         dtype = get_dtype(dtype)
 */
    __pyx_t_3 = __pyx_v_a->dtype;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2097
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         if a._c_contiguous:
 *             return a
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2102
 *         dtype = a.dtype
 *     else:
 *         dtype = get_dtype(dtype)             # <<<<<<<<<<<<<<
 *         if a._c_contiguous and dtype == a.dtype:
 *             return a
 */
  /*else*/ {
    __pyx_t_3 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2102, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2103
 *     else:
 *         dtype = get_dtype(dtype)
 *         if a._c_contiguous and dtype == a.dtype:             # <<<<<<<<<<<<<<
 *             return a
 * 
 */
    __pyx_t_1 = (__pyx_v_a->_c_contiguous != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_dtype, __pyx_v_a->dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2103, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2103, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2104
 *         dtype = get_dtype(dtype)
 *         if a._c_contiguous and dtype == a.dtype:
 *             return a             # <<<<<<<<<<<<<<
 * 
 *     newarray = ndarray(a.shape, dtype)
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __pyx_r = __pyx_v_a;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2103
 *     else:
 *         dtype = get_dtype(dtype)
 *         if a._c_contiguous and dtype == a.dtype:             # <<<<<<<<<<<<<<
 *             return a
 * 
 */
    }
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":2106
 *             return a
 * 
 *     newarray = ndarray(a.shape, dtype)             # <<<<<<<<<<<<<<
 *     elementwise_copy(a, newarray)
 *     return newarray
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_dtype);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2107
 * 
 *     newarray = ndarray(a.shape, dtype)
 *     elementwise_copy(a, newarray)             # <<<<<<<<<<<<<<
 *     return newarray
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  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_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2107, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2107, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_a));
    __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_newarray));
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_newarray));
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2108
 *     newarray = ndarray(a.shape, dtype)
 *     elementwise_copy(a, newarray)
 *     return newarray             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
  __pyx_r = __pyx_v_newarray;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2096
 * 
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         if a._c_contiguous:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core.ascontiguousarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_newarray);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_51ascontiguousarray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_50ascontiguousarray[] = "ascontiguousarray(ndarray a, dtype=None) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_51ascontiguousarray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ascontiguousarray (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_dtype,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "ascontiguousarray") < 0)) __PYX_ERR(0, 2096, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_dtype = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("ascontiguousarray", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2096, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ascontiguousarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2096, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_50ascontiguousarray(__pyx_self, __pyx_v_a, __pyx_v_dtype);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_50ascontiguousarray(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray __pyx_t_2;
  __Pyx_RefNannySetupContext("ascontiguousarray", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_ascontiguousarray(__pyx_v_a, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2096, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ascontiguousarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2111
 * 
 * 
 * cpdef ndarray asfortranarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     cdef ndarray newarray
 *     cdef int m, n
 */

static PyObject *__pyx_pw_4cupy_4core_4core_53asfortranarray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_asfortranarray(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_asfortranarray *__pyx_optional_args) {
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_newarray = 0;
  int __pyx_v_m;
  int __pyx_v_n;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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)(PyObject *);
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  __Pyx_RefNannySetupContext("asfortranarray", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_dtype = __pyx_optional_args->dtype;
    }
  }
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/core.pyx":2115
 *     cdef int m, n
 * 
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         if a._f_contiguous:
 *             return a
 */
  __pyx_t_1 = (__pyx_v_dtype == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2116
 * 
 *     if dtype is None:
 *         if a._f_contiguous:             # <<<<<<<<<<<<<<
 *             return a
 *         dtype = a.dtype
 */
    __pyx_t_2 = (__pyx_v_a->_f_contiguous != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2117
 *     if dtype is None:
 *         if a._f_contiguous:
 *             return a             # <<<<<<<<<<<<<<
 *         dtype = a.dtype
 *     else:
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __pyx_r = __pyx_v_a;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2116
 * 
 *     if dtype is None:
 *         if a._f_contiguous:             # <<<<<<<<<<<<<<
 *             return a
 *         dtype = a.dtype
 */
    }

    /* "cupy/core/core.pyx":2118
 *         if a._f_contiguous:
 *             return a
 *         dtype = a.dtype             # <<<<<<<<<<<<<<
 *     else:
 *         dtype = get_dtype(dtype)
 */
    __pyx_t_3 = __pyx_v_a->dtype;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2115
 *     cdef int m, n
 * 
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         if a._f_contiguous:
 *             return a
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2120
 *         dtype = a.dtype
 *     else:
 *         dtype = get_dtype(dtype)             # <<<<<<<<<<<<<<
 *         if a._f_contiguous and dtype == a.dtype:
 *             return a
 */
  /*else*/ {
    __pyx_t_3 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2120, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2121
 *     else:
 *         dtype = get_dtype(dtype)
 *         if a._f_contiguous and dtype == a.dtype:             # <<<<<<<<<<<<<<
 *             return a
 * 
 */
    __pyx_t_1 = (__pyx_v_a->_f_contiguous != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_dtype, __pyx_v_a->dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2121, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2121, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2122
 *         dtype = get_dtype(dtype)
 *         if a._f_contiguous and dtype == a.dtype:
 *             return a             # <<<<<<<<<<<<<<
 * 
 *     newarray = ndarray(a.shape, dtype, order='F')
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __pyx_r = __pyx_v_a;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2121
 *     else:
 *         dtype = get_dtype(dtype)
 *         if a._f_contiguous and dtype == a.dtype:             # <<<<<<<<<<<<<<
 *             return a
 * 
 */
    }
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":2124
 *             return a
 * 
 *     newarray = ndarray(a.shape, dtype, order='F')             # <<<<<<<<<<<<<<
 *     if (a.flags.c_contiguous and
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64) and
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_dtype);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_order, __pyx_n_s_F) < 0) __PYX_ERR(0, 2124, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2125
 * 
 *     newarray = ndarray(a.shape, dtype, order='F')
 *     if (a.flags.c_contiguous and             # <<<<<<<<<<<<<<
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64) and
 *             a.ndim == 2 and dtype == a.dtype):
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_flags); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_c_contiguous); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2125, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L9_bool_binop_done;
  }

  /* "cupy/core/core.pyx":2126
 *     newarray = ndarray(a.shape, dtype, order='F')
 *     if (a.flags.c_contiguous and
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64) and             # <<<<<<<<<<<<<<
 *             a.ndim == 2 and dtype == a.dtype):
 *         m, n = a.shape
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float32); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2126, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2126, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!__pyx_t_1) {
  } else {
    goto __pyx_L11_next_and;
  }
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2126, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2126, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_L11_next_and:;

  /* "cupy/core/core.pyx":2127
 *     if (a.flags.c_contiguous and
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64) and
 *             a.ndim == 2 and dtype == a.dtype):             # <<<<<<<<<<<<<<
 *         m, n = a.shape
 *         if a.dtype == numpy.float32:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2127, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_5 = PyObject_RichCompare(__pyx_v_dtype, __pyx_v_a->dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2127, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2127, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = __pyx_t_1;
  __pyx_L9_bool_binop_done:;

  /* "cupy/core/core.pyx":2125
 * 
 *     newarray = ndarray(a.shape, dtype, order='F')
 *     if (a.flags.c_contiguous and             # <<<<<<<<<<<<<<
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64) and
 *             a.ndim == 2 and dtype == a.dtype):
 */
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2128
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64) and
 *             a.ndim == 2 and dtype == a.dtype):
 *         m, n = a.shape             # <<<<<<<<<<<<<<
 *         if a.dtype == numpy.float32:
 *             cuda.cublas.sgeam(
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2128, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
      PyObject* sequence = __pyx_t_5;
      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(0, 2128, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_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(0, 2128, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2128, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2128, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L14_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_4 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L14_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) __PYX_ERR(0, 2128, __pyx_L1_error)
      __pyx_t_7 = NULL;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L15_unpacking_done;
      __pyx_L14_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 2128, __pyx_L1_error)
      __pyx_L15_unpacking_done:;
    }
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2128, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2128, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_m = __pyx_t_8;
    __pyx_v_n = __pyx_t_9;

    /* "cupy/core/core.pyx":2129
 *             a.ndim == 2 and dtype == a.dtype):
 *         m, n = a.shape
 *         if a.dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *             cuda.cublas.sgeam(
 *                 cuda.Device().cublas_handle,
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_float32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2129, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2129, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2130
 *         m, n = a.shape
 *         if a.dtype == numpy.float32:
 *             cuda.cublas.sgeam(             # <<<<<<<<<<<<<<
 *                 cuda.Device().cublas_handle,
 *                 1,  # transpose a
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2130, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_cublas); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2130, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sgeam); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2130, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":2131
 *         if a.dtype == numpy.float32:
 *             cuda.cublas.sgeam(
 *                 cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *                 1,  # transpose a
 *                 1,  # transpose newarray
 */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2131, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_Device); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2131, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      if (__pyx_t_6) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2131, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else {
        __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2131, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2131, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":2134
 *                 1,  # transpose a
 *                 1,  # transpose newarray
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,             # <<<<<<<<<<<<<<
 *                 newarray.data.ptr, m)
 *         elif a.dtype == numpy.float64:
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_m); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2134, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2134, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_11 = __Pyx_PyInt_FromSize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2134, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2134, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = __Pyx_PyInt_FromSize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2134, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2134, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);

      /* "cupy/core/core.pyx":2135
 *                 1,  # transpose newarray
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,
 *                 newarray.data.ptr, m)             # <<<<<<<<<<<<<<
 *         elif a.dtype == numpy.float64:
 *             cuda.cublas.dgeam(
 */
      __pyx_t_15 = __Pyx_PyInt_FromSize_t(__pyx_v_newarray->data->ptr); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2135, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_16 = __Pyx_PyInt_From_int(__pyx_v_m); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2135, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_17 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_17)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_17);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[14] = {__pyx_t_17, __pyx_t_10, __pyx_int_1, __pyx_int_1, __pyx_t_3, __pyx_t_6, __pyx_float_1_, __pyx_t_11, __pyx_t_12, __pyx_float_0_, __pyx_t_13, __pyx_t_14, __pyx_t_15, __pyx_t_16};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 13+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2130, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[14] = {__pyx_t_17, __pyx_t_10, __pyx_int_1, __pyx_int_1, __pyx_t_3, __pyx_t_6, __pyx_float_1_, __pyx_t_11, __pyx_t_12, __pyx_float_0_, __pyx_t_13, __pyx_t_14, __pyx_t_15, __pyx_t_16};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 13+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2130, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      } else
      #endif
      {
        __pyx_t_18 = PyTuple_New(13+__pyx_t_9); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2130, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_18);
        if (__pyx_t_17) {
          __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_17); __pyx_t_17 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_9, __pyx_t_10);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_9, __pyx_int_1);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_18, 2+__pyx_t_9, __pyx_int_1);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_18, 3+__pyx_t_9, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_18, 4+__pyx_t_9, __pyx_t_6);
        __Pyx_INCREF(__pyx_float_1_);
        __Pyx_GIVEREF(__pyx_float_1_);
        PyTuple_SET_ITEM(__pyx_t_18, 5+__pyx_t_9, __pyx_float_1_);
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_18, 6+__pyx_t_9, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_18, 7+__pyx_t_9, __pyx_t_12);
        __Pyx_INCREF(__pyx_float_0_);
        __Pyx_GIVEREF(__pyx_float_0_);
        PyTuple_SET_ITEM(__pyx_t_18, 8+__pyx_t_9, __pyx_float_0_);
        __Pyx_GIVEREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_18, 9+__pyx_t_9, __pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_18, 10+__pyx_t_9, __pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_18, 11+__pyx_t_9, __pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_16);
        PyTuple_SET_ITEM(__pyx_t_18, 12+__pyx_t_9, __pyx_t_16);
        __pyx_t_10 = 0;
        __pyx_t_3 = 0;
        __pyx_t_6 = 0;
        __pyx_t_11 = 0;
        __pyx_t_12 = 0;
        __pyx_t_13 = 0;
        __pyx_t_14 = 0;
        __pyx_t_15 = 0;
        __pyx_t_16 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_18, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2130, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/core/core.pyx":2129
 *             a.ndim == 2 and dtype == a.dtype):
 *         m, n = a.shape
 *         if a.dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *             cuda.cublas.sgeam(
 *                 cuda.Device().cublas_handle,
 */
      goto __pyx_L16;
    }

    /* "cupy/core/core.pyx":2136
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,
 *                 newarray.data.ptr, m)
 *         elif a.dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *             cuda.cublas.dgeam(
 *                 cuda.Device().cublas_handle,
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2136, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_float64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2136, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2136, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2136, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2137
 *                 newarray.data.ptr, m)
 *         elif a.dtype == numpy.float64:
 *             cuda.cublas.dgeam(             # <<<<<<<<<<<<<<
 *                 cuda.Device().cublas_handle,
 *                 1,  # transpose a
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2137, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_cublas); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2137, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_n_s_dgeam); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2137, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

      /* "cupy/core/core.pyx":2138
 *         elif a.dtype == numpy.float64:
 *             cuda.cublas.dgeam(
 *                 cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *                 1,  # transpose a
 *                 1,  # transpose newarray
 */
      __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_Device); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_16 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
        __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_15);
        if (likely(__pyx_t_16)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_16);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_15, function);
        }
      }
      if (__pyx_t_16) {
        __pyx_t_18 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_16); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2138, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      } else {
        __pyx_t_18 = __Pyx_PyObject_CallNoArg(__pyx_t_15); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2138, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_18);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

      /* "cupy/core/core.pyx":2141
 *                 1,  # transpose a
 *                 1,  # transpose newarray
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,             # <<<<<<<<<<<<<<
 *                 newarray.data.ptr, m)
 *         return newarray
 */
      __pyx_t_18 = __Pyx_PyInt_From_int(__pyx_v_m); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_16 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_14 = __Pyx_PyInt_FromSize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_12 = __Pyx_PyInt_FromSize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);

      /* "cupy/core/core.pyx":2142
 *                 1,  # transpose newarray
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,
 *                 newarray.data.ptr, m)             # <<<<<<<<<<<<<<
 *         return newarray
 *     else:
 */
      __pyx_t_6 = __Pyx_PyInt_FromSize_t(__pyx_v_newarray->data->ptr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2142, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_m); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2142, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[14] = {__pyx_t_10, __pyx_t_15, __pyx_int_1, __pyx_int_1, __pyx_t_18, __pyx_t_16, __pyx_float_1_, __pyx_t_14, __pyx_t_13, __pyx_float_0_, __pyx_t_12, __pyx_t_11, __pyx_t_6, __pyx_t_3};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 13+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2137, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[14] = {__pyx_t_10, __pyx_t_15, __pyx_int_1, __pyx_int_1, __pyx_t_18, __pyx_t_16, __pyx_float_1_, __pyx_t_14, __pyx_t_13, __pyx_float_0_, __pyx_t_12, __pyx_t_11, __pyx_t_6, __pyx_t_3};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 13+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2137, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      {
        __pyx_t_17 = PyTuple_New(13+__pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2137, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_17);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_9, __pyx_t_15);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_9, __pyx_int_1);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_17, 2+__pyx_t_9, __pyx_int_1);
        __Pyx_GIVEREF(__pyx_t_18);
        PyTuple_SET_ITEM(__pyx_t_17, 3+__pyx_t_9, __pyx_t_18);
        __Pyx_GIVEREF(__pyx_t_16);
        PyTuple_SET_ITEM(__pyx_t_17, 4+__pyx_t_9, __pyx_t_16);
        __Pyx_INCREF(__pyx_float_1_);
        __Pyx_GIVEREF(__pyx_float_1_);
        PyTuple_SET_ITEM(__pyx_t_17, 5+__pyx_t_9, __pyx_float_1_);
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_17, 6+__pyx_t_9, __pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_17, 7+__pyx_t_9, __pyx_t_13);
        __Pyx_INCREF(__pyx_float_0_);
        __Pyx_GIVEREF(__pyx_float_0_);
        PyTuple_SET_ITEM(__pyx_t_17, 8+__pyx_t_9, __pyx_float_0_);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_17, 9+__pyx_t_9, __pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_17, 10+__pyx_t_9, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_17, 11+__pyx_t_9, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_17, 12+__pyx_t_9, __pyx_t_3);
        __pyx_t_15 = 0;
        __pyx_t_18 = 0;
        __pyx_t_16 = 0;
        __pyx_t_14 = 0;
        __pyx_t_13 = 0;
        __pyx_t_12 = 0;
        __pyx_t_11 = 0;
        __pyx_t_6 = 0;
        __pyx_t_3 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_17, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2137, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/core/core.pyx":2136
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,
 *                 newarray.data.ptr, m)
 *         elif a.dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *             cuda.cublas.dgeam(
 *                 cuda.Device().cublas_handle,
 */
    }
    __pyx_L16:;

    /* "cupy/core/core.pyx":2143
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,
 *                 newarray.data.ptr, m)
 *         return newarray             # <<<<<<<<<<<<<<
 *     else:
 *         elementwise_copy(a, newarray)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
    __pyx_r = __pyx_v_newarray;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2125
 * 
 *     newarray = ndarray(a.shape, dtype, order='F')
 *     if (a.flags.c_contiguous and             # <<<<<<<<<<<<<<
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64) and
 *             a.ndim == 2 and dtype == a.dtype):
 */
  }

  /* "cupy/core/core.pyx":2145
 *         return newarray
 *     else:
 *         elementwise_copy(a, newarray)             # <<<<<<<<<<<<<<
 *         return newarray
 * 
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2145, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_17 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_17)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_17);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_17, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2145, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_17, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2145, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2145, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_17) {
        __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_17); __pyx_t_17 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, ((PyObject *)__pyx_v_a));
      __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_newarray));
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, ((PyObject *)__pyx_v_newarray));
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2145, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2146
 *     else:
 *         elementwise_copy(a, newarray)
 *         return newarray             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
    __pyx_r = __pyx_v_newarray;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":2111
 * 
 * 
 * cpdef ndarray asfortranarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     cdef ndarray newarray
 *     cdef int m, n
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_AddTraceback("cupy.core.core.asfortranarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_newarray);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_53asfortranarray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_52asfortranarray[] = "asfortranarray(ndarray a, dtype=None) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_53asfortranarray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("asfortranarray (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_dtype,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "asfortranarray") < 0)) __PYX_ERR(0, 2111, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_dtype = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("asfortranarray", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2111, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.asfortranarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2111, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_52asfortranarray(__pyx_self, __pyx_v_a, __pyx_v_dtype);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_52asfortranarray(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_asfortranarray __pyx_t_2;
  __Pyx_RefNannySetupContext("asfortranarray", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_asfortranarray(__pyx_v_a, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.asfortranarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2153
 * # -----------------------------------------------------------------------------
 * 
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):             # <<<<<<<<<<<<<<
 *     for elem in source:
 *         if elem == n:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_55_has_element(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_54_has_element[] = "_has_element(vector[Py_ssize_t] source, Py_ssize_t n)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_55_has_element = {"_has_element", (PyCFunction)__pyx_pw_4cupy_4core_4core_55_has_element, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_54_has_element};
static PyObject *__pyx_pw_4cupy_4core_4core_55_has_element(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  std::vector<Py_ssize_t>  __pyx_v_source;
  Py_ssize_t __pyx_v_n;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_has_element (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,&__pyx_n_s_n,0};
    PyObject* values[2] = {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  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_source)) != 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_n)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_has_element", 1, 2, 2, 1); __PYX_ERR(0, 2153, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_has_element") < 0)) __PYX_ERR(0, 2153, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_source = __pyx_convert_vector_from_py_Py_ssize_t(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2153, __pyx_L3_error)
    __pyx_v_n = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_n == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2153, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_has_element", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2153, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._has_element", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_54_has_element(__pyx_self, __pyx_v_source, __pyx_v_n);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_54_has_element(CYTHON_UNUSED PyObject *__pyx_self, std::vector<Py_ssize_t>  __pyx_v_source, Py_ssize_t __pyx_v_n) {
  Py_ssize_t __pyx_v_elem;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  std::vector<Py_ssize_t> ::iterator __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("_has_element", 0);

  /* "cupy/core/core.pyx":2154
 * 
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):
 *     for elem in source:             # <<<<<<<<<<<<<<
 *         if elem == n:
 *             return True
 */
  __pyx_t_1 = __pyx_v_source.begin();
  for (;;) {
    if (!(__pyx_t_1 != __pyx_v_source.end())) break;
    __pyx_t_2 = *__pyx_t_1;
    ++__pyx_t_1;
    __pyx_v_elem = __pyx_t_2;

    /* "cupy/core/core.pyx":2155
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):
 *     for elem in source:
 *         if elem == n:             # <<<<<<<<<<<<<<
 *             return True
 *     return False
 */
    __pyx_t_3 = ((__pyx_v_elem == __pyx_v_n) != 0);
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":2156
 *     for elem in source:
 *         if elem == n:
 *             return True             # <<<<<<<<<<<<<<
 *     return False
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2155
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):
 *     for elem in source:
 *         if elem == n:             # <<<<<<<<<<<<<<
 *             return True
 *     return False
 */
    }

    /* "cupy/core/core.pyx":2154
 * 
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):
 *     for elem in source:             # <<<<<<<<<<<<<<
 *         if elem == n:
 *             return True
 */
  }

  /* "cupy/core/core.pyx":2157
 *         if elem == n:
 *             return True
 *     return False             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_False);
  __pyx_r = Py_False;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2153
 * # -----------------------------------------------------------------------------
 * 
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):             # <<<<<<<<<<<<<<
 *     for elem in source:
 *         if elem == n:
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2160
 * 
 * 
 * cpdef vector.vector[Py_ssize_t] normalize_axis_tuple(axis, Py_ssize_t ndim) \             # <<<<<<<<<<<<<<
 *         except *:
 *     """Normalizes an axis argument into a tuple of non-negative integer axes.
 */

static PyObject *__pyx_pw_4cupy_4core_4core_57normalize_axis_tuple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static std::vector<Py_ssize_t>  __pyx_f_4cupy_4core_4core_normalize_axis_tuple(PyObject *__pyx_v_axis, Py_ssize_t __pyx_v_ndim, CYTHON_UNUSED int __pyx_skip_dispatch) {
  std::vector<Py_ssize_t>  __pyx_v_ret;
  PyObject *__pyx_v_ax = NULL;
  std::vector<Py_ssize_t>  __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_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  Py_ssize_t __pyx_t_14;
  __Pyx_RefNannySetupContext("normalize_axis_tuple", 0);
  __Pyx_INCREF(__pyx_v_axis);

  /* "cupy/core/core.pyx":2167
 * 
 *     """
 *     if numpy.isscalar(axis):             # <<<<<<<<<<<<<<
 *         axis = (axis,)
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_isscalar); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __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);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_axis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2167, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_axis};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2167, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_axis};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2167, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2167, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_axis);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2167, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2167, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":2168
 *     """
 *     if numpy.isscalar(axis):
 *         axis = (axis,)             # <<<<<<<<<<<<<<
 * 
 *     cdef vector.vector[Py_ssize_t] ret
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2168, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_axis);
    __Pyx_GIVEREF(__pyx_v_axis);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_axis);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2167
 * 
 *     """
 *     if numpy.isscalar(axis):             # <<<<<<<<<<<<<<
 *         axis = (axis,)
 * 
 */
  }

  /* "cupy/core/core.pyx":2171
 * 
 *     cdef vector.vector[Py_ssize_t] ret
 *     for ax in axis:             # <<<<<<<<<<<<<<
 *         if ax >= ndim or ax < -ndim:
 *             raise _AxisError('axis {} is out of bounds for array of '
 */
  if (likely(PyList_CheckExact(__pyx_v_axis)) || PyTuple_CheckExact(__pyx_v_axis)) {
    __pyx_t_1 = __pyx_v_axis; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_axis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2171, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2171, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 2171, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2171, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 2171, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2171, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2171, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_ax, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2172
 *     cdef vector.vector[Py_ssize_t] ret
 *     for ax in axis:
 *         if ax >= ndim or ax < -ndim:             # <<<<<<<<<<<<<<
 *             raise _AxisError('axis {} is out of bounds for array of '
 *                              'dimension {}'.format(ax, ndim))
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_ax, __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2172, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 2172, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!__pyx_t_8) {
    } else {
      __pyx_t_5 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_4 = PyInt_FromSsize_t((-__pyx_v_ndim)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_ax, __pyx_t_4, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2172, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 2172, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = __pyx_t_8;
    __pyx_L7_bool_binop_done:;
    if (unlikely(__pyx_t_5)) {

      /* "cupy/core/core.pyx":2173
 *     for ax in axis:
 *         if ax >= ndim or ax < -ndim:
 *             raise _AxisError('axis {} is out of bounds for array of '             # <<<<<<<<<<<<<<
 *                              'dimension {}'.format(ax, ndim))
 *         if _has_element(ret, ax):
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2173, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);

      /* "cupy/core/core.pyx":2174
 *         if ax >= ndim or ax < -ndim:
 *             raise _AxisError('axis {} is out of bounds for array of '
 *                              'dimension {}'.format(ax, ndim))             # <<<<<<<<<<<<<<
 *         if _has_element(ret, ax):
 *             raise _AxisError('repeated axis')
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_axis_is_out_of_bounds_for_array, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = NULL;
      __pyx_t_12 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_12 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_ax, __pyx_t_10};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2174, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_ax, __pyx_t_10};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2174, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else
      #endif
      {
        __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2174, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        if (__pyx_t_11) {
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); __pyx_t_11 = NULL;
        }
        __Pyx_INCREF(__pyx_v_ax);
        __Pyx_GIVEREF(__pyx_v_ax);
        PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_v_ax);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_10);
        __pyx_t_10 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2174, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_9) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2173, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_2};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2173, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_2};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2173, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        } else
        #endif
        {
          __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2173, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_9); __pyx_t_9 = NULL;
          __Pyx_GIVEREF(__pyx_t_2);
          PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_2);
          __pyx_t_2 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2173, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
      }
      __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(0, 2173, __pyx_L1_error)

      /* "cupy/core/core.pyx":2172
 *     cdef vector.vector[Py_ssize_t] ret
 *     for ax in axis:
 *         if ax >= ndim or ax < -ndim:             # <<<<<<<<<<<<<<
 *             raise _AxisError('axis {} is out of bounds for array of '
 *                              'dimension {}'.format(ax, ndim))
 */
    }

    /* "cupy/core/core.pyx":2175
 *             raise _AxisError('axis {} is out of bounds for array of '
 *                              'dimension {}'.format(ax, ndim))
 *         if _has_element(ret, ax):             # <<<<<<<<<<<<<<
 *             raise _AxisError('repeated axis')
 *         ret.push_back(ax % ndim)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_has_element); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2175, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_13 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_ret); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2175, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_2 = NULL;
    __pyx_t_12 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_12 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_13, __pyx_v_ax};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2175, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_13, __pyx_v_ax};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2175, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2175, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_13);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_12, __pyx_t_13);
      __Pyx_INCREF(__pyx_v_ax);
      __Pyx_GIVEREF(__pyx_v_ax);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_12, __pyx_v_ax);
      __pyx_t_13 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2175, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2175, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(__pyx_t_5)) {

      /* "cupy/core/core.pyx":2176
 *                              'dimension {}'.format(ax, ndim))
 *         if _has_element(ret, ax):
 *             raise _AxisError('repeated axis')             # <<<<<<<<<<<<<<
 *         ret.push_back(ax % ndim)
 * 
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2176, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2176, __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(0, 2176, __pyx_L1_error)

      /* "cupy/core/core.pyx":2175
 *             raise _AxisError('axis {} is out of bounds for array of '
 *                              'dimension {}'.format(ax, ndim))
 *         if _has_element(ret, ax):             # <<<<<<<<<<<<<<
 *             raise _AxisError('repeated axis')
 *         ret.push_back(ax % ndim)
 */
    }

    /* "cupy/core/core.pyx":2177
 *         if _has_element(ret, ax):
 *             raise _AxisError('repeated axis')
 *         ret.push_back(ax % ndim)             # <<<<<<<<<<<<<<
 * 
 *     return ret
 */
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2177, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_Remainder(__pyx_v_ax, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2177, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2177, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    try {
      __pyx_v_ret.push_back(__pyx_t_14);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2177, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2171
 * 
 *     cdef vector.vector[Py_ssize_t] ret
 *     for ax in axis:             # <<<<<<<<<<<<<<
 *         if ax >= ndim or ax < -ndim:
 *             raise _AxisError('axis {} is out of bounds for array of '
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2179
 *         ret.push_back(ax % ndim)
 * 
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2160
 * 
 * 
 * cpdef vector.vector[Py_ssize_t] normalize_axis_tuple(axis, Py_ssize_t ndim) \             # <<<<<<<<<<<<<<
 *         except *:
 *     """Normalizes an axis argument into a tuple of non-negative integer axes.
 */

  /* 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_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("cupy.core.core.normalize_axis_tuple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ax);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_57normalize_axis_tuple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_56normalize_axis_tuple[] = "normalize_axis_tuple(axis, Py_ssize_t ndim) -> vector[Py_ssize_t]\nNormalizes an axis argument into a tuple of non-negative integer axes.\n\n    Arguments `allow_duplicate` and `axis_name` are not supported.\n\n    ";
static PyObject *__pyx_pw_4cupy_4core_4core_57normalize_axis_tuple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  Py_ssize_t __pyx_v_ndim;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("normalize_axis_tuple (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_ndim,0};
    PyObject* values[2] = {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  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_axis)) != 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_ndim)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("normalize_axis_tuple", 1, 2, 2, 1); __PYX_ERR(0, 2160, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "normalize_axis_tuple") < 0)) __PYX_ERR(0, 2160, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_axis = values[0];
    __pyx_v_ndim = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_ndim == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2160, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("normalize_axis_tuple", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2160, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.normalize_axis_tuple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_56normalize_axis_tuple(__pyx_self, __pyx_v_axis, __pyx_v_ndim);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_56normalize_axis_tuple(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_axis, Py_ssize_t __pyx_v_ndim) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  std::vector<Py_ssize_t>  __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("normalize_axis_tuple", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_normalize_axis_tuple(__pyx_v_axis, __pyx_v_ndim, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2160, __pyx_L1_error)
  __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.normalize_axis_tuple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2182
 * 
 * 
 * cpdef ndarray moveaxis(ndarray a, source, destination):             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] src = normalize_axis_tuple(source, a.ndim)
 *     cdef vector.vector[Py_ssize_t] dest = normalize_axis_tuple(destination,
 */

static PyObject *__pyx_pw_4cupy_4core_4core_59moveaxis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_moveaxis(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_source, PyObject *__pyx_v_destination, CYTHON_UNUSED int __pyx_skip_dispatch) {
  std::vector<Py_ssize_t>  __pyx_v_src;
  std::vector<Py_ssize_t>  __pyx_v_dest;
  std::vector<Py_ssize_t>  __pyx_v_order;
  Py_ssize_t __pyx_v_n;
  PyObject *__pyx_v_i = NULL;
  Py_ssize_t __pyx_v_d;
  Py_ssize_t __pyx_v_s;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  std::vector<Py_ssize_t>  __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  int __pyx_t_15;
  PyObject *(*__pyx_t_16)(PyObject *);
  Py_ssize_t __pyx_t_17;
  __Pyx_RefNannySetupContext("moveaxis", 0);

  /* "cupy/core/core.pyx":2183
 * 
 * cpdef ndarray moveaxis(ndarray a, source, destination):
 *     cdef vector.vector[Py_ssize_t] src = normalize_axis_tuple(source, a.ndim)             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] dest = normalize_axis_tuple(destination,
 *                                                                a.ndim)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2183, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_f_4cupy_4core_4core_normalize_axis_tuple(__pyx_v_source, __pyx_t_2, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2183, __pyx_L1_error)
  __pyx_v_src = __pyx_t_3;

  /* "cupy/core/core.pyx":2185
 *     cdef vector.vector[Py_ssize_t] src = normalize_axis_tuple(source, a.ndim)
 *     cdef vector.vector[Py_ssize_t] dest = normalize_axis_tuple(destination,
 *                                                                a.ndim)             # <<<<<<<<<<<<<<
 * 
 *     if len(src) != len(dest):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2185, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2184
 * cpdef ndarray moveaxis(ndarray a, source, destination):
 *     cdef vector.vector[Py_ssize_t] src = normalize_axis_tuple(source, a.ndim)
 *     cdef vector.vector[Py_ssize_t] dest = normalize_axis_tuple(destination,             # <<<<<<<<<<<<<<
 *                                                                a.ndim)
 * 
 */
  __pyx_t_3 = __pyx_f_4cupy_4core_4core_normalize_axis_tuple(__pyx_v_destination, __pyx_t_2, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2184, __pyx_L1_error)
  __pyx_v_dest = __pyx_t_3;

  /* "cupy/core/core.pyx":2187
 *                                                                a.ndim)
 * 
 *     if len(src) != len(dest):             # <<<<<<<<<<<<<<
 *         raise ValueError('`source` and `destination` arguments must have '
 *                          'the same number of elements')
 */
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_src); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2187, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_dest); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2187, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_2 != __pyx_t_4) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "cupy/core/core.pyx":2188
 * 
 *     if len(src) != len(dest):
 *         raise ValueError('`source` and `destination` arguments must have '             # <<<<<<<<<<<<<<
 *                          'the same number of elements')
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2188, __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(0, 2188, __pyx_L1_error)

    /* "cupy/core/core.pyx":2187
 *                                                                a.ndim)
 * 
 *     if len(src) != len(dest):             # <<<<<<<<<<<<<<
 *         raise ValueError('`source` and `destination` arguments must have '
 *                          'the same number of elements')
 */
  }

  /* "cupy/core/core.pyx":2192
 * 
 *     cdef vector.vector[Py_ssize_t] order
 *     cdef Py_ssize_t n = 0             # <<<<<<<<<<<<<<
 *     for i in range(a.ndim):
 *         n = <Py_ssize_t>i
 */
  __pyx_v_n = 0;

  /* "cupy/core/core.pyx":2193
 *     cdef vector.vector[Py_ssize_t] order
 *     cdef Py_ssize_t n = 0
 *     for i in range(a.ndim):             # <<<<<<<<<<<<<<
 *         n = <Py_ssize_t>i
 *         if not _has_element(src, n):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) {
    __pyx_t_1 = __pyx_t_6; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2193, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2193, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2193, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2193, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2193, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2193, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2193, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2194
 *     cdef Py_ssize_t n = 0
 *     for i in range(a.ndim):
 *         n = <Py_ssize_t>i             # <<<<<<<<<<<<<<
 *         if not _has_element(src, n):
 *             order.push_back(n)
 */
    __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2194, __pyx_L1_error)
    __pyx_v_n = ((Py_ssize_t)__pyx_t_2);

    /* "cupy/core/core.pyx":2195
 *     for i in range(a.ndim):
 *         n = <Py_ssize_t>i
 *         if not _has_element(src, n):             # <<<<<<<<<<<<<<
 *             order.push_back(n)
 * 
 */
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_has_element); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_src); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = NULL;
    __pyx_t_12 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
        __pyx_t_12 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_9, __pyx_t_10};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2195, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_9, __pyx_t_10};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2195, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2195, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (__pyx_t_11) {
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); __pyx_t_11 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_10);
      __pyx_t_9 = 0;
      __pyx_t_10 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2195, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2195, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_14 = ((!__pyx_t_5) != 0);
    if (__pyx_t_14) {

      /* "cupy/core/core.pyx":2196
 *         n = <Py_ssize_t>i
 *         if not _has_element(src, n):
 *             order.push_back(n)             # <<<<<<<<<<<<<<
 * 
 *     cdef Py_ssize_t d, s
 */
      try {
        __pyx_v_order.push_back(__pyx_v_n);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 2196, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":2195
 *     for i in range(a.ndim):
 *         n = <Py_ssize_t>i
 *         if not _has_element(src, n):             # <<<<<<<<<<<<<<
 *             order.push_back(n)
 * 
 */
    }

    /* "cupy/core/core.pyx":2193
 *     cdef vector.vector[Py_ssize_t] order
 *     cdef Py_ssize_t n = 0
 *     for i in range(a.ndim):             # <<<<<<<<<<<<<<
 *         n = <Py_ssize_t>i
 *         if not _has_element(src, n):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2199
 * 
 *     cdef Py_ssize_t d, s
 *     for d, s in sorted(zip(dest, src)):             # <<<<<<<<<<<<<<
 *         order.insert(order.begin() + d, s)
 * 
 */
  __pyx_t_6 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_dest); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_src); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_8);
  __pyx_t_6 = 0;
  __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_13, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = PySequence_List(__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_1 = ((PyObject*)__pyx_t_13);
  __pyx_t_13 = 0;
  __pyx_t_15 = PyList_Sort(__pyx_t_1); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 2199, __pyx_L1_error)
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 2199, __pyx_L1_error)
  }
  __pyx_t_13 = __pyx_t_1; __Pyx_INCREF(__pyx_t_13); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_13)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyList_GET_ITEM(__pyx_t_13, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2199, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_13, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2199, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      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(0, 2199, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_16 = Py_TYPE(__pyx_t_10)->tp_iternext;
      index = 0; __pyx_t_8 = __pyx_t_16(__pyx_t_10); if (unlikely(!__pyx_t_8)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_8);
      index = 1; __pyx_t_6 = __pyx_t_16(__pyx_t_10); if (unlikely(!__pyx_t_6)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_10), 2) < 0) __PYX_ERR(0, 2199, __pyx_L1_error)
      __pyx_t_16 = NULL;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L10_unpacking_done;
      __pyx_L9_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_16 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 2199, __pyx_L1_error)
      __pyx_L10_unpacking_done:;
    }
    __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2199, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_17 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_17 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2199, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_d = __pyx_t_2;
    __pyx_v_s = __pyx_t_17;

    /* "cupy/core/core.pyx":2200
 *     cdef Py_ssize_t d, s
 *     for d, s in sorted(zip(dest, src)):
 *         order.insert(order.begin() + d, s)             # <<<<<<<<<<<<<<
 * 
 *     return a.transpose(order)
 */
    try {
      __pyx_v_order.insert((__pyx_v_order.begin() + __pyx_v_d), __pyx_v_s);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2200, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2199
 * 
 *     cdef Py_ssize_t d, s
 *     for d, s in sorted(zip(dest, src)):             # <<<<<<<<<<<<<<
 *         order.insert(order.begin() + d, s)
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":2202
 *         order.insert(order.begin() + d, s)
 * 
 *     return a.transpose(order)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_order); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2202, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_13);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
      __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2202, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
      __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2202, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2202, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2202, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2202, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_13);
  __pyx_t_13 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2182
 * 
 * 
 * cpdef ndarray moveaxis(ndarray a, source, destination):             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] src = normalize_axis_tuple(source, a.ndim)
 *     cdef vector.vector[Py_ssize_t] dest = normalize_axis_tuple(destination,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("cupy.core.core.moveaxis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_59moveaxis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_58moveaxis[] = "moveaxis(ndarray a, source, destination) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_59moveaxis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_source = 0;
  PyObject *__pyx_v_destination = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("moveaxis (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_source,&__pyx_n_s_destination,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_a)) != 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_source)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("moveaxis", 1, 3, 3, 1); __PYX_ERR(0, 2182, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_destination)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("moveaxis", 1, 3, 3, 2); __PYX_ERR(0, 2182, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "moveaxis") < 0)) __PYX_ERR(0, 2182, __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_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_source = values[1];
    __pyx_v_destination = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("moveaxis", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2182, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.moveaxis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2182, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_58moveaxis(__pyx_self, __pyx_v_a, __pyx_v_source, __pyx_v_destination);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_58moveaxis(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_source, PyObject *__pyx_v_destination) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("moveaxis", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_moveaxis(__pyx_v_a, __pyx_v_source, __pyx_v_destination, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2182, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.moveaxis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2205
 * 
 * 
 * cpdef ndarray rollaxis(ndarray a, Py_ssize_t axis, Py_ssize_t start=0):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, ndim = a.ndim
 *     cdef vector.vector[Py_ssize_t] axes
 */

static PyObject *__pyx_pw_4cupy_4core_4core_61rollaxis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_rollaxis(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, Py_ssize_t __pyx_v_axis, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_rollaxis *__pyx_optional_args) {
  Py_ssize_t __pyx_v_start = ((Py_ssize_t)0);
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_ndim;
  std::vector<Py_ssize_t>  __pyx_v_axes;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  __Pyx_RefNannySetupContext("rollaxis", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_start = __pyx_optional_args->start;
    }
  }

  /* "cupy/core/core.pyx":2206
 * 
 * cpdef ndarray rollaxis(ndarray a, Py_ssize_t axis, Py_ssize_t start=0):
 *     cdef Py_ssize_t i, ndim = a.ndim             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] axes
 *     if axis < 0:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2206, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_2;

  /* "cupy/core/core.pyx":2208
 *     cdef Py_ssize_t i, ndim = a.ndim
 *     cdef vector.vector[Py_ssize_t] axes
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += ndim
 *     if start < 0:
 */
  __pyx_t_3 = ((__pyx_v_axis < 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2209
 *     cdef vector.vector[Py_ssize_t] axes
 *     if axis < 0:
 *         axis += ndim             # <<<<<<<<<<<<<<
 *     if start < 0:
 *         start += ndim
 */
    __pyx_v_axis = (__pyx_v_axis + __pyx_v_ndim);

    /* "cupy/core/core.pyx":2208
 *     cdef Py_ssize_t i, ndim = a.ndim
 *     cdef vector.vector[Py_ssize_t] axes
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += ndim
 *     if start < 0:
 */
  }

  /* "cupy/core/core.pyx":2210
 *     if axis < 0:
 *         axis += ndim
 *     if start < 0:             # <<<<<<<<<<<<<<
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 */
  __pyx_t_3 = ((__pyx_v_start < 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2211
 *         axis += ndim
 *     if start < 0:
 *         start += ndim             # <<<<<<<<<<<<<<
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 *         raise ValueError('Axis out of range')
 */
    __pyx_v_start = (__pyx_v_start + __pyx_v_ndim);

    /* "cupy/core/core.pyx":2210
 *     if axis < 0:
 *         axis += ndim
 *     if start < 0:             # <<<<<<<<<<<<<<
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 */
  }

  /* "cupy/core/core.pyx":2212
 *     if start < 0:
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):             # <<<<<<<<<<<<<<
 *         raise ValueError('Axis out of range')
 *     if axis < start:
 */
  __pyx_t_4 = (0 <= __pyx_v_axis);
  if (__pyx_t_4) {
    __pyx_t_4 = (__pyx_v_axis < __pyx_v_ndim);
  }
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_5 = (0 <= __pyx_v_start);
  if (__pyx_t_5) {
    __pyx_t_5 = (__pyx_v_start <= __pyx_v_ndim);
  }
  __pyx_t_4 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L6_bool_binop_done:;
  __pyx_t_4 = ((!__pyx_t_3) != 0);
  if (unlikely(__pyx_t_4)) {

    /* "cupy/core/core.pyx":2213
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 *         raise ValueError('Axis out of range')             # <<<<<<<<<<<<<<
 *     if axis < start:
 *         start -= 1
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2213, __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(0, 2213, __pyx_L1_error)

    /* "cupy/core/core.pyx":2212
 *     if start < 0:
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):             # <<<<<<<<<<<<<<
 *         raise ValueError('Axis out of range')
 *     if axis < start:
 */
  }

  /* "cupy/core/core.pyx":2214
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 *         raise ValueError('Axis out of range')
 *     if axis < start:             # <<<<<<<<<<<<<<
 *         start -= 1
 *     if axis == start:
 */
  __pyx_t_4 = ((__pyx_v_axis < __pyx_v_start) != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":2215
 *         raise ValueError('Axis out of range')
 *     if axis < start:
 *         start -= 1             # <<<<<<<<<<<<<<
 *     if axis == start:
 *         return a
 */
    __pyx_v_start = (__pyx_v_start - 1);

    /* "cupy/core/core.pyx":2214
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 *         raise ValueError('Axis out of range')
 *     if axis < start:             # <<<<<<<<<<<<<<
 *         start -= 1
 *     if axis == start:
 */
  }

  /* "cupy/core/core.pyx":2216
 *     if axis < start:
 *         start -= 1
 *     if axis == start:             # <<<<<<<<<<<<<<
 *         return a
 *     if ndim == 2:
 */
  __pyx_t_4 = ((__pyx_v_axis == __pyx_v_start) != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":2217
 *         start -= 1
 *     if axis == start:
 *         return a             # <<<<<<<<<<<<<<
 *     if ndim == 2:
 *         return a._transpose(axes)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2216
 *     if axis < start:
 *         start -= 1
 *     if axis == start:             # <<<<<<<<<<<<<<
 *         return a
 *     if ndim == 2:
 */
  }

  /* "cupy/core/core.pyx":2218
 *     if axis == start:
 *         return a
 *     if ndim == 2:             # <<<<<<<<<<<<<<
 *         return a._transpose(axes)
 * 
 */
  __pyx_t_4 = ((__pyx_v_ndim == 2) != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":2219
 *         return a
 *     if ndim == 2:
 *         return a._transpose(axes)             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->_transpose(__pyx_v_a, __pyx_v_axes, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2219, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2218
 *     if axis == start:
 *         return a
 *     if ndim == 2:             # <<<<<<<<<<<<<<
 *         return a._transpose(axes)
 * 
 */
  }

  /* "cupy/core/core.pyx":2221
 *         return a._transpose(axes)
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         axes.push_back(i)
 *     axes.erase(axes.begin() + axis)
 */
  __pyx_t_2 = __pyx_v_ndim;
  __pyx_t_6 = __pyx_t_2;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "cupy/core/core.pyx":2222
 * 
 *     for i in range(ndim):
 *         axes.push_back(i)             # <<<<<<<<<<<<<<
 *     axes.erase(axes.begin() + axis)
 *     axes.insert(axes.begin() + start, axis)
 */
    try {
      __pyx_v_axes.push_back(__pyx_v_i);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2222, __pyx_L1_error)
    }
  }

  /* "cupy/core/core.pyx":2223
 *     for i in range(ndim):
 *         axes.push_back(i)
 *     axes.erase(axes.begin() + axis)             # <<<<<<<<<<<<<<
 *     axes.insert(axes.begin() + start, axis)
 *     return a._transpose(axes)
 */
  (void)(__pyx_v_axes.erase((__pyx_v_axes.begin() + __pyx_v_axis)));

  /* "cupy/core/core.pyx":2224
 *         axes.push_back(i)
 *     axes.erase(axes.begin() + axis)
 *     axes.insert(axes.begin() + start, axis)             # <<<<<<<<<<<<<<
 *     return a._transpose(axes)
 * 
 */
  try {
    __pyx_v_axes.insert((__pyx_v_axes.begin() + __pyx_v_start), __pyx_v_axis);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 2224, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":2225
 *     axes.erase(axes.begin() + axis)
 *     axes.insert(axes.begin() + start, axis)
 *     return a._transpose(axes)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->_transpose(__pyx_v_a, __pyx_v_axes, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2225, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2205
 * 
 * 
 * cpdef ndarray rollaxis(ndarray a, Py_ssize_t axis, Py_ssize_t start=0):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, ndim = a.ndim
 *     cdef vector.vector[Py_ssize_t] axes
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.rollaxis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_61rollaxis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_60rollaxis[] = "rollaxis(ndarray a, Py_ssize_t axis, Py_ssize_t start=0) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_61rollaxis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  Py_ssize_t __pyx_v_axis;
  Py_ssize_t __pyx_v_start;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rollaxis (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_axis,&__pyx_n_s_start,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_a)) != 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_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rollaxis", 0, 2, 3, 1); __PYX_ERR(0, 2205, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_start);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rollaxis") < 0)) __PYX_ERR(0, 2205, __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_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_axis = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_axis == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2205, __pyx_L3_error)
    if (values[2]) {
      __pyx_v_start = __Pyx_PyIndex_AsSsize_t(values[2]); if (unlikely((__pyx_v_start == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2205, __pyx_L3_error)
    } else {
      __pyx_v_start = ((Py_ssize_t)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("rollaxis", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2205, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.rollaxis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2205, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_60rollaxis(__pyx_self, __pyx_v_a, __pyx_v_axis, __pyx_v_start);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_60rollaxis(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, Py_ssize_t __pyx_v_axis, Py_ssize_t __pyx_v_start) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_rollaxis __pyx_t_2;
  __Pyx_RefNannySetupContext("rollaxis", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.start = __pyx_v_start;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_rollaxis(__pyx_v_a, __pyx_v_axis, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.rollaxis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2228
 * 
 * 
 * def array_split(ndarray ary, indices_or_sections, Py_ssize_t axis):             # <<<<<<<<<<<<<<
 * 
 *     cdef Py_ssize_t i, ndim, size, each_size, index, prev, offset, stride
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_63array_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_62array_split[] = "array_split(ndarray ary, indices_or_sections, Py_ssize_t axis)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_63array_split = {"array_split", (PyCFunction)__pyx_pw_4cupy_4core_4core_63array_split, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_62array_split};
static PyObject *__pyx_pw_4cupy_4core_4core_63array_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ary = 0;
  PyObject *__pyx_v_indices_or_sections = 0;
  Py_ssize_t __pyx_v_axis;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("array_split (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ary,&__pyx_n_s_indices_or_sections,&__pyx_n_s_axis,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_ary)) != 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_indices_or_sections)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("array_split", 1, 3, 3, 1); __PYX_ERR(0, 2228, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("array_split", 1, 3, 3, 2); __PYX_ERR(0, 2228, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "array_split") < 0)) __PYX_ERR(0, 2228, __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_ary = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_indices_or_sections = values[1];
    __pyx_v_axis = __Pyx_PyIndex_AsSsize_t(values[2]); if (unlikely((__pyx_v_axis == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2228, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("array_split", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2228, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.array_split", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ary), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "ary", 0))) __PYX_ERR(0, 2228, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_62array_split(__pyx_self, __pyx_v_ary, __pyx_v_indices_or_sections, __pyx_v_axis);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_62array_split(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ary, PyObject *__pyx_v_indices_or_sections, Py_ssize_t __pyx_v_axis) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_size;
  Py_ssize_t __pyx_v_each_size;
  Py_ssize_t __pyx_v_index;
  Py_ssize_t __pyx_v_prev;
  Py_ssize_t __pyx_v_stride;
  std::vector<Py_ssize_t>  __pyx_v_shape;
  PyObject *__pyx_v_indices = NULL;
  PyObject *__pyx_v_ret = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  long __pyx_t_8;
  long __pyx_t_9;
  std::vector<Py_ssize_t>  __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  Py_ssize_t __pyx_t_12;
  int __pyx_t_13;
  __Pyx_RefNannySetupContext("array_split", 0);

  /* "cupy/core/core.pyx":2233
 *     cdef vector.vector[Py_ssize_t] shape
 * 
 *     ndim = ary.ndim             # <<<<<<<<<<<<<<
 *     if -ndim > axis or ndim <= axis:
 *         raise IndexError('Axis exceeds ndim')
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ary), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2233, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_2;

  /* "cupy/core/core.pyx":2234
 * 
 *     ndim = ary.ndim
 *     if -ndim > axis or ndim <= axis:             # <<<<<<<<<<<<<<
 *         raise IndexError('Axis exceeds ndim')
 *     if axis < 0:
 */
  __pyx_t_4 = (((-__pyx_v_ndim) > __pyx_v_axis) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_ndim <= __pyx_v_axis) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_3)) {

    /* "cupy/core/core.pyx":2235
 *     ndim = ary.ndim
 *     if -ndim > axis or ndim <= axis:
 *         raise IndexError('Axis exceeds ndim')             # <<<<<<<<<<<<<<
 *     if axis < 0:
 *         axis += ndim
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__89, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2235, __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(0, 2235, __pyx_L1_error)

    /* "cupy/core/core.pyx":2234
 * 
 *     ndim = ary.ndim
 *     if -ndim > axis or ndim <= axis:             # <<<<<<<<<<<<<<
 *         raise IndexError('Axis exceeds ndim')
 *     if axis < 0:
 */
  }

  /* "cupy/core/core.pyx":2236
 *     if -ndim > axis or ndim <= axis:
 *         raise IndexError('Axis exceeds ndim')
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += ndim
 *     size = ary._shape[axis]
 */
  __pyx_t_3 = ((__pyx_v_axis < 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2237
 *         raise IndexError('Axis exceeds ndim')
 *     if axis < 0:
 *         axis += ndim             # <<<<<<<<<<<<<<
 *     size = ary._shape[axis]
 * 
 */
    __pyx_v_axis = (__pyx_v_axis + __pyx_v_ndim);

    /* "cupy/core/core.pyx":2236
 *     if -ndim > axis or ndim <= axis:
 *         raise IndexError('Axis exceeds ndim')
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += ndim
 *     size = ary._shape[axis]
 */
  }

  /* "cupy/core/core.pyx":2238
 *     if axis < 0:
 *         axis += ndim
 *     size = ary._shape[axis]             # <<<<<<<<<<<<<<
 * 
 *     if numpy.isscalar(indices_or_sections):
 */
  __pyx_v_size = (__pyx_v_ary->_shape[__pyx_v_axis]);

  /* "cupy/core/core.pyx":2240
 *     size = ary._shape[axis]
 * 
 *     if numpy.isscalar(indices_or_sections):             # <<<<<<<<<<<<<<
 *         each_size = (size - 1) // indices_or_sections + 1
 *         indices = [i * each_size
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_isscalar); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(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);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_indices_or_sections); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2240, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_indices_or_sections};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2240, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_indices_or_sections};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2240, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2240, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_indices_or_sections);
      __Pyx_GIVEREF(__pyx_v_indices_or_sections);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_indices_or_sections);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2240, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2240, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2241
 * 
 *     if numpy.isscalar(indices_or_sections):
 *         each_size = (size - 1) // indices_or_sections + 1             # <<<<<<<<<<<<<<
 *         indices = [i * each_size
 *                    for i in range(1, indices_or_sections)]
 */
    __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_size - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2241, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyNumber_FloorDivide(__pyx_t_1, __pyx_v_indices_or_sections); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2241, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_6, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2241, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2241, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_each_size = __pyx_t_2;

    /* "cupy/core/core.pyx":2242
 *     if numpy.isscalar(indices_or_sections):
 *         each_size = (size - 1) // indices_or_sections + 1
 *         indices = [i * each_size             # <<<<<<<<<<<<<<
 *                    for i in range(1, indices_or_sections)]
 *     else:
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2242, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "cupy/core/core.pyx":2243
 *         each_size = (size - 1) // indices_or_sections + 1
 *         indices = [i * each_size
 *                    for i in range(1, indices_or_sections)]             # <<<<<<<<<<<<<<
 *     else:
 *         indices = indices_or_sections
 */
    __pyx_t_8 = __Pyx_PyInt_As_long(__pyx_v_indices_or_sections); if (unlikely((__pyx_t_8 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 2243, __pyx_L1_error)
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_2 = 1; __pyx_t_2 < __pyx_t_9; __pyx_t_2+=1) {
      __pyx_v_i = __pyx_t_2;

      /* "cupy/core/core.pyx":2242
 *     if numpy.isscalar(indices_or_sections):
 *         each_size = (size - 1) // indices_or_sections + 1
 *         indices = [i * each_size             # <<<<<<<<<<<<<<
 *                    for i in range(1, indices_or_sections)]
 *     else:
 */
      __pyx_t_6 = PyInt_FromSsize_t((__pyx_v_i * __pyx_v_each_size)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2242, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 2242, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __pyx_v_indices = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2240
 *     size = ary._shape[axis]
 * 
 *     if numpy.isscalar(indices_or_sections):             # <<<<<<<<<<<<<<
 *         each_size = (size - 1) // indices_or_sections + 1
 *         indices = [i * each_size
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":2245
 *                    for i in range(1, indices_or_sections)]
 *     else:
 *         indices = indices_or_sections             # <<<<<<<<<<<<<<
 * 
 *     if len(indices) == 0:
 */
  /*else*/ {
    __Pyx_INCREF(__pyx_v_indices_or_sections);
    __pyx_v_indices = __pyx_v_indices_or_sections;
  }
  __pyx_L7:;

  /* "cupy/core/core.pyx":2247
 *         indices = indices_or_sections
 * 
 *     if len(indices) == 0:             # <<<<<<<<<<<<<<
 *         return [ary]
 * 
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_indices); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2247, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_t_2 == 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2248
 * 
 *     if len(indices) == 0:
 *         return [ary]             # <<<<<<<<<<<<<<
 * 
 *     # Make a copy of shape for each view
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2248, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_ary));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_ary));
    PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_ary));
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2247
 *         indices = indices_or_sections
 * 
 *     if len(indices) == 0:             # <<<<<<<<<<<<<<
 *         return [ary]
 * 
 */
  }

  /* "cupy/core/core.pyx":2251
 * 
 *     # Make a copy of shape for each view
 *     shape = ary._shape             # <<<<<<<<<<<<<<
 * 
 *     prev = 0
 */
  __pyx_t_10 = __pyx_v_ary->_shape;
  __pyx_v_shape = __pyx_t_10;

  /* "cupy/core/core.pyx":2253
 *     shape = ary._shape
 * 
 *     prev = 0             # <<<<<<<<<<<<<<
 *     ret = []
 *     stride = ary._strides[axis]
 */
  __pyx_v_prev = 0;

  /* "cupy/core/core.pyx":2254
 * 
 *     prev = 0
 *     ret = []             # <<<<<<<<<<<<<<
 *     stride = ary._strides[axis]
 *     for index in indices:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2255
 *     prev = 0
 *     ret = []
 *     stride = ary._strides[axis]             # <<<<<<<<<<<<<<
 *     for index in indices:
 *         shape[axis] = index - prev
 */
  __pyx_v_stride = (__pyx_v_ary->_strides[__pyx_v_axis]);

  /* "cupy/core/core.pyx":2256
 *     ret = []
 *     stride = ary._strides[axis]
 *     for index in indices:             # <<<<<<<<<<<<<<
 *         shape[axis] = index - prev
 *         v = ary.view()
 */
  if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
    __pyx_t_1 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2256, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2256, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_6); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2256, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2256, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_6); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2256, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2256, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_11(__pyx_t_1);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2256, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2256, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_index = __pyx_t_12;

    /* "cupy/core/core.pyx":2257
 *     stride = ary._strides[axis]
 *     for index in indices:
 *         shape[axis] = index - prev             # <<<<<<<<<<<<<<
 *         v = ary.view()
 *         v.data = ary.data + prev * stride
 */
    (__pyx_v_shape[__pyx_v_axis]) = (__pyx_v_index - __pyx_v_prev);

    /* "cupy/core/core.pyx":2258
 *     for index in indices:
 *         shape[axis] = index - prev
 *         v = ary.view()             # <<<<<<<<<<<<<<
 *         v.data = ary.data + prev * stride
 *         v._set_shape_and_strides(shape, ary._strides)
 */
    __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ary->__pyx_vtab)->view(__pyx_v_ary, 0, NULL)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2258, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF_SET(__pyx_v_v, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6));
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2259
 *         shape[axis] = index - prev
 *         v = ary.view()
 *         v.data = ary.data + prev * stride             # <<<<<<<<<<<<<<
 *         v._set_shape_and_strides(shape, ary._strides)
 *         ret.append(v)
 */
    __pyx_t_6 = PyInt_FromSsize_t((__pyx_v_prev * __pyx_v_stride)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2259, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyNumber_Add(((PyObject *)__pyx_v_ary->data), __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2259, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer))))) __PYX_ERR(0, 2259, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_7);
    __Pyx_GOTREF(__pyx_v_v->data);
    __Pyx_DECREF(((PyObject *)__pyx_v_v->data));
    __pyx_v_v->data = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2260
 *         v = ary.view()
 *         v.data = ary.data + prev * stride
 *         v._set_shape_and_strides(shape, ary._strides)             # <<<<<<<<<<<<<<
 *         ret.append(v)
 * 
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_v->__pyx_vtab)->_set_shape_and_strides(__pyx_v_v, __pyx_v_shape, __pyx_v_ary->_strides, 0, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2260, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2261
 *         v.data = ary.data + prev * stride
 *         v._set_shape_and_strides(shape, ary._strides)
 *         ret.append(v)             # <<<<<<<<<<<<<<
 * 
 *         prev = index
 */
    __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, ((PyObject *)__pyx_v_v)); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 2261, __pyx_L1_error)

    /* "cupy/core/core.pyx":2263
 *         ret.append(v)
 * 
 *         prev = index             # <<<<<<<<<<<<<<
 * 
 *     shape[axis] = size - prev
 */
    __pyx_v_prev = __pyx_v_index;

    /* "cupy/core/core.pyx":2256
 *     ret = []
 *     stride = ary._strides[axis]
 *     for index in indices:             # <<<<<<<<<<<<<<
 *         shape[axis] = index - prev
 *         v = ary.view()
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2265
 *         prev = index
 * 
 *     shape[axis] = size - prev             # <<<<<<<<<<<<<<
 *     v = ary.view()
 *     v.data = ary.data + prev * stride
 */
  (__pyx_v_shape[__pyx_v_axis]) = (__pyx_v_size - __pyx_v_prev);

  /* "cupy/core/core.pyx":2266
 * 
 *     shape[axis] = size - prev
 *     v = ary.view()             # <<<<<<<<<<<<<<
 *     v.data = ary.data + prev * stride
 *     v._set_shape_and_strides(shape, ary._strides)
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ary->__pyx_vtab)->view(__pyx_v_ary, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XDECREF_SET(__pyx_v_v, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2267
 *     shape[axis] = size - prev
 *     v = ary.view()
 *     v.data = ary.data + prev * stride             # <<<<<<<<<<<<<<
 *     v._set_shape_and_strides(shape, ary._strides)
 *     ret.append(v)
 */
  __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_prev * __pyx_v_stride)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyNumber_Add(((PyObject *)__pyx_v_ary->data), __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer))))) __PYX_ERR(0, 2267, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_7);
  __Pyx_GOTREF(__pyx_v_v->data);
  __Pyx_DECREF(((PyObject *)__pyx_v_v->data));
  __pyx_v_v->data = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2268
 *     v = ary.view()
 *     v.data = ary.data + prev * stride
 *     v._set_shape_and_strides(shape, ary._strides)             # <<<<<<<<<<<<<<
 *     ret.append(v)
 * 
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_v->__pyx_vtab)->_set_shape_and_strides(__pyx_v_v, __pyx_v_shape, __pyx_v_ary->_strides, 0, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2268, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2269
 *     v.data = ary.data + prev * stride
 *     v._set_shape_and_strides(shape, ary._strides)
 *     ret.append(v)             # <<<<<<<<<<<<<<
 * 
 *     return ret
 */
  __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, ((PyObject *)__pyx_v_v)); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 2269, __pyx_L1_error)

  /* "cupy/core/core.pyx":2271
 *     ret.append(v)
 * 
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2228
 * 
 * 
 * def array_split(ndarray ary, indices_or_sections, Py_ssize_t axis):             # <<<<<<<<<<<<<<
 * 
 *     cdef Py_ssize_t i, ndim, size, each_size, index, prev, offset, stride
 */

  /* 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_AddTraceback("cupy.core.core.array_split", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_indices);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF((PyObject *)__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2302
 *         readonly Py_ssize_t nd
 * 
 *     def __init__(self, *arrays):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i, j, s, smin, smax, a_ndim, a_sh
 *         cdef vector.vector[Py_ssize_t] shape, strides, r_shape, r_strides
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_9broadcast_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_4core_4core_9broadcast_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_arrays = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_arrays = __pyx_args;
  __pyx_r = __pyx_pf_4cupy_4core_4core_9broadcast___init__(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v_self), __pyx_v_arrays);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_arrays);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4cupy_4core_4core_9broadcast___init__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self, PyObject *__pyx_v_arrays) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_j;
  Py_ssize_t __pyx_v_s;
  Py_ssize_t __pyx_v_smin;
  Py_ssize_t __pyx_v_smax;
  Py_ssize_t __pyx_v_a_ndim;
  Py_ssize_t __pyx_v_a_sh;
  std::vector<Py_ssize_t>  __pyx_v_shape;
  std::vector<Py_ssize_t>  __pyx_v_strides;
  std::vector<Py_ssize_t>  __pyx_v_r_shape;
  std::vector<Py_ssize_t>  __pyx_v_r_strides;
  std::vector<std::vector<Py_ssize_t> >  __pyx_v_shape_arr;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_view = 0;
  CYTHON_UNUSED PyObject *__pyx_v_rev = 0;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_broadcasted = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __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;
  Py_ssize_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  int __pyx_t_14;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/core.pyx":2307
 *         cdef vector.vector[vector.vector[Py_ssize_t]] shape_arr
 *         cdef ndarray a, view
 *         cdef slice rev = slice(None, None, -1)             # <<<<<<<<<<<<<<
 * 
 *         self.nd = 0
 */
  __pyx_t_1 = __pyx_slice__90;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_rev = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2309
 *         cdef slice rev = slice(None, None, -1)
 * 
 *         self.nd = 0             # <<<<<<<<<<<<<<
 *         for x in arrays:
 *             if not isinstance(x, ndarray):
 */
  __pyx_v_self->nd = 0;

  /* "cupy/core/core.pyx":2310
 * 
 *         self.nd = 0
 *         for x in arrays:             # <<<<<<<<<<<<<<
 *             if not isinstance(x, ndarray):
 *                 continue
 */
  __pyx_t_1 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2310, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2311
 *         self.nd = 0
 *         for x in arrays:
 *             if not isinstance(x, ndarray):             # <<<<<<<<<<<<<<
 *                 continue
 *             a = x
 */
    __pyx_t_4 = __Pyx_TypeCheck(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_5 = ((!(__pyx_t_4 != 0)) != 0);
    if (__pyx_t_5) {

      /* "cupy/core/core.pyx":2312
 *         for x in arrays:
 *             if not isinstance(x, ndarray):
 *                 continue             # <<<<<<<<<<<<<<
 *             a = x
 *             self.nd = max(self.nd, <Py_ssize_t>a._shape.size())
 */
      goto __pyx_L3_continue;

      /* "cupy/core/core.pyx":2311
 *         self.nd = 0
 *         for x in arrays:
 *             if not isinstance(x, ndarray):             # <<<<<<<<<<<<<<
 *                 continue
 *             a = x
 */
    }

    /* "cupy/core/core.pyx":2313
 *             if not isinstance(x, ndarray):
 *                 continue
 *             a = x             # <<<<<<<<<<<<<<
 *             self.nd = max(self.nd, <Py_ssize_t>a._shape.size())
 *             r_shape.assign(a._shape.rbegin(), a._shape.rend())
 */
    if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2313, __pyx_L1_error)
    __pyx_t_3 = __pyx_v_x;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2314
 *                 continue
 *             a = x
 *             self.nd = max(self.nd, <Py_ssize_t>a._shape.size())             # <<<<<<<<<<<<<<
 *             r_shape.assign(a._shape.rbegin(), a._shape.rend())
 *             shape_arr.push_back(r_shape)
 */
    __pyx_t_6 = ((Py_ssize_t)__pyx_v_a->_shape.size());
    __pyx_t_7 = __pyx_v_self->nd;
    if (((__pyx_t_6 > __pyx_t_7) != 0)) {
      __pyx_t_8 = __pyx_t_6;
    } else {
      __pyx_t_8 = __pyx_t_7;
    }
    __pyx_v_self->nd = __pyx_t_8;

    /* "cupy/core/core.pyx":2315
 *             a = x
 *             self.nd = max(self.nd, <Py_ssize_t>a._shape.size())
 *             r_shape.assign(a._shape.rbegin(), a._shape.rend())             # <<<<<<<<<<<<<<
 *             shape_arr.push_back(r_shape)
 * 
 */
    try {
      __pyx_v_r_shape.assign(__pyx_v_a->_shape.rbegin(), __pyx_v_a->_shape.rend());
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2315, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2316
 *             self.nd = max(self.nd, <Py_ssize_t>a._shape.size())
 *             r_shape.assign(a._shape.rbegin(), a._shape.rend())
 *             shape_arr.push_back(r_shape)             # <<<<<<<<<<<<<<
 * 
 *         r_shape.clear()
 */
    try {
      __pyx_v_shape_arr.push_back(__pyx_v_r_shape);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2316, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2310
 * 
 *         self.nd = 0
 *         for x in arrays:             # <<<<<<<<<<<<<<
 *             if not isinstance(x, ndarray):
 *                 continue
 */
    __pyx_L3_continue:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2318
 *             shape_arr.push_back(r_shape)
 * 
 *         r_shape.clear()             # <<<<<<<<<<<<<<
 *         for i in range(self.nd):
 *             smin = PY_SSIZE_T_MAX
 */
  __pyx_v_r_shape.clear();

  /* "cupy/core/core.pyx":2319
 * 
 *         r_shape.clear()
 *         for i in range(self.nd):             # <<<<<<<<<<<<<<
 *             smin = PY_SSIZE_T_MAX
 *             smax = 0
 */
  __pyx_t_2 = __pyx_v_self->nd;
  __pyx_t_8 = __pyx_t_2;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_8; __pyx_t_6+=1) {
    __pyx_v_i = __pyx_t_6;

    /* "cupy/core/core.pyx":2320
 *         r_shape.clear()
 *         for i in range(self.nd):
 *             smin = PY_SSIZE_T_MAX             # <<<<<<<<<<<<<<
 *             smax = 0
 *             for j in range(<Py_ssize_t>shape_arr.size()):
 */
    __pyx_v_smin = __pyx_v_4cupy_4core_4core_PY_SSIZE_T_MAX;

    /* "cupy/core/core.pyx":2321
 *         for i in range(self.nd):
 *             smin = PY_SSIZE_T_MAX
 *             smax = 0             # <<<<<<<<<<<<<<
 *             for j in range(<Py_ssize_t>shape_arr.size()):
 *                 if i < <Py_ssize_t>shape_arr[j].size():
 */
    __pyx_v_smax = 0;

    /* "cupy/core/core.pyx":2322
 *             smin = PY_SSIZE_T_MAX
 *             smax = 0
 *             for j in range(<Py_ssize_t>shape_arr.size()):             # <<<<<<<<<<<<<<
 *                 if i < <Py_ssize_t>shape_arr[j].size():
 *                     s = shape_arr[j][i]
 */
    __pyx_t_7 = ((Py_ssize_t)__pyx_v_shape_arr.size());
    __pyx_t_9 = __pyx_t_7;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_j = __pyx_t_10;

      /* "cupy/core/core.pyx":2323
 *             smax = 0
 *             for j in range(<Py_ssize_t>shape_arr.size()):
 *                 if i < <Py_ssize_t>shape_arr[j].size():             # <<<<<<<<<<<<<<
 *                     s = shape_arr[j][i]
 *                     smin = min(smin, s)
 */
      __pyx_t_5 = ((__pyx_v_i < ((Py_ssize_t)(__pyx_v_shape_arr[__pyx_v_j]).size())) != 0);
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":2324
 *             for j in range(<Py_ssize_t>shape_arr.size()):
 *                 if i < <Py_ssize_t>shape_arr[j].size():
 *                     s = shape_arr[j][i]             # <<<<<<<<<<<<<<
 *                     smin = min(smin, s)
 *                     smax = max(smax, s)
 */
        __pyx_v_s = ((__pyx_v_shape_arr[__pyx_v_j])[__pyx_v_i]);

        /* "cupy/core/core.pyx":2325
 *                 if i < <Py_ssize_t>shape_arr[j].size():
 *                     s = shape_arr[j][i]
 *                     smin = min(smin, s)             # <<<<<<<<<<<<<<
 *                     smax = max(smax, s)
 *             if smin == 0 and smax > 1:
 */
        __pyx_t_11 = __pyx_v_s;
        __pyx_t_12 = __pyx_v_smin;
        if (((__pyx_t_11 < __pyx_t_12) != 0)) {
          __pyx_t_13 = __pyx_t_11;
        } else {
          __pyx_t_13 = __pyx_t_12;
        }
        __pyx_v_smin = __pyx_t_13;

        /* "cupy/core/core.pyx":2326
 *                     s = shape_arr[j][i]
 *                     smin = min(smin, s)
 *                     smax = max(smax, s)             # <<<<<<<<<<<<<<
 *             if smin == 0 and smax > 1:
 *                 raise ValueError(
 */
        __pyx_t_13 = __pyx_v_s;
        __pyx_t_11 = __pyx_v_smax;
        if (((__pyx_t_13 > __pyx_t_11) != 0)) {
          __pyx_t_12 = __pyx_t_13;
        } else {
          __pyx_t_12 = __pyx_t_11;
        }
        __pyx_v_smax = __pyx_t_12;

        /* "cupy/core/core.pyx":2323
 *             smax = 0
 *             for j in range(<Py_ssize_t>shape_arr.size()):
 *                 if i < <Py_ssize_t>shape_arr[j].size():             # <<<<<<<<<<<<<<
 *                     s = shape_arr[j][i]
 *                     smin = min(smin, s)
 */
      }
    }

    /* "cupy/core/core.pyx":2327
 *                     smin = min(smin, s)
 *                     smax = max(smax, s)
 *             if smin == 0 and smax > 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'shape mismatch: objects cannot be broadcast to a '
 */
    __pyx_t_4 = ((__pyx_v_smin == 0) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L12_bool_binop_done;
    }
    __pyx_t_4 = ((__pyx_v_smax > 1) != 0);
    __pyx_t_5 = __pyx_t_4;
    __pyx_L12_bool_binop_done:;
    if (unlikely(__pyx_t_5)) {

      /* "cupy/core/core.pyx":2328
 *                     smax = max(smax, s)
 *             if smin == 0 and smax > 1:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'shape mismatch: objects cannot be broadcast to a '
 *                     'single shape')
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__91, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2328, __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(0, 2328, __pyx_L1_error)

      /* "cupy/core/core.pyx":2327
 *                     smin = min(smin, s)
 *                     smax = max(smax, s)
 *             if smin == 0 and smax > 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'shape mismatch: objects cannot be broadcast to a '
 */
    }

    /* "cupy/core/core.pyx":2331
 *                     'shape mismatch: objects cannot be broadcast to a '
 *                     'single shape')
 *             r_shape.push_back(0 if smin == 0 else smax)             # <<<<<<<<<<<<<<
 * 
 *         shape.assign(r_shape.rbegin(), r_shape.rend())
 */
    if (((__pyx_v_smin == 0) != 0)) {
      __pyx_t_7 = 0;
    } else {
      __pyx_t_7 = __pyx_v_smax;
    }
    try {
      __pyx_v_r_shape.push_back(__pyx_t_7);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2331, __pyx_L1_error)
    }
  }

  /* "cupy/core/core.pyx":2333
 *             r_shape.push_back(0 if smin == 0 else smax)
 * 
 *         shape.assign(r_shape.rbegin(), r_shape.rend())             # <<<<<<<<<<<<<<
 *         self.shape = tuple(shape)
 *         self.size = internal.prod_ssize_t(shape)
 */
  try {
    __pyx_v_shape.assign(__pyx_v_r_shape.rbegin(), __pyx_v_r_shape.rend());
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 2333, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":2334
 * 
 *         shape.assign(r_shape.rbegin(), r_shape.rend())
 *         self.shape = tuple(shape)             # <<<<<<<<<<<<<<
 *         self.size = internal.prod_ssize_t(shape)
 * 
 */
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->shape);
  __Pyx_DECREF(__pyx_v_self->shape);
  __pyx_v_self->shape = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2335
 *         shape.assign(r_shape.rbegin(), r_shape.rend())
 *         self.shape = tuple(shape)
 *         self.size = internal.prod_ssize_t(shape)             # <<<<<<<<<<<<<<
 * 
 *         broadcasted = []
 */
  __pyx_v_self->size = __pyx_f_4cupy_4core_8internal_prod_ssize_t(__pyx_v_shape, 0, NULL);

  /* "cupy/core/core.pyx":2337
 *         self.size = internal.prod_ssize_t(shape)
 * 
 *         broadcasted = []             # <<<<<<<<<<<<<<
 *         for x in arrays:
 *             if not isinstance(x, ndarray):
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_broadcasted = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2338
 * 
 *         broadcasted = []
 *         for x in arrays:             # <<<<<<<<<<<<<<
 *             if not isinstance(x, ndarray):
 *                 broadcasted.append(x)
 */
  __pyx_t_3 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2338, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2339
 *         broadcasted = []
 *         for x in arrays:
 *             if not isinstance(x, ndarray):             # <<<<<<<<<<<<<<
 *                 broadcasted.append(x)
 *                 continue
 */
    __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_4 = ((!(__pyx_t_5 != 0)) != 0);
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":2340
 *         for x in arrays:
 *             if not isinstance(x, ndarray):
 *                 broadcasted.append(x)             # <<<<<<<<<<<<<<
 *                 continue
 *             a = x
 */
      __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_broadcasted, __pyx_v_x); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 2340, __pyx_L1_error)

      /* "cupy/core/core.pyx":2341
 *             if not isinstance(x, ndarray):
 *                 broadcasted.append(x)
 *                 continue             # <<<<<<<<<<<<<<
 *             a = x
 *             if internal.vector_equal(a._shape, shape):
 */
      goto __pyx_L14_continue;

      /* "cupy/core/core.pyx":2339
 *         broadcasted = []
 *         for x in arrays:
 *             if not isinstance(x, ndarray):             # <<<<<<<<<<<<<<
 *                 broadcasted.append(x)
 *                 continue
 */
    }

    /* "cupy/core/core.pyx":2342
 *                 broadcasted.append(x)
 *                 continue
 *             a = x             # <<<<<<<<<<<<<<
 *             if internal.vector_equal(a._shape, shape):
 *                 broadcasted.append(a)
 */
    if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2342, __pyx_L1_error)
    __pyx_t_1 = __pyx_v_x;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2343
 *                 continue
 *             a = x
 *             if internal.vector_equal(a._shape, shape):             # <<<<<<<<<<<<<<
 *                 broadcasted.append(a)
 *                 continue
 */
    __pyx_t_4 = (__pyx_f_4cupy_4core_8internal_vector_equal(__pyx_v_a->_shape, __pyx_v_shape, 0) != 0);
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":2344
 *             a = x
 *             if internal.vector_equal(a._shape, shape):
 *                 broadcasted.append(a)             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
      __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_broadcasted, ((PyObject *)__pyx_v_a)); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 2344, __pyx_L1_error)

      /* "cupy/core/core.pyx":2345
 *             if internal.vector_equal(a._shape, shape):
 *                 broadcasted.append(a)
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             r_strides.assign(self.nd, <Py_ssize_t>0)
 */
      goto __pyx_L14_continue;

      /* "cupy/core/core.pyx":2343
 *                 continue
 *             a = x
 *             if internal.vector_equal(a._shape, shape):             # <<<<<<<<<<<<<<
 *                 broadcasted.append(a)
 *                 continue
 */
    }

    /* "cupy/core/core.pyx":2347
 *                 continue
 * 
 *             r_strides.assign(self.nd, <Py_ssize_t>0)             # <<<<<<<<<<<<<<
 *             a_ndim = a._shape.size()
 *             for i in range(a_ndim):
 */
    try {
      __pyx_v_r_strides.assign(__pyx_v_self->nd, ((Py_ssize_t)0));
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2347, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2348
 * 
 *             r_strides.assign(self.nd, <Py_ssize_t>0)
 *             a_ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *             for i in range(a_ndim):
 *                 a_sh = a._shape[a_ndim - i - 1]
 */
    __pyx_v_a_ndim = __pyx_v_a->_shape.size();

    /* "cupy/core/core.pyx":2349
 *             r_strides.assign(self.nd, <Py_ssize_t>0)
 *             a_ndim = a._shape.size()
 *             for i in range(a_ndim):             # <<<<<<<<<<<<<<
 *                 a_sh = a._shape[a_ndim - i - 1]
 *                 if a_sh == r_shape[i]:
 */
    __pyx_t_8 = __pyx_v_a_ndim;
    __pyx_t_6 = __pyx_t_8;
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_v_i = __pyx_t_7;

      /* "cupy/core/core.pyx":2350
 *             a_ndim = a._shape.size()
 *             for i in range(a_ndim):
 *                 a_sh = a._shape[a_ndim - i - 1]             # <<<<<<<<<<<<<<
 *                 if a_sh == r_shape[i]:
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 */
      __pyx_v_a_sh = (__pyx_v_a->_shape[((__pyx_v_a_ndim - __pyx_v_i) - 1)]);

      /* "cupy/core/core.pyx":2351
 *             for i in range(a_ndim):
 *                 a_sh = a._shape[a_ndim - i - 1]
 *                 if a_sh == r_shape[i]:             # <<<<<<<<<<<<<<
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 *                 elif a_sh != 1:
 */
      __pyx_t_4 = ((__pyx_v_a_sh == (__pyx_v_r_shape[__pyx_v_i])) != 0);
      if (__pyx_t_4) {

        /* "cupy/core/core.pyx":2352
 *                 a_sh = a._shape[a_ndim - i - 1]
 *                 if a_sh == r_shape[i]:
 *                     r_strides[i] = a._strides[a_ndim - i - 1]             # <<<<<<<<<<<<<<
 *                 elif a_sh != 1:
 *                     raise ValueError('Broadcasting failed')
 */
        (__pyx_v_r_strides[__pyx_v_i]) = (__pyx_v_a->_strides[((__pyx_v_a_ndim - __pyx_v_i) - 1)]);

        /* "cupy/core/core.pyx":2351
 *             for i in range(a_ndim):
 *                 a_sh = a._shape[a_ndim - i - 1]
 *                 if a_sh == r_shape[i]:             # <<<<<<<<<<<<<<
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 *                 elif a_sh != 1:
 */
        goto __pyx_L20;
      }

      /* "cupy/core/core.pyx":2353
 *                 if a_sh == r_shape[i]:
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 *                 elif a_sh != 1:             # <<<<<<<<<<<<<<
 *                     raise ValueError('Broadcasting failed')
 * 
 */
      __pyx_t_4 = ((__pyx_v_a_sh != 1) != 0);
      if (unlikely(__pyx_t_4)) {

        /* "cupy/core/core.pyx":2354
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 *                 elif a_sh != 1:
 *                     raise ValueError('Broadcasting failed')             # <<<<<<<<<<<<<<
 * 
 *             strides.assign(r_strides.rbegin(), r_strides.rend())
 */
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__92, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2354, __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(0, 2354, __pyx_L1_error)

        /* "cupy/core/core.pyx":2353
 *                 if a_sh == r_shape[i]:
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 *                 elif a_sh != 1:             # <<<<<<<<<<<<<<
 *                     raise ValueError('Broadcasting failed')
 * 
 */
      }
      __pyx_L20:;
    }

    /* "cupy/core/core.pyx":2356
 *                     raise ValueError('Broadcasting failed')
 * 
 *             strides.assign(r_strides.rbegin(), r_strides.rend())             # <<<<<<<<<<<<<<
 *             view = a.view()
 *             view._set_shape_and_strides(shape, strides)
 */
    try {
      __pyx_v_strides.assign(__pyx_v_r_strides.rbegin(), __pyx_v_r_strides.rend());
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2356, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2357
 * 
 *             strides.assign(r_strides.rbegin(), r_strides.rend())
 *             view = a.view()             # <<<<<<<<<<<<<<
 *             view._set_shape_and_strides(shape, strides)
 *             broadcasted.append(view)
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2357, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_view, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2358
 *             strides.assign(r_strides.rbegin(), r_strides.rend())
 *             view = a.view()
 *             view._set_shape_and_strides(shape, strides)             # <<<<<<<<<<<<<<
 *             broadcasted.append(view)
 * 
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_v_shape, __pyx_v_strides, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2358, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2359
 *             view = a.view()
 *             view._set_shape_and_strides(shape, strides)
 *             broadcasted.append(view)             # <<<<<<<<<<<<<<
 * 
 *         self.values = tuple(broadcasted)
 */
    __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_broadcasted, ((PyObject *)__pyx_v_view)); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 2359, __pyx_L1_error)

    /* "cupy/core/core.pyx":2338
 * 
 *         broadcasted = []
 *         for x in arrays:             # <<<<<<<<<<<<<<
 *             if not isinstance(x, ndarray):
 *                 broadcasted.append(x)
 */
    __pyx_L14_continue:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2361
 *             broadcasted.append(view)
 * 
 *         self.values = tuple(broadcasted)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = PyList_AsTuple(__pyx_v_broadcasted); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2361, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->values);
  __Pyx_DECREF(__pyx_v_self->values);
  __pyx_v_self->values = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2302
 *         readonly Py_ssize_t nd
 * 
 *     def __init__(self, *arrays):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i, j, s, smin, smax, a_ndim, a_sh
 *         cdef vector.vector[Py_ssize_t] shape, strides, r_shape, r_strides
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.broadcast.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_view);
  __Pyx_XDECREF(__pyx_v_rev);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_broadcasted);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2297
 * 
 *     cdef:
 *         readonly tuple values             # <<<<<<<<<<<<<<
 *         readonly tuple shape
 *         readonly Py_ssize_t size
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_6values_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_6values_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_9broadcast_6values___get__(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_6values___get__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->values);
  __pyx_r = __pyx_v_self->values;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2298
 *     cdef:
 *         readonly tuple values
 *         readonly tuple shape             # <<<<<<<<<<<<<<
 *         readonly Py_ssize_t size
 *         readonly Py_ssize_t nd
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_5shape_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_9broadcast_5shape___get__(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_5shape___get__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->shape);
  __pyx_r = __pyx_v_self->shape;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2299
 *         readonly tuple values
 *         readonly tuple shape
 *         readonly Py_ssize_t size             # <<<<<<<<<<<<<<
 *         readonly Py_ssize_t nd
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_4size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_4size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_9broadcast_4size___get__(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_4size___get__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.broadcast.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2300
 *         readonly tuple shape
 *         readonly Py_ssize_t size
 *         readonly Py_ssize_t nd             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, *arrays):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_2nd_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_2nd_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_9broadcast_2nd___get__(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_2nd___get__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->nd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.broadcast.nd.__get__", __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):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.nd, self.shape, self.size, self.values)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_9broadcast_2__reduce_cython__[] = "broadcast.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_3__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_4cupy_4core_4core_9broadcast_2__reduce_cython__(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_2__reduce_cython__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     cdef bint use_setstate
 *     state = (self.nd, self.shape, self.size, self.values)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->nd); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->shape);
  __Pyx_GIVEREF(__pyx_v_self->shape);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->shape);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->values);
  __Pyx_GIVEREF(__pyx_v_self->values);
  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_self->values);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "(tree fragment)":4
 *     cdef bint use_setstate
 *     state = (self.nd, self.shape, self.size, self.values)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v__dict = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":5
 *     state = (self.nd, self.shape, self.size, self.values)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_4 = (__pyx_v__dict != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":6
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "(tree fragment)":7
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.shape is not None or self.values is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":5
 *     state = (self.nd, self.shape, self.size, self.values)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         use_setstate = True
 *     else:
 *         use_setstate = self.shape is not None or self.values is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, None), state
 */
  /*else*/ {
    __pyx_t_4 = (__pyx_v_self->shape != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->values != ((PyObject*)Py_None));
    __pyx_t_4 = (__pyx_t_6 != 0);
    __pyx_t_5 = __pyx_t_4;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_5;
  }
  __pyx_L3:;

  /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.shape is not None or self.values is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, None), state
 *     else:
 */
  __pyx_t_5 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":11
 *         use_setstate = self.shape is not None or self.values is not None
 *     if use_setstate:
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_broadcast); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_5472103);
    __Pyx_GIVEREF(__pyx_int_5472103);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_5472103);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":10
 *     else:
 *         use_setstate = self.shape is not None or self.values is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, None), state
 *     else:
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_broadcast__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_broadcast); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_5472103);
    __Pyx_GIVEREF(__pyx_int_5472103);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_5472103);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef bint use_setstate
 *     state = (self.nd, self.shape, self.size, self.values)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.broadcast.__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)":14
 *     else:
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_broadcast__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_4core_4core_9broadcast_4__setstate_cython__[] = "broadcast.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_4core_4core_9broadcast_5__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_4cupy_4core_4core_9broadcast_4__setstate_cython__(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_9broadcast_4__setstate_cython__(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_broadcast__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(4, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4core_4core___pyx_unpickle_broadcast__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     else:
 *         return __pyx_unpickle_broadcast, (type(self), 0x0537f67, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_broadcast__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("cupy.core.core.broadcast.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2364
 * 
 * 
 * cpdef ndarray broadcast_to(ndarray array, shape):             # <<<<<<<<<<<<<<
 *     """Broadcast an array to a given shape.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_65broadcast_to(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_broadcast_to(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_array, PyObject *__pyx_v_shape, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_strides = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_v_sh = NULL;
  PyObject *__pyx_v_a_sh = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_view = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  std::vector<Py_ssize_t> ::size_type __pyx_t_7;
  std::vector<Py_ssize_t>  __pyx_t_8;
  std::vector<Py_ssize_t>  __pyx_t_9;
  __Pyx_RefNannySetupContext("broadcast_to", 0);

  /* "cupy/core/core.pyx":2372
 * 
 *     """
 *     if array.ndim > len(shape):             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'input operand has more dimensions than allowed by the axis '
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_array), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_v_shape); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2372, __pyx_L1_error)
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2372, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2372, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(__pyx_t_5)) {

    /* "cupy/core/core.pyx":2373
 *     """
 *     if array.ndim > len(shape):
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'input operand has more dimensions than allowed by the axis '
 *             'remapping')
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__93, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2373, __pyx_L1_error)

    /* "cupy/core/core.pyx":2372
 * 
 *     """
 *     if array.ndim > len(shape):             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'input operand has more dimensions than allowed by the axis '
 */
  }

  /* "cupy/core/core.pyx":2377
 *             'remapping')
 * 
 *     strides = [0] * len(shape)             # <<<<<<<<<<<<<<
 *     for i in range(array.ndim):
 *         j = -i - 1
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_shape); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2377, __pyx_L1_error)
  __pyx_t_4 = PyList_New(1 * ((__pyx_t_2<0) ? 0:__pyx_t_2)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  { Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < __pyx_t_2; __pyx_temp++) {
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyList_SET_ITEM(__pyx_t_4, __pyx_temp, __pyx_int_0);
    }
  }
  __pyx_v_strides = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2378
 * 
 *     strides = [0] * len(shape)
 *     for i in range(array.ndim):             # <<<<<<<<<<<<<<
 *         j = -i - 1
 *         sh = shape[j]
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_array), __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2378, __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(0, 2378, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2378, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2378, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2378, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2378, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_6(__pyx_t_4);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2378, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2379
 *     strides = [0] * len(shape)
 *     for i in range(array.ndim):
 *         j = -i - 1             # <<<<<<<<<<<<<<
 *         sh = shape[j]
 *         a_sh = array.shape[j]
 */
    __pyx_t_3 = PyNumber_Negative(__pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2379, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2379, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2380
 *     for i in range(array.ndim):
 *         j = -i - 1
 *         sh = shape[j]             # <<<<<<<<<<<<<<
 *         a_sh = array.shape[j]
 *         if sh == a_sh:
 */
    __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_shape, __pyx_v_j); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2380, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_sh, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2381
 *         j = -i - 1
 *         sh = shape[j]
 *         a_sh = array.shape[j]             # <<<<<<<<<<<<<<
 *         if sh == a_sh:
 *             strides[j] = array._strides[j % array.ndim]
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_array), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2381, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_j); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2381, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_a_sh, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2382
 *         sh = shape[j]
 *         a_sh = array.shape[j]
 *         if sh == a_sh:             # <<<<<<<<<<<<<<
 *             strides[j] = array._strides[j % array.ndim]
 *         elif a_sh != 1:
 */
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_sh, __pyx_v_a_sh, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2382, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2382, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_5) {

      /* "cupy/core/core.pyx":2383
 *         a_sh = array.shape[j]
 *         if sh == a_sh:
 *             strides[j] = array._strides[j % array.ndim]             # <<<<<<<<<<<<<<
 *         elif a_sh != 1:
 *             raise ValueError('Broadcasting failed')
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_array), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2383, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyNumber_Remainder(__pyx_v_j, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2383, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_7 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2383, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_array->_strides[__pyx_t_7])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2383, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(PyObject_SetItem(__pyx_v_strides, __pyx_v_j, __pyx_t_1) < 0)) __PYX_ERR(0, 2383, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":2382
 *         sh = shape[j]
 *         a_sh = array.shape[j]
 *         if sh == a_sh:             # <<<<<<<<<<<<<<
 *             strides[j] = array._strides[j % array.ndim]
 *         elif a_sh != 1:
 */
      goto __pyx_L6;
    }

    /* "cupy/core/core.pyx":2384
 *         if sh == a_sh:
 *             strides[j] = array._strides[j % array.ndim]
 *         elif a_sh != 1:             # <<<<<<<<<<<<<<
 *             raise ValueError('Broadcasting failed')
 * 
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_a_sh, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2384, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2384, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(__pyx_t_5)) {

      /* "cupy/core/core.pyx":2385
 *             strides[j] = array._strides[j % array.ndim]
 *         elif a_sh != 1:
 *             raise ValueError('Broadcasting failed')             # <<<<<<<<<<<<<<
 * 
 *     view = array.view()
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__94, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2385, __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(0, 2385, __pyx_L1_error)

      /* "cupy/core/core.pyx":2384
 *         if sh == a_sh:
 *             strides[j] = array._strides[j % array.ndim]
 *         elif a_sh != 1:             # <<<<<<<<<<<<<<
 *             raise ValueError('Broadcasting failed')
 * 
 */
    }
    __pyx_L6:;

    /* "cupy/core/core.pyx":2378
 * 
 *     strides = [0] * len(shape)
 *     for i in range(array.ndim):             # <<<<<<<<<<<<<<
 *         j = -i - 1
 *         sh = shape[j]
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2387
 *             raise ValueError('Broadcasting failed')
 * 
 *     view = array.view()             # <<<<<<<<<<<<<<
 *     view._set_shape_and_strides(shape, strides)
 *     return view
 */
  __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_array->__pyx_vtab)->view(__pyx_v_array, 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2388
 * 
 *     view = array.view()
 *     view._set_shape_and_strides(shape, strides)             # <<<<<<<<<<<<<<
 *     return view
 * 
 */
  __pyx_t_8 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2388, __pyx_L1_error)
  __pyx_t_9 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_strides); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2388, __pyx_L1_error)
  __pyx_t_4 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_t_8, __pyx_t_9, 0, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2389
 *     view = array.view()
 *     view._set_shape_and_strides(shape, strides)
 *     return view             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_view));
  __pyx_r = __pyx_v_view;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2364
 * 
 * 
 * cpdef ndarray broadcast_to(ndarray array, shape):             # <<<<<<<<<<<<<<
 *     """Broadcast an array to a given shape.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.broadcast_to", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_strides);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XDECREF(__pyx_v_sh);
  __Pyx_XDECREF(__pyx_v_a_sh);
  __Pyx_XDECREF((PyObject *)__pyx_v_view);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_65broadcast_to(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_64broadcast_to[] = "broadcast_to(ndarray array, shape) -> ndarray\nBroadcast an array to a given shape.\n\n    .. seealso::\n        :func:`cupy.broadcast_to` for full documentation,\n        :meth:`numpy.broadcast_to`\n\n    ";
static PyObject *__pyx_pw_4cupy_4core_4core_65broadcast_to(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_array = 0;
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("broadcast_to (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_array,&__pyx_n_s_shape,0};
    PyObject* values[2] = {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  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_array)) != 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_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("broadcast_to", 1, 2, 2, 1); __PYX_ERR(0, 2364, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "broadcast_to") < 0)) __PYX_ERR(0, 2364, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_array = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_shape = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("broadcast_to", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2364, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.broadcast_to", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_array), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "array", 0))) __PYX_ERR(0, 2364, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_64broadcast_to(__pyx_self, __pyx_v_array, __pyx_v_shape);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_64broadcast_to(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_array, PyObject *__pyx_v_shape) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("broadcast_to", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_broadcast_to(__pyx_v_array, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.broadcast_to", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2392
 * 
 * 
 * cpdef ndarray _repeat(ndarray a, repeats, axis=None):             # <<<<<<<<<<<<<<
 *     """Repeat arrays along an axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_67_repeat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__repeat(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_repeats, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__repeat *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = 0;
  int __pyx_v_broadcast;
  PyObject *__pyx_v_rep = NULL;
  PyObject *__pyx_v_ret_shape = NULL;
  PyObject *__pyx_v_a_index = NULL;
  PyObject *__pyx_v_ret_index = NULL;
  PyObject *__pyx_v_offset = NULL;
  PyObject *__pyx_v_i = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  std::vector<Py_ssize_t> ::size_type __pyx_t_13;
  __Pyx_RefNannySetupContext("_repeat", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF(__pyx_v_repeats);
  __Pyx_INCREF(__pyx_v_axis);

  /* "cupy/core/core.pyx":2410
 *     # Scalar and size 1 'repeat' arrays broadcast to any shape, for all
 *     # other inputs the dimension must match exactly.
 *     cdef bint broadcast = False             # <<<<<<<<<<<<<<
 *     if isinstance(repeats, int):
 *         if repeats < 0:
 */
  __pyx_v_broadcast = 0;

  /* "cupy/core/core.pyx":2411
 *     # other inputs the dimension must match exactly.
 *     cdef bint broadcast = False
 *     if isinstance(repeats, int):             # <<<<<<<<<<<<<<
 *         if repeats < 0:
 *             raise ValueError(
 */
  __pyx_t_1 = PyInt_Check(__pyx_v_repeats); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2412
 *     cdef bint broadcast = False
 *     if isinstance(repeats, int):
 *         if repeats < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 "'repeats' should not be negative: {}".format(repeats))
 */
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_repeats, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2412, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2412, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(__pyx_t_2)) {

      /* "cupy/core/core.pyx":2414
 *         if repeats < 0:
 *             raise ValueError(
 *                 "'repeats' should not be negative: {}".format(repeats))             # <<<<<<<<<<<<<<
 *         broadcast = True
 *         repeats = [repeats]
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_repeats_should_not_be_negative, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2414, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(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);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_repeats); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2414, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_repeats};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2414, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_repeats};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2414, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2414, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
          __Pyx_INCREF(__pyx_v_repeats);
          __Pyx_GIVEREF(__pyx_v_repeats);
          PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_repeats);
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2414, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2413
 *     if isinstance(repeats, int):
 *         if repeats < 0:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 "'repeats' should not be negative: {}".format(repeats))
 *         broadcast = True
 */
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2413, __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(0, 2413, __pyx_L1_error)

      /* "cupy/core/core.pyx":2412
 *     cdef bint broadcast = False
 *     if isinstance(repeats, int):
 *         if repeats < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 "'repeats' should not be negative: {}".format(repeats))
 */
    }

    /* "cupy/core/core.pyx":2415
 *             raise ValueError(
 *                 "'repeats' should not be negative: {}".format(repeats))
 *         broadcast = True             # <<<<<<<<<<<<<<
 *         repeats = [repeats]
 *     elif cpython.PySequence_Check(repeats):
 */
    __pyx_v_broadcast = 1;

    /* "cupy/core/core.pyx":2416
 *                 "'repeats' should not be negative: {}".format(repeats))
 *         broadcast = True
 *         repeats = [repeats]             # <<<<<<<<<<<<<<
 *     elif cpython.PySequence_Check(repeats):
 *         for rep in repeats:
 */
    __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_repeats);
    __Pyx_GIVEREF(__pyx_v_repeats);
    PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_repeats);
    __Pyx_DECREF_SET(__pyx_v_repeats, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2411
 *     # other inputs the dimension must match exactly.
 *     cdef bint broadcast = False
 *     if isinstance(repeats, int):             # <<<<<<<<<<<<<<
 *         if repeats < 0:
 *             raise ValueError(
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2417
 *         broadcast = True
 *         repeats = [repeats]
 *     elif cpython.PySequence_Check(repeats):             # <<<<<<<<<<<<<<
 *         for rep in repeats:
 *             if rep < 0:
 */
  __pyx_t_2 = (PySequence_Check(__pyx_v_repeats) != 0);
  if (likely(__pyx_t_2)) {

    /* "cupy/core/core.pyx":2418
 *         repeats = [repeats]
 *     elif cpython.PySequence_Check(repeats):
 *         for rep in repeats:             # <<<<<<<<<<<<<<
 *             if rep < 0:
 *                 raise ValueError(
 */
    if (likely(PyList_CheckExact(__pyx_v_repeats)) || PyTuple_CheckExact(__pyx_v_repeats)) {
      __pyx_t_4 = __pyx_v_repeats; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_repeats); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2418, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2418, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2418, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2418, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2418, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2418, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_8(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 2418, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_rep, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":2419
 *     elif cpython.PySequence_Check(repeats):
 *         for rep in repeats:
 *             if rep < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     "all elements of 'repeats' should not be negative: {}"
 */
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_rep, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2419, __pyx_L1_error)
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2419, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__pyx_t_2)) {

        /* "cupy/core/core.pyx":2422
 *                 raise ValueError(
 *                     "all elements of 'repeats' should not be negative: {}"
 *                     .format(repeats))             # <<<<<<<<<<<<<<
 *         if len(repeats) == 1:
 *             broadcast = True
 */
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_all_elements_of_repeats_should_n, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2422, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_5 = NULL;
        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);
          }
        }
        if (!__pyx_t_5) {
          __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_repeats); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2422, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_repeats};
            __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2422, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_GOTREF(__pyx_t_3);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_repeats};
            __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2422, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_GOTREF(__pyx_t_3);
          } else
          #endif
          {
            __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2422, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __pyx_t_5 = NULL;
            __Pyx_INCREF(__pyx_v_repeats);
            __Pyx_GIVEREF(__pyx_v_repeats);
            PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_repeats);
            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2422, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "cupy/core/core.pyx":2420
 *         for rep in repeats:
 *             if rep < 0:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     "all elements of 'repeats' should not be negative: {}"
 *                     .format(repeats))
 */
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2420, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_Raise(__pyx_t_6, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __PYX_ERR(0, 2420, __pyx_L1_error)

        /* "cupy/core/core.pyx":2419
 *     elif cpython.PySequence_Check(repeats):
 *         for rep in repeats:
 *             if rep < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     "all elements of 'repeats' should not be negative: {}"
 */
      }

      /* "cupy/core/core.pyx":2418
 *         repeats = [repeats]
 *     elif cpython.PySequence_Check(repeats):
 *         for rep in repeats:             # <<<<<<<<<<<<<<
 *             if rep < 0:
 *                 raise ValueError(
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2423
 *                     "all elements of 'repeats' should not be negative: {}"
 *                     .format(repeats))
 *         if len(repeats) == 1:             # <<<<<<<<<<<<<<
 *             broadcast = True
 *     else:
 */
    __pyx_t_7 = PyObject_Length(__pyx_v_repeats); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2423, __pyx_L1_error)
    __pyx_t_2 = ((__pyx_t_7 == 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2424
 *                     .format(repeats))
 *         if len(repeats) == 1:
 *             broadcast = True             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError(
 */
      __pyx_v_broadcast = 1;

      /* "cupy/core/core.pyx":2423
 *                     "all elements of 'repeats' should not be negative: {}"
 *                     .format(repeats))
 *         if len(repeats) == 1:             # <<<<<<<<<<<<<<
 *             broadcast = True
 *     else:
 */
    }

    /* "cupy/core/core.pyx":2417
 *         broadcast = True
 *         repeats = [repeats]
 *     elif cpython.PySequence_Check(repeats):             # <<<<<<<<<<<<<<
 *         for rep in repeats:
 *             if rep < 0:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2426
 *             broadcast = True
 *     else:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             "'repeats' should be int or sequence: {}".format(repeats))
 * 
 */
  /*else*/ {

    /* "cupy/core/core.pyx":2427
 *     else:
 *         raise ValueError(
 *             "'repeats' should be int or sequence: {}".format(repeats))             # <<<<<<<<<<<<<<
 * 
 *     if axis is None:
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_repeats_should_be_int_or_sequen, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_repeats); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2427, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_repeats};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2427, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_repeats};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2427, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2427, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __pyx_t_3 = NULL;
        __Pyx_INCREF(__pyx_v_repeats);
        __Pyx_GIVEREF(__pyx_v_repeats);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_repeats);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2427, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2426
 *             broadcast = True
 *     else:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             "'repeats' should be int or sequence: {}".format(repeats))
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2426, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(0, 2426, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":2429
 *             "'repeats' should be int or sequence: {}".format(repeats))
 * 
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         if broadcast:
 *             a = a.reshape((-1, 1))
 */
  __pyx_t_2 = (__pyx_v_axis == Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2430
 * 
 *     if axis is None:
 *         if broadcast:             # <<<<<<<<<<<<<<
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)
 */
    __pyx_t_1 = (__pyx_v_broadcast != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":2431
 *     if axis is None:
 *         if broadcast:
 *             a = a.reshape((-1, 1))             # <<<<<<<<<<<<<<
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)
 *             if ret.size:
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2431, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__96, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2431, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2431, __pyx_L1_error)
      __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2432
 *         if broadcast:
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)             # <<<<<<<<<<<<<<
 *             if ret.size:
 *                 ret[...] = a
 */
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_a->size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2432, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_repeats, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2432, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2432, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_6);
      __pyx_t_4 = 0;
      __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2432, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2432, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) __PYX_ERR(0, 2432, __pyx_L1_error)
      __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_6, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2432, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2433
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)
 *             if ret.size:             # <<<<<<<<<<<<<<
 *                 ret[...] = a
 *             return ret.ravel()
 */
      __pyx_t_1 = (__pyx_v_ret->size != 0);
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":2434
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)
 *             if ret.size:
 *                 ret[...] = a             # <<<<<<<<<<<<<<
 *             return ret.ravel()
 *         else:
 */
        if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_ret), Py_Ellipsis, ((PyObject *)__pyx_v_a)) < 0)) __PYX_ERR(0, 2434, __pyx_L1_error)

        /* "cupy/core/core.pyx":2433
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)
 *             if ret.size:             # <<<<<<<<<<<<<<
 *                 ret[...] = a
 *             return ret.ravel()
 */
      }

      /* "cupy/core/core.pyx":2435
 *             if ret.size:
 *                 ret[...] = a
 *             return ret.ravel()             # <<<<<<<<<<<<<<
 *         else:
 *             a = a.ravel()
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ret->__pyx_vtab)->ravel(__pyx_v_ret, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2435, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
      __pyx_t_4 = 0;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2430
 * 
 *     if axis is None:
 *         if broadcast:             # <<<<<<<<<<<<<<
 *             a = a.reshape((-1, 1))
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)
 */
    }

    /* "cupy/core/core.pyx":2437
 *             return ret.ravel()
 *         else:
 *             a = a.ravel()             # <<<<<<<<<<<<<<
 *             axis = 0
 *     elif not (-a.ndim <= axis < a.ndim):
 */
    /*else*/ {
      __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->ravel(__pyx_v_a, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2437, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2438
 *         else:
 *             a = a.ravel()
 *             axis = 0             # <<<<<<<<<<<<<<
 *     elif not (-a.ndim <= axis < a.ndim):
 *         raise _AxisError(
 */
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_DECREF_SET(__pyx_v_axis, __pyx_int_0);
    }

    /* "cupy/core/core.pyx":2429
 *             "'repeats' should be int or sequence: {}".format(repeats))
 * 
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         if broadcast:
 *             a = a.reshape((-1, 1))
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":2439
 *             a = a.ravel()
 *             axis = 0
 *     elif not (-a.ndim <= axis < a.ndim):             # <<<<<<<<<<<<<<
 *         raise _AxisError(
 *             'axis {} is out of bounds for array of dimension {}'.format(
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = PyNumber_Negative(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_9, __pyx_v_axis, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2439, __pyx_L1_error)
  if (__Pyx_PyObject_IsTrue(__pyx_t_4)) {
    __Pyx_DECREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2439, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_6, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2439, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2439, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "cupy/core/core.pyx":2440
 *             axis = 0
 *     elif not (-a.ndim <= axis < a.ndim):
 *         raise _AxisError(             # <<<<<<<<<<<<<<
 *             'axis {} is out of bounds for array of dimension {}'.format(
 *                 axis, a.ndim))
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2440, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);

    /* "cupy/core/core.pyx":2441
 *     elif not (-a.ndim <= axis < a.ndim):
 *         raise _AxisError(
 *             'axis {} is out of bounds for array of dimension {}'.format(             # <<<<<<<<<<<<<<
 *                 axis, a.ndim))
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_axis_is_out_of_bounds_for_array, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2441, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "cupy/core/core.pyx":2442
 *         raise _AxisError(
 *             'axis {} is out of bounds for array of dimension {}'.format(
 *                 axis, a.ndim))             # <<<<<<<<<<<<<<
 * 
 *     if broadcast:
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2442, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_10 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_axis, __pyx_t_5};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2441, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_axis, __pyx_t_5};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2441, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2441, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_v_axis);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2441, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2440, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_6};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2440, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_6};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2440, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2440, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); __pyx_t_3 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2440, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2440, __pyx_L1_error)

    /* "cupy/core/core.pyx":2439
 *             a = a.ravel()
 *             axis = 0
 *     elif not (-a.ndim <= axis < a.ndim):             # <<<<<<<<<<<<<<
 *         raise _AxisError(
 *             'axis {} is out of bounds for array of dimension {}'.format(
 */
  }
  __pyx_L9:;

  /* "cupy/core/core.pyx":2444
 *                 axis, a.ndim))
 * 
 *     if broadcast:             # <<<<<<<<<<<<<<
 *         repeats = repeats * a._shape[axis % a._shape.size()]
 *     elif a.shape[axis] != len(repeats):
 */
  __pyx_t_2 = (__pyx_v_broadcast != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2445
 * 
 *     if broadcast:
 *         repeats = repeats * a._shape[axis % a._shape.size()]             # <<<<<<<<<<<<<<
 *     elif a.shape[axis] != len(repeats):
 *         raise ValueError(
 */
    __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_a->_shape.size()); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2445, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = PyNumber_Remainder(__pyx_v_axis, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2445, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_13 = __Pyx_PyInt_As_size_t(__pyx_t_9); if (unlikely((__pyx_t_13 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2445, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyInt_FromSsize_t((__pyx_v_a->_shape[__pyx_t_13])); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2445, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = PyNumber_Multiply(__pyx_v_repeats, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2445, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF_SET(__pyx_v_repeats, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2444
 *                 axis, a.ndim))
 * 
 *     if broadcast:             # <<<<<<<<<<<<<<
 *         repeats = repeats * a._shape[axis % a._shape.size()]
 *     elif a.shape[axis] != len(repeats):
 */
    goto __pyx_L12;
  }

  /* "cupy/core/core.pyx":2446
 *     if broadcast:
 *         repeats = repeats * a._shape[axis % a._shape.size()]
 *     elif a.shape[axis] != len(repeats):             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             "'repeats' and 'axis' of 'a' should be same length: {} != {}"
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_v_axis); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = PyObject_Length(__pyx_v_repeats); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2446, __pyx_L1_error)
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_12 = PyObject_RichCompare(__pyx_t_9, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2446, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2446, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (unlikely(__pyx_t_2)) {

    /* "cupy/core/core.pyx":2449
 *         raise ValueError(
 *             "'repeats' and 'axis' of 'a' should be same length: {} != {}"
 *             .format(a.shape[axis], len(repeats)))             # <<<<<<<<<<<<<<
 * 
 *     if axis < 0:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_repeats_and_axis_of_a_should_be, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2449, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2449, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_t_9, __pyx_v_axis); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2449, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_7 = PyObject_Length(__pyx_v_repeats); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2449, __pyx_L1_error)
    __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2449, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_3 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_6, __pyx_t_9};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2449, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_6, __pyx_t_9};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2449, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2449, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_11, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_11, __pyx_t_9);
      __pyx_t_6 = 0;
      __pyx_t_9 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2449, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2447
 *         repeats = repeats * a._shape[axis % a._shape.size()]
 *     elif a.shape[axis] != len(repeats):
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             "'repeats' and 'axis' of 'a' should be same length: {} != {}"
 *             .format(a.shape[axis], len(repeats)))
 */
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2447, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2447, __pyx_L1_error)

    /* "cupy/core/core.pyx":2446
 *     if broadcast:
 *         repeats = repeats * a._shape[axis % a._shape.size()]
 *     elif a.shape[axis] != len(repeats):             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             "'repeats' and 'axis' of 'a' should be same length: {} != {}"
 */
  }
  __pyx_L12:;

  /* "cupy/core/core.pyx":2451
 *             .format(a.shape[axis], len(repeats)))
 * 
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += a.ndim
 * 
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2451, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2451, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2452
 * 
 *     if axis < 0:
 *         axis += a.ndim             # <<<<<<<<<<<<<<
 * 
 *     ret_shape = list(a.shape)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2452, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_v_axis, __pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2452, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_12);
    __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":2451
 *             .format(a.shape[axis], len(repeats)))
 * 
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += a.ndim
 * 
 */
  }

  /* "cupy/core/core.pyx":2454
 *         axis += a.ndim
 * 
 *     ret_shape = list(a.shape)             # <<<<<<<<<<<<<<
 *     ret_shape[axis] = sum(repeats)
 *     ret = ndarray(ret_shape, dtype=a.dtype)
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_4 = PySequence_List(__pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_v_ret_shape = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2455
 * 
 *     ret_shape = list(a.shape)
 *     ret_shape[axis] = sum(repeats)             # <<<<<<<<<<<<<<
 *     ret = ndarray(ret_shape, dtype=a.dtype)
 *     a_index = [slice(None)] * len(ret_shape)
 */
  __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_sum, __pyx_v_repeats); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (unlikely(PyObject_SetItem(__pyx_v_ret_shape, __pyx_v_axis, __pyx_t_4) < 0)) __PYX_ERR(0, 2455, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2456
 *     ret_shape = list(a.shape)
 *     ret_shape[axis] = sum(repeats)
 *     ret = ndarray(ret_shape, dtype=a.dtype)             # <<<<<<<<<<<<<<
 *     a_index = [slice(None)] * len(ret_shape)
 *     ret_index = list(a_index)
 */
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_ret_shape);
  __Pyx_GIVEREF(__pyx_v_ret_shape);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_ret_shape);
  __pyx_t_12 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) __PYX_ERR(0, 2456, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_4, __pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2457
 *     ret_shape[axis] = sum(repeats)
 *     ret = ndarray(ret_shape, dtype=a.dtype)
 *     a_index = [slice(None)] * len(ret_shape)             # <<<<<<<<<<<<<<
 *     ret_index = list(a_index)
 *     offset = 0
 */
  __pyx_t_7 = PyList_GET_SIZE(__pyx_v_ret_shape); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2457, __pyx_L1_error)
  __pyx_t_5 = PyList_New(1 * ((__pyx_t_7<0) ? 0:__pyx_t_7)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  { Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < __pyx_t_7; __pyx_temp++) {
      __Pyx_INCREF(__pyx_slice__97);
      __Pyx_GIVEREF(__pyx_slice__97);
      PyList_SET_ITEM(__pyx_t_5, __pyx_temp, __pyx_slice__97);
    }
  }
  __pyx_v_a_index = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2458
 *     ret = ndarray(ret_shape, dtype=a.dtype)
 *     a_index = [slice(None)] * len(ret_shape)
 *     ret_index = list(a_index)             # <<<<<<<<<<<<<<
 *     offset = 0
 *     for i in range(a._shape[axis]):
 */
  __pyx_t_5 = PySequence_List(__pyx_v_a_index); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_ret_index = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2459
 *     a_index = [slice(None)] * len(ret_shape)
 *     ret_index = list(a_index)
 *     offset = 0             # <<<<<<<<<<<<<<
 *     for i in range(a._shape[axis]):
 *         if repeats[i] == 0:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_offset = __pyx_int_0;

  /* "cupy/core/core.pyx":2460
 *     ret_index = list(a_index)
 *     offset = 0
 *     for i in range(a._shape[axis]):             # <<<<<<<<<<<<<<
 *         if repeats[i] == 0:
 *             continue
 */
  __pyx_t_13 = __Pyx_PyInt_As_size_t(__pyx_v_axis); if (unlikely((__pyx_t_13 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2460, __pyx_L1_error)
  __pyx_t_5 = PyInt_FromSsize_t((__pyx_v_a->_shape[__pyx_t_13])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_t_12)) || PyTuple_CheckExact(__pyx_t_12)) {
    __pyx_t_5 = __pyx_t_12; __Pyx_INCREF(__pyx_t_5); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2460, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2460, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_12 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_12); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2460, __pyx_L1_error)
        #else
        __pyx_t_12 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2460, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_12); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2460, __pyx_L1_error)
        #else
        __pyx_t_12 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2460, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
      }
    } else {
      __pyx_t_12 = __pyx_t_8(__pyx_t_5);
      if (unlikely(!__pyx_t_12)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2460, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_12);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_12);
    __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":2461
 *     offset = 0
 *     for i in range(a._shape[axis]):
 *         if repeats[i] == 0:             # <<<<<<<<<<<<<<
 *             continue
 *         a_index[axis] = slice(i, i + 1)
 */
    __pyx_t_12 = __Pyx_PyObject_GetItem(__pyx_v_repeats, __pyx_v_i); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2461, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_t_12, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2461, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2461, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2462
 *     for i in range(a._shape[axis]):
 *         if repeats[i] == 0:
 *             continue             # <<<<<<<<<<<<<<
 *         a_index[axis] = slice(i, i + 1)
 *         ret_index[axis] = slice(offset, offset + repeats[i])
 */
      goto __pyx_L14_continue;

      /* "cupy/core/core.pyx":2461
 *     offset = 0
 *     for i in range(a._shape[axis]):
 *         if repeats[i] == 0:             # <<<<<<<<<<<<<<
 *             continue
 *         a_index[axis] = slice(i, i + 1)
 */
    }

    /* "cupy/core/core.pyx":2463
 *         if repeats[i] == 0:
 *             continue
 *         a_index[axis] = slice(i, i + 1)             # <<<<<<<<<<<<<<
 *         ret_index[axis] = slice(offset, offset + repeats[i])
 *         # convert to tuple because cupy has a indexing bug
 */
    __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2463, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_12 = PySlice_New(__pyx_v_i, __pyx_t_4, Py_None); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2463, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(PyObject_SetItem(__pyx_v_a_index, __pyx_v_axis, __pyx_t_12) < 0)) __PYX_ERR(0, 2463, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":2464
 *             continue
 *         a_index[axis] = slice(i, i + 1)
 *         ret_index[axis] = slice(offset, offset + repeats[i])             # <<<<<<<<<<<<<<
 *         # convert to tuple because cupy has a indexing bug
 *         ret[tuple(ret_index)] = a[tuple(a_index)]
 */
    __pyx_t_12 = __Pyx_PyObject_GetItem(__pyx_v_repeats, __pyx_v_i); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_4 = PyNumber_Add(__pyx_v_offset, __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PySlice_New(__pyx_v_offset, __pyx_t_4, Py_None); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(PyObject_SetItem(__pyx_v_ret_index, __pyx_v_axis, __pyx_t_12) < 0)) __PYX_ERR(0, 2464, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":2466
 *         ret_index[axis] = slice(offset, offset + repeats[i])
 *         # convert to tuple because cupy has a indexing bug
 *         ret[tuple(ret_index)] = a[tuple(a_index)]             # <<<<<<<<<<<<<<
 *         offset += repeats[i]
 *     return ret
 */
    __pyx_t_12 = PyList_AsTuple(__pyx_v_a_index); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2466, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2466, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyList_AsTuple(__pyx_v_ret_index); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2466, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_ret), __pyx_t_12, __pyx_t_4) < 0)) __PYX_ERR(0, 2466, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2467
 *         # convert to tuple because cupy has a indexing bug
 *         ret[tuple(ret_index)] = a[tuple(a_index)]
 *         offset += repeats[i]             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_repeats, __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2467, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_v_offset, __pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2467, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_offset, __pyx_t_12);
    __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":2460
 *     ret_index = list(a_index)
 *     offset = 0
 *     for i in range(a._shape[axis]):             # <<<<<<<<<<<<<<
 *         if repeats[i] == 0:
 *             continue
 */
    __pyx_L14_continue:;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2468
 *         ret[tuple(ret_index)] = a[tuple(a_index)]
 *         offset += repeats[i]
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2392
 * 
 * 
 * cpdef ndarray _repeat(ndarray a, repeats, axis=None):             # <<<<<<<<<<<<<<
 *     """Repeat arrays along an axis.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core._repeat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_rep);
  __Pyx_XDECREF(__pyx_v_ret_shape);
  __Pyx_XDECREF(__pyx_v_a_index);
  __Pyx_XDECREF(__pyx_v_ret_index);
  __Pyx_XDECREF(__pyx_v_offset);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_repeats);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_67_repeat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_66_repeat[] = "_repeat(ndarray a, repeats, axis=None) -> ndarray\nRepeat arrays along an axis.\n\n    Args:\n        a (cupy.ndarray): Array to transform.\n        repeats (int, list or tuple): The number of repeats.\n        axis (int): The axis to repeat.\n\n    Returns:\n        cupy.ndarray: Transformed array with repeats.\n\n    .. seealso:: :func:`numpy.repeat`\n\n    ";
static PyObject *__pyx_pw_4cupy_4core_4core_67_repeat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_repeats = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_repeat (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_repeats,&__pyx_n_s_axis,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)Py_None);
    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_a)) != 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_repeats)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_repeat", 0, 2, 3, 1); __PYX_ERR(0, 2392, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_repeat") < 0)) __PYX_ERR(0, 2392, __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_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_repeats = values[1];
    __pyx_v_axis = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_repeat", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2392, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._repeat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2392, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_66_repeat(__pyx_self, __pyx_v_a, __pyx_v_repeats, __pyx_v_axis);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_66_repeat(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_repeats, PyObject *__pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__repeat __pyx_t_2;
  __Pyx_RefNannySetupContext("_repeat", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__repeat(__pyx_v_a, __pyx_v_repeats, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._repeat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2471
 * 
 * 
 * cpdef ndarray concatenate_method(tup, int axis):             # <<<<<<<<<<<<<<
 *     cdef int ndim
 *     cdef int i
 */

static PyObject *__pyx_pw_4cupy_4core_4core_69concatenate_method(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_concatenate_method(PyObject *__pyx_v_tup, int __pyx_v_axis, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_v_ndim;
  int __pyx_v_i;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  int __pyx_v_have_same_types;
  std::vector<Py_ssize_t>  __pyx_v_shape;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_arrays = NULL;
  PyObject *__pyx_v_o = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  std::vector<Py_ssize_t>  __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  int __pyx_t_16;
  __Pyx_RefNannySetupContext("concatenate_method", 0);

  /* "cupy/core/core.pyx":2478
 *     cdef vector.vector[Py_ssize_t] shape
 * 
 *     ndim = -1             # <<<<<<<<<<<<<<
 *     dtype = None
 *     have_same_types = True
 */
  __pyx_v_ndim = -1;

  /* "cupy/core/core.pyx":2479
 * 
 *     ndim = -1
 *     dtype = None             # <<<<<<<<<<<<<<
 *     have_same_types = True
 *     arrays = list(tup)
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_dtype = Py_None;

  /* "cupy/core/core.pyx":2480
 *     ndim = -1
 *     dtype = None
 *     have_same_types = True             # <<<<<<<<<<<<<<
 *     arrays = list(tup)
 *     for o in arrays:
 */
  __pyx_v_have_same_types = 1;

  /* "cupy/core/core.pyx":2481
 *     dtype = None
 *     have_same_types = True
 *     arrays = list(tup)             # <<<<<<<<<<<<<<
 *     for o in arrays:
 *         if not isinstance(o, ndarray):
 */
  __pyx_t_1 = PySequence_List(__pyx_v_tup); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2481, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_arrays = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2482
 *     have_same_types = True
 *     arrays = list(tup)
 *     for o in arrays:             # <<<<<<<<<<<<<<
 *         if not isinstance(o, ndarray):
 *             raise TypeError('Only cupy arrays can be concatenated')
 */
  __pyx_t_1 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2482, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_o, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2483
 *     arrays = list(tup)
 *     for o in arrays:
 *         if not isinstance(o, ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError('Only cupy arrays can be concatenated')
 *         a = o
 */
    __pyx_t_4 = __Pyx_TypeCheck(__pyx_v_o, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_5 = ((!(__pyx_t_4 != 0)) != 0);
    if (unlikely(__pyx_t_5)) {

      /* "cupy/core/core.pyx":2484
 *     for o in arrays:
 *         if not isinstance(o, ndarray):
 *             raise TypeError('Only cupy arrays can be concatenated')             # <<<<<<<<<<<<<<
 *         a = o
 *         if a.ndim == 0:
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__98, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2484, __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(0, 2484, __pyx_L1_error)

      /* "cupy/core/core.pyx":2483
 *     arrays = list(tup)
 *     for o in arrays:
 *         if not isinstance(o, ndarray):             # <<<<<<<<<<<<<<
 *             raise TypeError('Only cupy arrays can be concatenated')
 *         a = o
 */
    }

    /* "cupy/core/core.pyx":2485
 *         if not isinstance(o, ndarray):
 *             raise TypeError('Only cupy arrays can be concatenated')
 *         a = o             # <<<<<<<<<<<<<<
 *         if a.ndim == 0:
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')
 */
    if (!(likely(((__pyx_v_o) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_o, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2485, __pyx_L1_error)
    __pyx_t_3 = __pyx_v_o;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2486
 *             raise TypeError('Only cupy arrays can be concatenated')
 *         a = o
 *         if a.ndim == 0:             # <<<<<<<<<<<<<<
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')
 *         if ndim == -1:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2486, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2486, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2486, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_t_5)) {

      /* "cupy/core/core.pyx":2487
 *         a = o
 *         if a.ndim == 0:
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')             # <<<<<<<<<<<<<<
 *         if ndim == -1:
 *             ndim = a.ndim
 */
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__99, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2487, __pyx_L1_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(0, 2487, __pyx_L1_error)

      /* "cupy/core/core.pyx":2486
 *             raise TypeError('Only cupy arrays can be concatenated')
 *         a = o
 *         if a.ndim == 0:             # <<<<<<<<<<<<<<
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')
 *         if ndim == -1:
 */
    }

    /* "cupy/core/core.pyx":2488
 *         if a.ndim == 0:
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')
 *         if ndim == -1:             # <<<<<<<<<<<<<<
 *             ndim = a.ndim
 *             shape = a._shape
 */
    __pyx_t_5 = ((__pyx_v_ndim == -1L) != 0);
    if (__pyx_t_5) {

      /* "cupy/core/core.pyx":2489
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')
 *         if ndim == -1:
 *             ndim = a.ndim             # <<<<<<<<<<<<<<
 *             shape = a._shape
 *             if axis < 0:
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2489, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2489, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_ndim = __pyx_t_7;

      /* "cupy/core/core.pyx":2490
 *         if ndim == -1:
 *             ndim = a.ndim
 *             shape = a._shape             # <<<<<<<<<<<<<<
 *             if axis < 0:
 *                 axis += ndim
 */
      __pyx_t_8 = __pyx_v_a->_shape;
      __pyx_v_shape = __pyx_t_8;

      /* "cupy/core/core.pyx":2491
 *             ndim = a.ndim
 *             shape = a._shape
 *             if axis < 0:             # <<<<<<<<<<<<<<
 *                 axis += ndim
 *             if axis < 0 or axis >= ndim:
 */
      __pyx_t_5 = ((__pyx_v_axis < 0) != 0);
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":2492
 *             shape = a._shape
 *             if axis < 0:
 *                 axis += ndim             # <<<<<<<<<<<<<<
 *             if axis < 0 or axis >= ndim:
 *                 raise _AxisError(
 */
        __pyx_v_axis = (__pyx_v_axis + __pyx_v_ndim);

        /* "cupy/core/core.pyx":2491
 *             ndim = a.ndim
 *             shape = a._shape
 *             if axis < 0:             # <<<<<<<<<<<<<<
 *                 axis += ndim
 *             if axis < 0 or axis >= ndim:
 */
      }

      /* "cupy/core/core.pyx":2493
 *             if axis < 0:
 *                 axis += ndim
 *             if axis < 0 or axis >= ndim:             # <<<<<<<<<<<<<<
 *                 raise _AxisError(
 *                     'axis {} out of bounds [0, {})'.format(axis, ndim))
 */
      __pyx_t_4 = ((__pyx_v_axis < 0) != 0);
      if (!__pyx_t_4) {
      } else {
        __pyx_t_5 = __pyx_t_4;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_4 = ((__pyx_v_axis >= __pyx_v_ndim) != 0);
      __pyx_t_5 = __pyx_t_4;
      __pyx_L10_bool_binop_done:;
      if (unlikely(__pyx_t_5)) {

        /* "cupy/core/core.pyx":2494
 *                 axis += ndim
 *             if axis < 0 or axis >= ndim:
 *                 raise _AxisError(             # <<<<<<<<<<<<<<
 *                     'axis {} out of bounds [0, {})'.format(axis, ndim))
 *             dtype = a.dtype
 */
        __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2494, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);

        /* "cupy/core/core.pyx":2495
 *             if axis < 0 or axis >= ndim:
 *                 raise _AxisError(
 *                     'axis {} out of bounds [0, {})'.format(axis, ndim))             # <<<<<<<<<<<<<<
 *             dtype = a.dtype
 *             continue
 */
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_axis_out_of_bounds_0, __pyx_n_s_format); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2495, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_axis); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2495, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_ndim); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2495, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_13 = NULL;
        __pyx_t_7 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_10);
          if (likely(__pyx_t_13)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_10, function);
            __pyx_t_7 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_10)) {
          PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_11, __pyx_t_12};
          __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2495, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
          PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_11, __pyx_t_12};
          __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2495, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        } else
        #endif
        {
          __pyx_t_14 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2495, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          if (__pyx_t_13) {
            __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_11);
          PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_7, __pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_12);
          PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_7, __pyx_t_12);
          __pyx_t_11 = 0;
          __pyx_t_12 = 0;
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_14, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2495, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        }
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        if (!__pyx_t_10) {
          __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2494, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_3)) {
            PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9};
            __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2494, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
            PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9};
            __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2494, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          } else
          #endif
          {
            __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2494, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_10); __pyx_t_10 = NULL;
            __Pyx_GIVEREF(__pyx_t_9);
            PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_9);
            __pyx_t_9 = 0;
            __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_14, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2494, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_Raise(__pyx_t_6, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __PYX_ERR(0, 2494, __pyx_L1_error)

        /* "cupy/core/core.pyx":2493
 *             if axis < 0:
 *                 axis += ndim
 *             if axis < 0 or axis >= ndim:             # <<<<<<<<<<<<<<
 *                 raise _AxisError(
 *                     'axis {} out of bounds [0, {})'.format(axis, ndim))
 */
      }

      /* "cupy/core/core.pyx":2496
 *                 raise _AxisError(
 *                     'axis {} out of bounds [0, {})'.format(axis, ndim))
 *             dtype = a.dtype             # <<<<<<<<<<<<<<
 *             continue
 * 
 */
      __pyx_t_6 = __pyx_v_a->dtype;
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "cupy/core/core.pyx":2497
 *                     'axis {} out of bounds [0, {})'.format(axis, ndim))
 *             dtype = a.dtype
 *             continue             # <<<<<<<<<<<<<<
 * 
 *         have_same_types = have_same_types and (a.dtype == dtype)
 */
      goto __pyx_L3_continue;

      /* "cupy/core/core.pyx":2488
 *         if a.ndim == 0:
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')
 *         if ndim == -1:             # <<<<<<<<<<<<<<
 *             ndim = a.ndim
 *             shape = a._shape
 */
    }

    /* "cupy/core/core.pyx":2499
 *             continue
 * 
 *         have_same_types = have_same_types and (a.dtype == dtype)             # <<<<<<<<<<<<<<
 *         if a.ndim != ndim:
 *             raise ValueError(
 */
    __pyx_t_4 = (__pyx_v_have_same_types != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L12_bool_binop_done;
    }
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_v_dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2499, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2499, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_5 = __pyx_t_4;
    __pyx_L12_bool_binop_done:;
    __pyx_v_have_same_types = __pyx_t_5;

    /* "cupy/core/core.pyx":2500
 * 
 *         have_same_types = have_same_types and (a.dtype == dtype)
 *         if a.ndim != ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'All arrays to concatenate must have the same ndim')
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2500, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2500, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_14 = PyObject_RichCompare(__pyx_t_6, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2500, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2500, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    if (unlikely(__pyx_t_5)) {

      /* "cupy/core/core.pyx":2501
 *         have_same_types = have_same_types and (a.dtype == dtype)
 *         if a.ndim != ndim:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'All arrays to concatenate must have the same ndim')
 *         for i in range(ndim):
 */
      __pyx_t_14 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__100, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2501, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_Raise(__pyx_t_14, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __PYX_ERR(0, 2501, __pyx_L1_error)

      /* "cupy/core/core.pyx":2500
 * 
 *         have_same_types = have_same_types and (a.dtype == dtype)
 *         if a.ndim != ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'All arrays to concatenate must have the same ndim')
 */
    }

    /* "cupy/core/core.pyx":2503
 *             raise ValueError(
 *                 'All arrays to concatenate must have the same ndim')
 *         for i in range(ndim):             # <<<<<<<<<<<<<<
 *             if i != axis and shape[i] != a._shape[i]:
 *                 raise ValueError(
 */
    __pyx_t_7 = __pyx_v_ndim;
    __pyx_t_15 = __pyx_t_7;
    for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
      __pyx_v_i = __pyx_t_16;

      /* "cupy/core/core.pyx":2504
 *                 'All arrays to concatenate must have the same ndim')
 *         for i in range(ndim):
 *             if i != axis and shape[i] != a._shape[i]:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'All arrays must have same shape except the axis to '
 */
      __pyx_t_4 = ((__pyx_v_i != __pyx_v_axis) != 0);
      if (__pyx_t_4) {
      } else {
        __pyx_t_5 = __pyx_t_4;
        goto __pyx_L18_bool_binop_done;
      }
      __pyx_t_4 = (((__pyx_v_shape[__pyx_v_i]) != (__pyx_v_a->_shape[__pyx_v_i])) != 0);
      __pyx_t_5 = __pyx_t_4;
      __pyx_L18_bool_binop_done:;
      if (unlikely(__pyx_t_5)) {

        /* "cupy/core/core.pyx":2505
 *         for i in range(ndim):
 *             if i != axis and shape[i] != a._shape[i]:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'All arrays must have same shape except the axis to '
 *                     'concatenate')
 */
        __pyx_t_14 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__101, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2505, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_Raise(__pyx_t_14, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __PYX_ERR(0, 2505, __pyx_L1_error)

        /* "cupy/core/core.pyx":2504
 *                 'All arrays to concatenate must have the same ndim')
 *         for i in range(ndim):
 *             if i != axis and shape[i] != a._shape[i]:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'All arrays must have same shape except the axis to '
 */
      }
    }

    /* "cupy/core/core.pyx":2508
 *                     'All arrays must have same shape except the axis to '
 *                     'concatenate')
 *         shape[axis] += a._shape[axis]             # <<<<<<<<<<<<<<
 * 
 *     if ndim == -1:
 */
    __pyx_t_7 = __pyx_v_axis;
    (__pyx_v_shape[__pyx_t_7]) = ((__pyx_v_shape[__pyx_t_7]) + (__pyx_v_a->_shape[__pyx_v_axis]));

    /* "cupy/core/core.pyx":2482
 *     have_same_types = True
 *     arrays = list(tup)
 *     for o in arrays:             # <<<<<<<<<<<<<<
 *         if not isinstance(o, ndarray):
 *             raise TypeError('Only cupy arrays can be concatenated')
 */
    __pyx_L3_continue:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2510
 *         shape[axis] += a._shape[axis]
 * 
 *     if ndim == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError('Cannot concatenate from empty tuple')
 * 
 */
  __pyx_t_5 = ((__pyx_v_ndim == -1L) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "cupy/core/core.pyx":2511
 * 
 *     if ndim == -1:
 *         raise ValueError('Cannot concatenate from empty tuple')             # <<<<<<<<<<<<<<
 * 
 *     if not have_same_types:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__102, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2511, __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(0, 2511, __pyx_L1_error)

    /* "cupy/core/core.pyx":2510
 *         shape[axis] += a._shape[axis]
 * 
 *     if ndim == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError('Cannot concatenate from empty tuple')
 * 
 */
  }

  /* "cupy/core/core.pyx":2513
 *         raise ValueError('Cannot concatenate from empty tuple')
 * 
 *     if not have_same_types:             # <<<<<<<<<<<<<<
 *         dtype = numpy.find_common_type([a.dtype for a in arrays], [])
 *     return _concatenate(arrays, axis, tuple(shape), dtype)
 */
  __pyx_t_5 = ((!(__pyx_v_have_same_types != 0)) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":2514
 * 
 *     if not have_same_types:
 *         dtype = numpy.find_common_type([a.dtype for a in arrays], [])             # <<<<<<<<<<<<<<
 *     return _concatenate(arrays, axis, tuple(shape), dtype)
 * 
 */
    __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_find_common_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_14 = PyList_New(0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_6 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_6); __pyx_t_2 = 0;
    for (;;) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_6)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_9 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_9); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2514, __pyx_L1_error)
      #else
      __pyx_t_9 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2514, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      #endif
      if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2514, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_9));
      __pyx_t_9 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_14, (PyObject*)__pyx_v_a->dtype))) __PYX_ERR(0, 2514, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_14, __pyx_t_6};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2514, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_14, __pyx_t_6};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2514, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2514, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_9) {
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_14);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_7, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_7, __pyx_t_6);
      __pyx_t_14 = 0;
      __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2514, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2513
 *         raise ValueError('Cannot concatenate from empty tuple')
 * 
 *     if not have_same_types:             # <<<<<<<<<<<<<<
 *         dtype = numpy.find_common_type([a.dtype for a in arrays], [])
 *     return _concatenate(arrays, axis, tuple(shape), dtype)
 */
  }

  /* "cupy/core/core.pyx":2515
 *     if not have_same_types:
 *         dtype = numpy.find_common_type([a.dtype for a in arrays], [])
 *     return _concatenate(arrays, axis, tuple(shape), dtype)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__concatenate(__pyx_v_arrays, __pyx_v_axis, ((PyObject*)__pyx_t_3), __pyx_v_dtype, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2471
 * 
 * 
 * cpdef ndarray concatenate_method(tup, int axis):             # <<<<<<<<<<<<<<
 *     cdef int ndim
 *     cdef int i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("cupy.core.core.concatenate_method", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_arrays);
  __Pyx_XDECREF(__pyx_v_o);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_69concatenate_method(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_68concatenate_method[] = "concatenate_method(tup, int axis) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_69concatenate_method(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tup = 0;
  int __pyx_v_axis;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("concatenate_method (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_tup,&__pyx_n_s_axis,0};
    PyObject* values[2] = {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  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_tup)) != 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_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("concatenate_method", 1, 2, 2, 1); __PYX_ERR(0, 2471, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "concatenate_method") < 0)) __PYX_ERR(0, 2471, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_tup = values[0];
    __pyx_v_axis = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_axis == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2471, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("concatenate_method", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2471, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.concatenate_method", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_68concatenate_method(__pyx_self, __pyx_v_tup, __pyx_v_axis);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_68concatenate_method(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tup, int __pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("concatenate_method", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_concatenate_method(__pyx_v_tup, __pyx_v_axis, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.concatenate_method", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2518
 * 
 * 
 * cpdef ndarray _concatenate(list arrays, Py_ssize_t axis, tuple shape, dtype):             # <<<<<<<<<<<<<<
 *     cdef ndarray a, ret
 *     cdef Py_ssize_t i
 */

static PyObject *__pyx_pw_4cupy_4core_4core_71_concatenate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__concatenate(PyObject *__pyx_v_arrays, Py_ssize_t __pyx_v_axis, PyObject *__pyx_v_shape, PyObject *__pyx_v_dtype, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = 0;
  Py_ssize_t __pyx_v_i;
  int __pyx_v_all_same_type;
  int __pyx_v_same_shape_and_contiguous;
  Py_ssize_t __pyx_v_axis_size;
  Py_ssize_t __pyx_v_threshold_size;
  PyObject *__pyx_v_total_bytes = NULL;
  PyObject *__pyx_v_slice_list = NULL;
  PyObject *__pyx_v_aw = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  Py_ssize_t __pyx_t_11;
  __Pyx_RefNannySetupContext("_concatenate", 0);

  /* "cupy/core/core.pyx":2524
 *     cdef Py_ssize_t axis_size
 *     # If arrays are large, Issuing each copy method is efficient.
 *     cdef Py_ssize_t threshold_size = 2 * 1024 * 1024             # <<<<<<<<<<<<<<
 * 
 *     if len(arrays) > 8:
 */
  __pyx_v_threshold_size = 0x200000;

  /* "cupy/core/core.pyx":2526
 *     cdef Py_ssize_t threshold_size = 2 * 1024 * 1024
 * 
 *     if len(arrays) > 8:             # <<<<<<<<<<<<<<
 *         all_same_type = True
 *         same_shape_and_contiguous = True
 */
  if (unlikely(__pyx_v_arrays == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 2526, __pyx_L1_error)
  }
  __pyx_t_1 = PyList_GET_SIZE(__pyx_v_arrays); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2526, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 > 8) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2527
 * 
 *     if len(arrays) > 8:
 *         all_same_type = True             # <<<<<<<<<<<<<<
 *         same_shape_and_contiguous = True
 *         axis_size = shape[axis] // len(arrays)
 */
    __pyx_v_all_same_type = 1;

    /* "cupy/core/core.pyx":2528
 *     if len(arrays) > 8:
 *         all_same_type = True
 *         same_shape_and_contiguous = True             # <<<<<<<<<<<<<<
 *         axis_size = shape[axis] // len(arrays)
 *         total_bytes = 0
 */
    __pyx_v_same_shape_and_contiguous = 1;

    /* "cupy/core/core.pyx":2529
 *         all_same_type = True
 *         same_shape_and_contiguous = True
 *         axis_size = shape[axis] // len(arrays)             # <<<<<<<<<<<<<<
 *         total_bytes = 0
 *         for a in arrays:
 */
    if (unlikely(__pyx_v_shape == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 2529, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_shape, __pyx_v_axis, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2529, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__pyx_v_arrays == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(0, 2529, __pyx_L1_error)
    }
    __pyx_t_1 = PyList_GET_SIZE(__pyx_v_arrays); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2529, __pyx_L1_error)
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2529, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyNumber_FloorDivide(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2529, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2529, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_axis_size = __pyx_t_1;

    /* "cupy/core/core.pyx":2530
 *         same_shape_and_contiguous = True
 *         axis_size = shape[axis] // len(arrays)
 *         total_bytes = 0             # <<<<<<<<<<<<<<
 *         for a in arrays:
 *             if a.dtype != dtype:
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_v_total_bytes = __pyx_int_0;

    /* "cupy/core/core.pyx":2531
 *         axis_size = shape[axis] // len(arrays)
 *         total_bytes = 0
 *         for a in arrays:             # <<<<<<<<<<<<<<
 *             if a.dtype != dtype:
 *                 all_same_type = False
 */
    if (unlikely(__pyx_v_arrays == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 2531, __pyx_L1_error)
    }
    __pyx_t_5 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0;
    for (;;) {
      if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_5)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 2531, __pyx_L1_error)
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2531, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2531, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2532
 *         total_bytes = 0
 *         for a in arrays:
 *             if a.dtype != dtype:             # <<<<<<<<<<<<<<
 *                 all_same_type = False
 *                 break
 */
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_v_dtype, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2532, __pyx_L1_error)
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2532, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":2533
 *         for a in arrays:
 *             if a.dtype != dtype:
 *                 all_same_type = False             # <<<<<<<<<<<<<<
 *                 break
 *             if same_shape_and_contiguous:
 */
        __pyx_v_all_same_type = 0;

        /* "cupy/core/core.pyx":2534
 *             if a.dtype != dtype:
 *                 all_same_type = False
 *                 break             # <<<<<<<<<<<<<<
 *             if same_shape_and_contiguous:
 *                 same_shape_and_contiguous = (
 */
        goto __pyx_L5_break;

        /* "cupy/core/core.pyx":2532
 *         total_bytes = 0
 *         for a in arrays:
 *             if a.dtype != dtype:             # <<<<<<<<<<<<<<
 *                 all_same_type = False
 *                 break
 */
      }

      /* "cupy/core/core.pyx":2535
 *                 all_same_type = False
 *                 break
 *             if same_shape_and_contiguous:             # <<<<<<<<<<<<<<
 *                 same_shape_and_contiguous = (
 *                     a._c_contiguous and a._shape[axis] == axis_size)
 */
      __pyx_t_2 = (__pyx_v_same_shape_and_contiguous != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":2537
 *             if same_shape_and_contiguous:
 *                 same_shape_and_contiguous = (
 *                     a._c_contiguous and a._shape[axis] == axis_size)             # <<<<<<<<<<<<<<
 *             total_bytes += a.size * a.dtype.itemsize
 * 
 */
        __pyx_t_6 = (__pyx_v_a->_c_contiguous != 0);
        if (__pyx_t_6) {
        } else {
          __pyx_t_2 = __pyx_t_6;
          goto __pyx_L8_bool_binop_done;
        }
        __pyx_t_6 = (((__pyx_v_a->_shape[__pyx_v_axis]) == __pyx_v_axis_size) != 0);
        __pyx_t_2 = __pyx_t_6;
        __pyx_L8_bool_binop_done:;
        __pyx_v_same_shape_and_contiguous = __pyx_t_2;

        /* "cupy/core/core.pyx":2535
 *                 all_same_type = False
 *                 break
 *             if same_shape_and_contiguous:             # <<<<<<<<<<<<<<
 *                 same_shape_and_contiguous = (
 *                     a._c_contiguous and a._shape[axis] == axis_size)
 */
      }

      /* "cupy/core/core.pyx":2538
 *                 same_shape_and_contiguous = (
 *                     a._c_contiguous and a._shape[axis] == axis_size)
 *             total_bytes += a.size * a.dtype.itemsize             # <<<<<<<<<<<<<<
 * 
 *         if all_same_type and total_bytes < threshold_size * len(arrays):
 */
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_a->size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2538, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2538, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = PyNumber_Multiply(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2538, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_total_bytes, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2538, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF_SET(__pyx_v_total_bytes, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":2531
 *         axis_size = shape[axis] // len(arrays)
 *         total_bytes = 0
 *         for a in arrays:             # <<<<<<<<<<<<<<
 *             if a.dtype != dtype:
 *                 all_same_type = False
 */
    }
    __pyx_L5_break:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2540
 *             total_bytes += a.size * a.dtype.itemsize
 * 
 *         if all_same_type and total_bytes < threshold_size * len(arrays):             # <<<<<<<<<<<<<<
 *             return _concatenate_single_kernel(
 *                 arrays, axis, shape, dtype, same_shape_and_contiguous)
 */
    __pyx_t_6 = (__pyx_v_all_same_type != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_2 = __pyx_t_6;
      goto __pyx_L11_bool_binop_done;
    }
    if (unlikely(__pyx_v_arrays == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(0, 2540, __pyx_L1_error)
    }
    __pyx_t_1 = PyList_GET_SIZE(__pyx_v_arrays); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2540, __pyx_L1_error)
    __pyx_t_5 = PyInt_FromSsize_t((__pyx_v_threshold_size * __pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2540, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_total_bytes, __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2540, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 2540, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __pyx_t_6;
    __pyx_L11_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2541
 * 
 *         if all_same_type and total_bytes < threshold_size * len(arrays):
 *             return _concatenate_single_kernel(             # <<<<<<<<<<<<<<
 *                 arrays, axis, shape, dtype, same_shape_and_contiguous)
 * 
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));

      /* "cupy/core/core.pyx":2542
 *         if all_same_type and total_bytes < threshold_size * len(arrays):
 *             return _concatenate_single_kernel(
 *                 arrays, axis, shape, dtype, same_shape_and_contiguous)             # <<<<<<<<<<<<<<
 * 
 *     ret = ndarray(shape, dtype=dtype)
 */
      __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core__concatenate_single_kernel(__pyx_v_arrays, __pyx_v_axis, __pyx_v_shape, __pyx_v_dtype, __pyx_v_same_shape_and_contiguous, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2541, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
      __pyx_t_3 = 0;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":2540
 *             total_bytes += a.size * a.dtype.itemsize
 * 
 *         if all_same_type and total_bytes < threshold_size * len(arrays):             # <<<<<<<<<<<<<<
 *             return _concatenate_single_kernel(
 *                 arrays, axis, shape, dtype, same_shape_and_contiguous)
 */
    }

    /* "cupy/core/core.pyx":2526
 *     cdef Py_ssize_t threshold_size = 2 * 1024 * 1024
 * 
 *     if len(arrays) > 8:             # <<<<<<<<<<<<<<
 *         all_same_type = True
 *         same_shape_and_contiguous = True
 */
  }

  /* "cupy/core/core.pyx":2544
 *                 arrays, axis, shape, dtype, same_shape_and_contiguous)
 * 
 *     ret = ndarray(shape, dtype=dtype)             # <<<<<<<<<<<<<<
 *     i = 0
 *     slice_list = [slice(None)] * len(shape)
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_shape);
  __Pyx_GIVEREF(__pyx_v_shape);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_shape);
  __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 2544, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2545
 * 
 *     ret = ndarray(shape, dtype=dtype)
 *     i = 0             # <<<<<<<<<<<<<<
 *     slice_list = [slice(None)] * len(shape)
 *     for a in arrays:
 */
  __pyx_v_i = 0;

  /* "cupy/core/core.pyx":2546
 *     ret = ndarray(shape, dtype=dtype)
 *     i = 0
 *     slice_list = [slice(None)] * len(shape)             # <<<<<<<<<<<<<<
 *     for a in arrays:
 *         aw = a._shape[axis]
 */
  if (unlikely(__pyx_v_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 2546, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2546, __pyx_L1_error)
  __pyx_t_7 = PyList_New(1 * ((__pyx_t_1<0) ? 0:__pyx_t_1)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  { Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < __pyx_t_1; __pyx_temp++) {
      __Pyx_INCREF(__pyx_slice__103);
      __Pyx_GIVEREF(__pyx_slice__103);
      PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__103);
    }
  }
  __pyx_v_slice_list = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2547
 *     i = 0
 *     slice_list = [slice(None)] * len(shape)
 *     for a in arrays:             # <<<<<<<<<<<<<<
 *         aw = a._shape[axis]
 *         slice_list[axis] = slice(i, i + aw)
 */
  if (unlikely(__pyx_v_arrays == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 2547, __pyx_L1_error)
  }
  __pyx_t_7 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_7); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_7)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_5 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 2547, __pyx_L1_error)
    #else
    __pyx_t_5 = PySequence_ITEM(__pyx_t_7, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2547, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2547, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2548
 *     slice_list = [slice(None)] * len(shape)
 *     for a in arrays:
 *         aw = a._shape[axis]             # <<<<<<<<<<<<<<
 *         slice_list[axis] = slice(i, i + aw)
 *         elementwise_copy(a, _simple_getitem(ret, slice_list))
 */
    __pyx_t_5 = PyInt_FromSsize_t((__pyx_v_a->_shape[__pyx_v_axis])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2548, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XDECREF_SET(__pyx_v_aw, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2549
 *     for a in arrays:
 *         aw = a._shape[axis]
 *         slice_list[axis] = slice(i, i + aw)             # <<<<<<<<<<<<<<
 *         elementwise_copy(a, _simple_getitem(ret, slice_list))
 *         i += aw
 */
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_v_aw); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PySlice_New(__pyx_t_5, __pyx_t_4, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__Pyx_SetItemInt(__pyx_v_slice_list, __pyx_v_axis, __pyx_t_3, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 2549, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2550
 *         aw = a._shape[axis]
 *         slice_list[axis] = slice(i, i + aw)
 *         elementwise_copy(a, _simple_getitem(ret, slice_list))             # <<<<<<<<<<<<<<
 *         i += aw
 *     return ret
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2550, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core__simple_getitem(__pyx_v_ret, __pyx_v_slice_list)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2550, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_a), __pyx_t_5};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2550, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_a), __pyx_t_5};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2550, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2550, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, ((PyObject *)__pyx_v_a));
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2550, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2551
 *         slice_list[axis] = slice(i, i + aw)
 *         elementwise_copy(a, _simple_getitem(ret, slice_list))
 *         i += aw             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2551, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_v_aw); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2551, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_11 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_11 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2551, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_i = __pyx_t_11;

    /* "cupy/core/core.pyx":2547
 *     i = 0
 *     slice_list = [slice(None)] * len(shape)
 *     for a in arrays:             # <<<<<<<<<<<<<<
 *         aw = a._shape[axis]
 *         slice_list[axis] = slice(i, i + aw)
 */
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2552
 *         elementwise_copy(a, _simple_getitem(ret, slice_list))
 *         i += aw
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2518
 * 
 * 
 * cpdef ndarray _concatenate(list arrays, Py_ssize_t axis, tuple shape, dtype):             # <<<<<<<<<<<<<<
 *     cdef ndarray a, ret
 *     cdef Py_ssize_t i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.core.core._concatenate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_total_bytes);
  __Pyx_XDECREF(__pyx_v_slice_list);
  __Pyx_XDECREF(__pyx_v_aw);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_71_concatenate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_70_concatenate[] = "_concatenate(list arrays, Py_ssize_t axis, tuple shape, dtype) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_71_concatenate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_arrays = 0;
  Py_ssize_t __pyx_v_axis;
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_concatenate (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arrays,&__pyx_n_s_axis,&__pyx_n_s_shape,&__pyx_n_s_dtype,0};
    PyObject* values[4] = {0,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  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_arrays)) != 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_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_concatenate", 1, 4, 4, 1); __PYX_ERR(0, 2518, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_concatenate", 1, 4, 4, 2); __PYX_ERR(0, 2518, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_concatenate", 1, 4, 4, 3); __PYX_ERR(0, 2518, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_concatenate") < 0)) __PYX_ERR(0, 2518, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_arrays = ((PyObject*)values[0]);
    __pyx_v_axis = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_axis == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2518, __pyx_L3_error)
    __pyx_v_shape = ((PyObject*)values[2]);
    __pyx_v_dtype = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_concatenate", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2518, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._concatenate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arrays), (&PyList_Type), 1, "arrays", 1))) __PYX_ERR(0, 2518, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(0, 2518, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_70_concatenate(__pyx_self, __pyx_v_arrays, __pyx_v_axis, __pyx_v_shape, __pyx_v_dtype);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_70_concatenate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arrays, Py_ssize_t __pyx_v_axis, PyObject *__pyx_v_shape, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_concatenate", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__concatenate(__pyx_v_arrays, __pyx_v_axis, __pyx_v_shape, __pyx_v_dtype, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._concatenate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2555
 * 
 * 
 * cpdef ndarray _concatenate_single_kernel(             # <<<<<<<<<<<<<<
 *         list arrays, Py_ssize_t axis, tuple shape, dtype,
 *         bint same_shape_and_contiguous):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_73_concatenate_single_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__concatenate_single_kernel(PyObject *__pyx_v_arrays, Py_ssize_t __pyx_v_axis, PyObject *__pyx_v_shape, PyObject *__pyx_v_dtype, int __pyx_v_same_shape_and_contiguous, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = 0;
  Py_ssize_t __pyx_v_base;
  Py_ssize_t __pyx_v_cum;
  Py_ssize_t __pyx_v_ndim;
  int __pyx_v_i;
  int __pyx_v_j;
  __Pyx_memviewslice __pyx_v_ptrs = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_cum_sizes = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_x_strides = { 0, 0, { 0 }, { 0 }, { 0 } };
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } };
  size_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  std::vector<Py_ssize_t>  __pyx_t_14;
  Py_ssize_t __pyx_t_15;
  __Pyx_memviewslice __pyx_t_16 = { 0, 0, { 0 }, { 0 }, { 0 } };
  Py_ssize_t __pyx_t_17;
  Py_ssize_t __pyx_t_18;
  Py_ssize_t __pyx_t_19;
  int __pyx_t_20;
  Py_ssize_t __pyx_t_21;
  PyObject *__pyx_t_22 = NULL;
  __Pyx_RefNannySetupContext("_concatenate_single_kernel", 0);

  /* "cupy/core/core.pyx":2565
 *     cdef Py_ssize_t[:, :] x_strides
 * 
 *     ptrs = numpy.ndarray(len(arrays), numpy.int64)             # <<<<<<<<<<<<<<
 *     for i, a in enumerate(arrays):
 *         ptrs[i] = a.data.ptr
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(__pyx_v_arrays == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 2565, __pyx_L1_error)
  }
  __pyx_t_4 = PyList_GET_SIZE(__pyx_v_arrays); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2565, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_2, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2565, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_2, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2565, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2565, __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_2);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_6);
    __pyx_t_2 = 0;
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_ds_Py_ssize_t(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ptrs = __pyx_t_9;
  __pyx_t_9.memview = NULL;
  __pyx_t_9.data = NULL;

  /* "cupy/core/core.pyx":2566
 * 
 *     ptrs = numpy.ndarray(len(arrays), numpy.int64)
 *     for i, a in enumerate(arrays):             # <<<<<<<<<<<<<<
 *         ptrs[i] = a.data.ptr
 *     x = array(ptrs)
 */
  __pyx_t_7 = 0;
  __pyx_t_1 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2566, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2566, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2566, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_v_i = __pyx_t_7;
    __pyx_t_7 = (__pyx_t_7 + 1);

    /* "cupy/core/core.pyx":2567
 *     ptrs = numpy.ndarray(len(arrays), numpy.int64)
 *     for i, a in enumerate(arrays):
 *         ptrs[i] = a.data.ptr             # <<<<<<<<<<<<<<
 *     x = array(ptrs)
 * 
 */
    __pyx_t_10 = __pyx_v_a->data->ptr;
    __pyx_t_11 = __pyx_v_i;
    __pyx_t_12 = -1;
    if (__pyx_t_11 < 0) {
      __pyx_t_11 += __pyx_v_ptrs.shape[0];
      if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
    } else if (unlikely(__pyx_t_11 >= __pyx_v_ptrs.shape[0])) __pyx_t_12 = 0;
    if (unlikely(__pyx_t_12 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_12);
      __PYX_ERR(0, 2567, __pyx_L1_error)
    }
    *((Py_ssize_t *) ( /* dim=0 */ (__pyx_v_ptrs.data + __pyx_t_11 * __pyx_v_ptrs.strides[0]) )) = __pyx_t_10;

    /* "cupy/core/core.pyx":2566
 * 
 *     ptrs = numpy.ndarray(len(arrays), numpy.int64)
 *     for i, a in enumerate(arrays):             # <<<<<<<<<<<<<<
 *         ptrs[i] = a.data.ptr
 *     x = array(ptrs)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2568
 *     for i, a in enumerate(arrays):
 *         ptrs[i] = a.data.ptr
 *     x = array(ptrs)             # <<<<<<<<<<<<<<
 * 
 *     ret = ndarray(shape, dtype=dtype)
 */
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_ptrs, 1, (PyObject *(*)(char *)) __pyx_memview_get_Py_ssize_t, (int (*)(char *, PyObject *)) __pyx_memview_set_Py_ssize_t, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_t_1, 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2570
 *     x = array(ptrs)
 * 
 *     ret = ndarray(shape, dtype=dtype)             # <<<<<<<<<<<<<<
 *     if same_shape_and_contiguous:
 *         base = internal.prod_ssize_t(shape[axis:]) // len(arrays)
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2570, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_shape);
  __Pyx_GIVEREF(__pyx_v_shape);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_shape);
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2570, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 2570, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2570, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2571
 * 
 *     ret = ndarray(shape, dtype=dtype)
 *     if same_shape_and_contiguous:             # <<<<<<<<<<<<<<
 *         base = internal.prod_ssize_t(shape[axis:]) // len(arrays)
 *         _concatenate_kernel_same_size(x, base, ret)
 */
  __pyx_t_13 = (__pyx_v_same_shape_and_contiguous != 0);
  if (__pyx_t_13) {

    /* "cupy/core/core.pyx":2572
 *     ret = ndarray(shape, dtype=dtype)
 *     if same_shape_and_contiguous:
 *         base = internal.prod_ssize_t(shape[axis:]) // len(arrays)             # <<<<<<<<<<<<<<
 *         _concatenate_kernel_same_size(x, base, ret)
 *         return ret
 */
    if (unlikely(__pyx_v_shape == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 2572, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyTuple_GetSlice(__pyx_v_shape, __pyx_v_axis, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_14 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2572, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_4 = __pyx_f_4cupy_4core_8internal_prod_ssize_t(__pyx_t_14, 0, NULL);
    if (unlikely(__pyx_v_arrays == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(0, 2572, __pyx_L1_error)
    }
    __pyx_t_15 = PyList_GET_SIZE(__pyx_v_arrays); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2572, __pyx_L1_error)
    if (unlikely(__pyx_t_15 == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(0, 2572, __pyx_L1_error)
    }
    else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_t_15 == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_4))) {
      PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
      __PYX_ERR(0, 2572, __pyx_L1_error)
    }
    __pyx_v_base = __Pyx_div_Py_ssize_t(__pyx_t_4, __pyx_t_15);

    /* "cupy/core/core.pyx":2573
 *     if same_shape_and_contiguous:
 *         base = internal.prod_ssize_t(shape[axis:]) // len(arrays)
 *         _concatenate_kernel_same_size(x, base, ret)             # <<<<<<<<<<<<<<
 *         return ret
 * 
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2573, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__concatenate_kernel_same_size);
    __pyx_t_3 = __pyx_v_4cupy_4core_4core__concatenate_kernel_same_size; __pyx_t_6 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, ((PyObject *)__pyx_v_x), __pyx_t_1, ((PyObject *)__pyx_v_ret)};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2573, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, ((PyObject *)__pyx_v_x), __pyx_t_1, ((PyObject *)__pyx_v_ret)};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2573, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2573, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_x));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_x));
      PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_7, ((PyObject *)__pyx_v_x));
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_7, __pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_ret));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
      PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_7, ((PyObject *)__pyx_v_ret));
      __pyx_t_1 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2573, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":2574
 *         base = internal.prod_ssize_t(shape[axis:]) // len(arrays)
 *         _concatenate_kernel_same_size(x, base, ret)
 *         return ret             # <<<<<<<<<<<<<<
 * 
 *     ndim = len(shape)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_ret));
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2571
 * 
 *     ret = ndarray(shape, dtype=dtype)
 *     if same_shape_and_contiguous:             # <<<<<<<<<<<<<<
 *         base = internal.prod_ssize_t(shape[axis:]) // len(arrays)
 *         _concatenate_kernel_same_size(x, base, ret)
 */
  }

  /* "cupy/core/core.pyx":2576
 *         return ret
 * 
 *     ndim = len(shape)             # <<<<<<<<<<<<<<
 *     x_strides = numpy.ndarray((len(arrays), ndim), numpy.int64)
 *     cum_sizes = numpy.ndarray(len(arrays), numpy.int64)
 */
  if (unlikely(__pyx_v_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 2576, __pyx_L1_error)
  }
  __pyx_t_15 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2576, __pyx_L1_error)
  __pyx_v_ndim = __pyx_t_15;

  /* "cupy/core/core.pyx":2577
 * 
 *     ndim = len(shape)
 *     x_strides = numpy.ndarray((len(arrays), ndim), numpy.int64)             # <<<<<<<<<<<<<<
 *     cum_sizes = numpy.ndarray(len(arrays), numpy.int64)
 *     cum = 0
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(__pyx_v_arrays == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 2577, __pyx_L1_error)
  }
  __pyx_t_15 = PyList_GET_SIZE(__pyx_v_arrays); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2577, __pyx_L1_error)
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __pyx_t_3 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_t_6, __pyx_t_3};
    __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2577, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_t_6, __pyx_t_3};
    __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2577, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2577, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_3);
    __pyx_t_6 = 0;
    __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2577, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_16 = __Pyx_PyObject_to_MemoryviewSlice_dsds_Py_ssize_t(__pyx_t_8, PyBUF_WRITABLE); if (unlikely(!__pyx_t_16.memview)) __PYX_ERR(0, 2577, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_x_strides = __pyx_t_16;
  __pyx_t_16.memview = NULL;
  __pyx_t_16.data = NULL;

  /* "cupy/core/core.pyx":2578
 *     ndim = len(shape)
 *     x_strides = numpy.ndarray((len(arrays), ndim), numpy.int64)
 *     cum_sizes = numpy.ndarray(len(arrays), numpy.int64)             # <<<<<<<<<<<<<<
 *     cum = 0
 *     for i, a in enumerate(arrays):
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(__pyx_v_arrays == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 2578, __pyx_L1_error)
  }
  __pyx_t_15 = PyList_GET_SIZE(__pyx_v_arrays); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2578, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_int64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_2, __pyx_t_6};
    __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2578, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __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_3, __pyx_t_2, __pyx_t_6};
    __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2578, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_1 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2578, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_7, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_7, __pyx_t_6);
    __pyx_t_2 = 0;
    __pyx_t_6 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2578, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_ds_Py_ssize_t(__pyx_t_8, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 2578, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_cum_sizes = __pyx_t_9;
  __pyx_t_9.memview = NULL;
  __pyx_t_9.data = NULL;

  /* "cupy/core/core.pyx":2579
 *     x_strides = numpy.ndarray((len(arrays), ndim), numpy.int64)
 *     cum_sizes = numpy.ndarray(len(arrays), numpy.int64)
 *     cum = 0             # <<<<<<<<<<<<<<
 *     for i, a in enumerate(arrays):
 *         for j in range(ndim):
 */
  __pyx_v_cum = 0;

  /* "cupy/core/core.pyx":2580
 *     cum_sizes = numpy.ndarray(len(arrays), numpy.int64)
 *     cum = 0
 *     for i, a in enumerate(arrays):             # <<<<<<<<<<<<<<
 *         for j in range(ndim):
 *             x_strides[i, j] = <int>a._strides[j]
 */
  __pyx_t_7 = 0;
  __pyx_t_8 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_8); __pyx_t_15 = 0;
  for (;;) {
    if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_8)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_5 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_15); __Pyx_INCREF(__pyx_t_5); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 2580, __pyx_L1_error)
    #else
    __pyx_t_5 = PySequence_ITEM(__pyx_t_8, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2580, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;
    __pyx_v_i = __pyx_t_7;
    __pyx_t_7 = (__pyx_t_7 + 1);

    /* "cupy/core/core.pyx":2581
 *     cum = 0
 *     for i, a in enumerate(arrays):
 *         for j in range(ndim):             # <<<<<<<<<<<<<<
 *             x_strides[i, j] = <int>a._strides[j]
 *         cum_sizes[i] = cum
 */
    __pyx_t_4 = __pyx_v_ndim;
    __pyx_t_17 = __pyx_t_4;
    for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_17; __pyx_t_12+=1) {
      __pyx_v_j = __pyx_t_12;

      /* "cupy/core/core.pyx":2582
 *     for i, a in enumerate(arrays):
 *         for j in range(ndim):
 *             x_strides[i, j] = <int>a._strides[j]             # <<<<<<<<<<<<<<
 *         cum_sizes[i] = cum
 *         cum += <int>a._shape[axis]
 */
      __pyx_t_18 = __pyx_v_i;
      __pyx_t_19 = __pyx_v_j;
      __pyx_t_20 = -1;
      if (__pyx_t_18 < 0) {
        __pyx_t_18 += __pyx_v_x_strides.shape[0];
        if (unlikely(__pyx_t_18 < 0)) __pyx_t_20 = 0;
      } else if (unlikely(__pyx_t_18 >= __pyx_v_x_strides.shape[0])) __pyx_t_20 = 0;
      if (__pyx_t_19 < 0) {
        __pyx_t_19 += __pyx_v_x_strides.shape[1];
        if (unlikely(__pyx_t_19 < 0)) __pyx_t_20 = 1;
      } else if (unlikely(__pyx_t_19 >= __pyx_v_x_strides.shape[1])) __pyx_t_20 = 1;
      if (unlikely(__pyx_t_20 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_20);
        __PYX_ERR(0, 2582, __pyx_L1_error)
      }
      *((Py_ssize_t *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x_strides.data + __pyx_t_18 * __pyx_v_x_strides.strides[0]) ) + __pyx_t_19 * __pyx_v_x_strides.strides[1]) )) = ((int)(__pyx_v_a->_strides[__pyx_v_j]));
    }

    /* "cupy/core/core.pyx":2583
 *         for j in range(ndim):
 *             x_strides[i, j] = <int>a._strides[j]
 *         cum_sizes[i] = cum             # <<<<<<<<<<<<<<
 *         cum += <int>a._shape[axis]
 * 
 */
    __pyx_t_21 = __pyx_v_i;
    __pyx_t_12 = -1;
    if (__pyx_t_21 < 0) {
      __pyx_t_21 += __pyx_v_cum_sizes.shape[0];
      if (unlikely(__pyx_t_21 < 0)) __pyx_t_12 = 0;
    } else if (unlikely(__pyx_t_21 >= __pyx_v_cum_sizes.shape[0])) __pyx_t_12 = 0;
    if (unlikely(__pyx_t_12 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_12);
      __PYX_ERR(0, 2583, __pyx_L1_error)
    }
    *((Py_ssize_t *) ( /* dim=0 */ (__pyx_v_cum_sizes.data + __pyx_t_21 * __pyx_v_cum_sizes.strides[0]) )) = __pyx_v_cum;

    /* "cupy/core/core.pyx":2584
 *             x_strides[i, j] = <int>a._strides[j]
 *         cum_sizes[i] = cum
 *         cum += <int>a._shape[axis]             # <<<<<<<<<<<<<<
 * 
 *     _concatenate_kernel(
 */
    __pyx_v_cum = (__pyx_v_cum + ((int)(__pyx_v_a->_shape[__pyx_v_axis])));

    /* "cupy/core/core.pyx":2580
 *     cum_sizes = numpy.ndarray(len(arrays), numpy.int64)
 *     cum = 0
 *     for i, a in enumerate(arrays):             # <<<<<<<<<<<<<<
 *         for j in range(ndim):
 *             x_strides[i, j] = <int>a._strides[j]
 */
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2587
 * 
 *     _concatenate_kernel(
 *         x, axis, array(cum_sizes), array(x_strides), ret)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
  __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_axis); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_cum_sizes, 1, (PyObject *(*)(char *)) __pyx_memview_get_Py_ssize_t, (int (*)(char *, PyObject *)) __pyx_memview_set_Py_ssize_t, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_t_1, 0, NULL)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x_strides, 2, (PyObject *(*)(char *)) __pyx_memview_get_Py_ssize_t, (int (*)(char *, PyObject *)) __pyx_memview_set_Py_ssize_t, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_t_1, 0, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__concatenate_kernel);
  __pyx_t_1 = __pyx_v_4cupy_4core_4core__concatenate_kernel; __pyx_t_3 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[6] = {__pyx_t_3, ((PyObject *)__pyx_v_x), __pyx_t_5, __pyx_t_6, __pyx_t_2, ((PyObject *)__pyx_v_ret)};
    __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2586, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[6] = {__pyx_t_3, ((PyObject *)__pyx_v_x), __pyx_t_5, __pyx_t_6, __pyx_t_2, ((PyObject *)__pyx_v_ret)};
    __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2586, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  #endif
  {
    __pyx_t_22 = PyTuple_New(5+__pyx_t_7); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 2586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_x));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_x));
    PyTuple_SET_ITEM(__pyx_t_22, 0+__pyx_t_7, ((PyObject *)__pyx_v_x));
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_22, 1+__pyx_t_7, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_22, 2+__pyx_t_7, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_22, 3+__pyx_t_7, __pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_ret));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
    PyTuple_SET_ITEM(__pyx_t_22, 4+__pyx_t_7, ((PyObject *)__pyx_v_ret));
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_2 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_22, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2588
 *     _concatenate_kernel(
 *         x, axis, array(cum_sizes), array(x_strides), ret)
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2555
 * 
 * 
 * cpdef ndarray _concatenate_single_kernel(             # <<<<<<<<<<<<<<
 *         list arrays, Py_ssize_t axis, tuple shape, dtype,
 *         bint same_shape_and_contiguous):
 */

  /* 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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_16, 1);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_AddTraceback("cupy.core.core._concatenate_single_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __PYX_XDEC_MEMVIEW(&__pyx_v_ptrs, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_cum_sizes, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_x_strides, 1);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_73_concatenate_single_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_72_concatenate_single_kernel[] = "_concatenate_single_kernel(list arrays, Py_ssize_t axis, tuple shape, dtype, bool same_shape_and_contiguous) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_73_concatenate_single_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_arrays = 0;
  Py_ssize_t __pyx_v_axis;
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_v_dtype = 0;
  int __pyx_v_same_shape_and_contiguous;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_concatenate_single_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arrays,&__pyx_n_s_axis,&__pyx_n_s_shape,&__pyx_n_s_dtype,&__pyx_n_s_same_shape_and_contiguous,0};
    PyObject* values[5] = {0,0,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  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_arrays)) != 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_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_concatenate_single_kernel", 1, 5, 5, 1); __PYX_ERR(0, 2555, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_concatenate_single_kernel", 1, 5, 5, 2); __PYX_ERR(0, 2555, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_concatenate_single_kernel", 1, 5, 5, 3); __PYX_ERR(0, 2555, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_same_shape_and_contiguous)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_concatenate_single_kernel", 1, 5, 5, 4); __PYX_ERR(0, 2555, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_concatenate_single_kernel") < 0)) __PYX_ERR(0, 2555, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_arrays = ((PyObject*)values[0]);
    __pyx_v_axis = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_axis == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2556, __pyx_L3_error)
    __pyx_v_shape = ((PyObject*)values[2]);
    __pyx_v_dtype = values[3];
    __pyx_v_same_shape_and_contiguous = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_same_shape_and_contiguous == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2557, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_concatenate_single_kernel", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2555, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._concatenate_single_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arrays), (&PyList_Type), 1, "arrays", 1))) __PYX_ERR(0, 2556, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(0, 2556, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_72_concatenate_single_kernel(__pyx_self, __pyx_v_arrays, __pyx_v_axis, __pyx_v_shape, __pyx_v_dtype, __pyx_v_same_shape_and_contiguous);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_72_concatenate_single_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arrays, Py_ssize_t __pyx_v_axis, PyObject *__pyx_v_shape, PyObject *__pyx_v_dtype, int __pyx_v_same_shape_and_contiguous) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_concatenate_single_kernel", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__concatenate_single_kernel(__pyx_v_arrays, __pyx_v_axis, __pyx_v_shape, __pyx_v_dtype, __pyx_v_same_shape_and_contiguous, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2555, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._concatenate_single_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2643
 * 
 * 
 * cpdef Py_ssize_t size(ndarray a, axis=None) except *:             # <<<<<<<<<<<<<<
 *     """Returns the number of elements along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_75size(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static Py_ssize_t __pyx_f_4cupy_4core_4core_size(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_size *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  int __pyx_v_index;
  int __pyx_v_ndim;
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("size", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
    }
  }

  /* "cupy/core/core.pyx":2656
 *     """
 *     cdef int index, ndim
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         return a.size
 *     else:
 */
  __pyx_t_1 = (__pyx_v_axis == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2657
 *     cdef int index, ndim
 *     if axis is None:
 *         return a.size             # <<<<<<<<<<<<<<
 *     else:
 *         index = axis
 */
    __pyx_r = __pyx_v_a->size;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2656
 *     """
 *     cdef int index, ndim
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         return a.size
 *     else:
 */
  }

  /* "cupy/core/core.pyx":2659
 *         return a.size
 *     else:
 *         index = axis             # <<<<<<<<<<<<<<
 *         ndim = a._shape.size()
 *         if index < 0:
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_axis); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2659, __pyx_L1_error)
    __pyx_v_index = __pyx_t_3;

    /* "cupy/core/core.pyx":2660
 *     else:
 *         index = axis
 *         ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *         if index < 0:
 *             index += ndim
 */
    __pyx_v_ndim = __pyx_v_a->_shape.size();

    /* "cupy/core/core.pyx":2661
 *         index = axis
 *         ndim = a._shape.size()
 *         if index < 0:             # <<<<<<<<<<<<<<
 *             index += ndim
 *         if not 0 <= index < ndim:
 */
    __pyx_t_2 = ((__pyx_v_index < 0) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2662
 *         ndim = a._shape.size()
 *         if index < 0:
 *             index += ndim             # <<<<<<<<<<<<<<
 *         if not 0 <= index < ndim:
 *             raise IndexError('index out of range')
 */
      __pyx_v_index = (__pyx_v_index + __pyx_v_ndim);

      /* "cupy/core/core.pyx":2661
 *         index = axis
 *         ndim = a._shape.size()
 *         if index < 0:             # <<<<<<<<<<<<<<
 *             index += ndim
 *         if not 0 <= index < ndim:
 */
    }

    /* "cupy/core/core.pyx":2663
 *         if index < 0:
 *             index += ndim
 *         if not 0 <= index < ndim:             # <<<<<<<<<<<<<<
 *             raise IndexError('index out of range')
 *         return a._shape[index]
 */
    __pyx_t_2 = (0 <= __pyx_v_index);
    if (__pyx_t_2) {
      __pyx_t_2 = (__pyx_v_index < __pyx_v_ndim);
    }
    __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "cupy/core/core.pyx":2664
 *             index += ndim
 *         if not 0 <= index < ndim:
 *             raise IndexError('index out of range')             # <<<<<<<<<<<<<<
 *         return a._shape[index]
 * 
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__104, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2664, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 2664, __pyx_L1_error)

      /* "cupy/core/core.pyx":2663
 *         if index < 0:
 *             index += ndim
 *         if not 0 <= index < ndim:             # <<<<<<<<<<<<<<
 *             raise IndexError('index out of range')
 *         return a._shape[index]
 */
    }

    /* "cupy/core/core.pyx":2665
 *         if not 0 <= index < ndim:
 *             raise IndexError('index out of range')
 *         return a._shape[index]             # <<<<<<<<<<<<<<
 * 
 * # -----------------------------------------------------------------------------
 */
    __pyx_r = (__pyx_v_a->_shape[__pyx_v_index]);
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":2643
 * 
 * 
 * cpdef Py_ssize_t size(ndarray a, axis=None) except *:             # <<<<<<<<<<<<<<
 *     """Returns the number of elements along a given axis.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_75size(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_74size[] = "size(ndarray a, axis=None) -> Py_ssize_t\nReturns the number of elements along a given axis.\n\n    Args:\n        a (ndarray): Input data.\n        axis (int or None): Axis along which the elements are counted.\n            When it is ``None``, it returns the total number of elements.\n\n    Returns:\n        int: Number of elements along the given axis.\n\n    ";
static PyObject *__pyx_pw_4cupy_4core_4core_75size(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_axis,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "size") < 0)) __PYX_ERR(0, 2643, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_axis = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("size", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2643, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2643, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_74size(__pyx_self, __pyx_v_a, __pyx_v_axis);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_74size(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  struct __pyx_opt_args_4cupy_4core_4core_size __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("size", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_size(__pyx_v_a, 0, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2643, __pyx_L1_error)
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2643, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core.size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2671
 * # -----------------------------------------------------------------------------
 * 
 * cpdef _create_bit_op(name, op, no_bool, doc=''):             # <<<<<<<<<<<<<<
 *     types = () if no_bool else ('??->?',)
 *     return create_ufunc(
 */

static PyObject *__pyx_pw_4cupy_4core_4core_77_create_bit_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__create_bit_op(PyObject *__pyx_v_name, PyObject *__pyx_v_op, PyObject *__pyx_v_no_bool, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__create_bit_op *__pyx_optional_args) {
  PyObject *__pyx_v_doc = ((PyObject *)__pyx_kp_s__6);
  PyObject *__pyx_v_types = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_create_bit_op", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_doc = __pyx_optional_args->doc;
    }
  }

  /* "cupy/core/core.pyx":2672
 * 
 * cpdef _create_bit_op(name, op, no_bool, doc=''):
 *     types = () if no_bool else ('??->?',)             # <<<<<<<<<<<<<<
 *     return create_ufunc(
 *         'cupy_' + name,
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_no_bool); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2672, __pyx_L1_error)
  if (__pyx_t_2) {
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_t_1 = __pyx_empty_tuple;
  } else {
    __Pyx_INCREF(__pyx_tuple__106);
    __pyx_t_1 = __pyx_tuple__106;
  }
  __pyx_v_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2673
 * cpdef _create_bit_op(name, op, no_bool, doc=''):
 *     types = () if no_bool else ('??->?',)
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         types + ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2673, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":2674
 *     types = () if no_bool else ('??->?',)
 *     return create_ufunc(
 *         'cupy_' + name,             # <<<<<<<<<<<<<<
 *         types + ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 *                  'LL->L', 'qq->q', 'QQ->Q'),
 */
  __pyx_t_3 = PyNumber_Add(__pyx_n_s_cupy_2, __pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2674, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/core.pyx":2675
 *     return create_ufunc(
 *         'cupy_' + name,
 *         types + ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',             # <<<<<<<<<<<<<<
 *                  'LL->L', 'qq->q', 'QQ->Q'),
 *         'out0 = in0 %s in1' % op,
 */
  __pyx_t_4 = PyNumber_Add(__pyx_v_types, __pyx_tuple__107); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2675, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":2677
 *         types + ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 *                  'LL->L', 'qq->q', 'QQ->Q'),
 *         'out0 = in0 %s in1' % op,             # <<<<<<<<<<<<<<
 *         doc=doc)
 * 
 */
  __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_out0_in0_s_in1, __pyx_v_op); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2677, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":2673
 * cpdef _create_bit_op(name, op, no_bool, doc=''):
 *     types = () if no_bool else ('??->?',)
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         types + ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 */
  __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2673, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2678
 *                  'LL->L', 'qq->q', 'QQ->Q'),
 *         'out0 = in0 %s in1' % op,
 *         doc=doc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_doc, __pyx_v_doc) < 0) __PYX_ERR(0, 2678, __pyx_L1_error)

  /* "cupy/core/core.pyx":2673
 * cpdef _create_bit_op(name, op, no_bool, doc=''):
 *     types = () if no_bool else ('??->?',)
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         types + ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2673, __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;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2671
 * # -----------------------------------------------------------------------------
 * 
 * cpdef _create_bit_op(name, op, no_bool, doc=''):             # <<<<<<<<<<<<<<
 *     types = () if no_bool else ('??->?',)
 *     return create_ufunc(
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core._create_bit_op", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_77_create_bit_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_76_create_bit_op[] = "_create_bit_op(name, op, no_bool, doc='')";
static PyObject *__pyx_pw_4cupy_4core_4core_77_create_bit_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_v_no_bool = 0;
  PyObject *__pyx_v_doc = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_bit_op (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_op,&__pyx_n_s_no_bool,&__pyx_n_s_doc,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((PyObject *)__pyx_kp_s__6);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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_name)) != 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_op)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_bit_op", 0, 3, 4, 1); __PYX_ERR(0, 2671, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_no_bool)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_bit_op", 0, 3, 4, 2); __PYX_ERR(0, 2671, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_doc);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_create_bit_op") < 0)) __PYX_ERR(0, 2671, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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_name = values[0];
    __pyx_v_op = values[1];
    __pyx_v_no_bool = values[2];
    __pyx_v_doc = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_create_bit_op", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2671, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._create_bit_op", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_76_create_bit_op(__pyx_self, __pyx_v_name, __pyx_v_op, __pyx_v_no_bool, __pyx_v_doc);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_76_create_bit_op(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_op, PyObject *__pyx_v_no_bool, PyObject *__pyx_v_doc) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__create_bit_op __pyx_t_2;
  __Pyx_RefNannySetupContext("_create_bit_op", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.doc = __pyx_v_doc;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_v_name, __pyx_v_op, __pyx_v_no_bool, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2671, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._create_bit_op", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2753
 * # -----------------------------------------------------------------------------
 * 
 * cpdef _prepare_slice_list(slices, Py_ssize_t ndim):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, n_newaxes, axis
 *     cdef list slice_list
 */

static PyObject *__pyx_pw_4cupy_4core_4core_79_prepare_slice_list(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__prepare_slice_list(PyObject *__pyx_v_slices, Py_ssize_t __pyx_v_ndim, CYTHON_UNUSED int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_n_newaxes;
  PyObject *__pyx_v_slice_list = 0;
  PyObject *__pyx_v_kind = 0;
  PyObject *__pyx_v_s = NULL;
  int __pyx_v_advanced;
  int __pyx_v_mask_exists;
  int __pyx_v_is_list;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("_prepare_slice_list", 0);

  /* "cupy/core/core.pyx":2758
 *     cdef str kind
 * 
 *     if isinstance(slices, tuple):             # <<<<<<<<<<<<<<
 *         slice_list = list(slices)
 *     elif isinstance(slices, list):
 */
  __pyx_t_1 = PyTuple_Check(__pyx_v_slices); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2759
 * 
 *     if isinstance(slices, tuple):
 *         slice_list = list(slices)             # <<<<<<<<<<<<<<
 *     elif isinstance(slices, list):
 *         slice_list = list(slices)  # copy list
 */
    __pyx_t_3 = PySequence_List(__pyx_v_slices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2759, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_slice_list = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2758
 *     cdef str kind
 * 
 *     if isinstance(slices, tuple):             # <<<<<<<<<<<<<<
 *         slice_list = list(slices)
 *     elif isinstance(slices, list):
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2760
 *     if isinstance(slices, tuple):
 *         slice_list = list(slices)
 *     elif isinstance(slices, list):             # <<<<<<<<<<<<<<
 *         slice_list = list(slices)  # copy list
 *         for s in slice_list:
 */
  __pyx_t_2 = PyList_Check(__pyx_v_slices); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2761
 *         slice_list = list(slices)
 *     elif isinstance(slices, list):
 *         slice_list = list(slices)  # copy list             # <<<<<<<<<<<<<<
 *         for s in slice_list:
 *             if not isinstance(s, int):
 */
    __pyx_t_3 = PySequence_List(__pyx_v_slices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2761, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_slice_list = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2762
 *     elif isinstance(slices, list):
 *         slice_list = list(slices)  # copy list
 *         for s in slice_list:             # <<<<<<<<<<<<<<
 *             if not isinstance(s, int):
 *                 break
 */
    __pyx_t_3 = __pyx_v_slice_list; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 2762, __pyx_L1_error)
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2762, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "cupy/core/core.pyx":2763
 *         slice_list = list(slices)  # copy list
 *         for s in slice_list:
 *             if not isinstance(s, int):             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
      __pyx_t_1 = PyInt_Check(__pyx_v_s); 
      __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":2764
 *         for s in slice_list:
 *             if not isinstance(s, int):
 *                 break             # <<<<<<<<<<<<<<
 *         else:
 *             slice_list = [slice_list]
 */
        goto __pyx_L5_break;

        /* "cupy/core/core.pyx":2763
 *         slice_list = list(slices)  # copy list
 *         for s in slice_list:
 *             if not isinstance(s, int):             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
      }

      /* "cupy/core/core.pyx":2762
 *     elif isinstance(slices, list):
 *         slice_list = list(slices)  # copy list
 *         for s in slice_list:             # <<<<<<<<<<<<<<
 *             if not isinstance(s, int):
 *                 break
 */
    }
    /*else*/ {

      /* "cupy/core/core.pyx":2766
 *                 break
 *         else:
 *             slice_list = [slice_list]             # <<<<<<<<<<<<<<
 *     else:
 *         slice_list = [slices]
 */
      __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2766, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_slice_list);
      __Pyx_GIVEREF(__pyx_v_slice_list);
      PyList_SET_ITEM(__pyx_t_5, 0, __pyx_v_slice_list);
      __Pyx_DECREF_SET(__pyx_v_slice_list, ((PyObject*)__pyx_t_5));
      __pyx_t_5 = 0;
    }

    /* "cupy/core/core.pyx":2762
 *     elif isinstance(slices, list):
 *         slice_list = list(slices)  # copy list
 *         for s in slice_list:             # <<<<<<<<<<<<<<
 *             if not isinstance(s, int):
 *                 break
 */
    __pyx_L5_break:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2760
 *     if isinstance(slices, tuple):
 *         slice_list = list(slices)
 *     elif isinstance(slices, list):             # <<<<<<<<<<<<<<
 *         slice_list = list(slices)  # copy list
 *         for s in slice_list:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2768
 *             slice_list = [slice_list]
 *     else:
 *         slice_list = [slices]             # <<<<<<<<<<<<<<
 * 
 *     slice_list, n_newaxes = internal.complete_slice_list(slice_list, ndim)
 */
  /*else*/ {
    __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2768, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_slices);
    __Pyx_GIVEREF(__pyx_v_slices);
    PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_slices);
    __pyx_v_slice_list = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":2770
 *         slice_list = [slices]
 * 
 *     slice_list, n_newaxes = internal.complete_slice_list(slice_list, ndim)             # <<<<<<<<<<<<<<
 * 
 *     # Check if advanced is true,
 */
  __pyx_t_3 = __pyx_f_4cupy_4core_8internal_complete_slice_list(__pyx_v_slice_list, __pyx_v_ndim, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2770, __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(0, 2770, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_6);
    #else
    __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2770, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2770, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 2770, __pyx_L1_error)
  }
  if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(0, 2770, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2770, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_slice_list, ((PyObject*)__pyx_t_5));
  __pyx_t_5 = 0;
  __pyx_v_n_newaxes = __pyx_t_4;

  /* "cupy/core/core.pyx":2774
 *     # Check if advanced is true,
 *     # and convert list/NumPy arrays to cupy.ndarray
 *     advanced = False             # <<<<<<<<<<<<<<
 *     mask_exists = False
 *     for i, s in enumerate(slice_list):
 */
  __pyx_v_advanced = 0;

  /* "cupy/core/core.pyx":2775
 *     # and convert list/NumPy arrays to cupy.ndarray
 *     advanced = False
 *     mask_exists = False             # <<<<<<<<<<<<<<
 *     for i, s in enumerate(slice_list):
 *         is_list = isinstance(s, list)
 */
  __pyx_v_mask_exists = 0;

  /* "cupy/core/core.pyx":2776
 *     advanced = False
 *     mask_exists = False
 *     for i, s in enumerate(slice_list):             # <<<<<<<<<<<<<<
 *         is_list = isinstance(s, list)
 *         if is_list or isinstance(s, numpy.ndarray):
 */
  __pyx_t_4 = 0;
  __pyx_t_3 = __pyx_v_slice_list; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
  for (;;) {
    if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2776, __pyx_L1_error)
    #else
    __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_v_i = __pyx_t_4;
    __pyx_t_4 = (__pyx_t_4 + 1);

    /* "cupy/core/core.pyx":2777
 *     mask_exists = False
 *     for i, s in enumerate(slice_list):
 *         is_list = isinstance(s, list)             # <<<<<<<<<<<<<<
 *         if is_list or isinstance(s, numpy.ndarray):
 *             # handle the case when s is an empty list
 */
    __pyx_t_2 = PyList_Check(__pyx_v_s); 
    __pyx_v_is_list = __pyx_t_2;

    /* "cupy/core/core.pyx":2778
 *     for i, s in enumerate(slice_list):
 *         is_list = isinstance(s, list)
 *         if is_list or isinstance(s, numpy.ndarray):             # <<<<<<<<<<<<<<
 *             # handle the case when s is an empty list
 *             s = array(s)
 */
    __pyx_t_1 = (__pyx_v_is_list != 0);
    if (!__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2778, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2778, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_1 = PyObject_IsInstance(__pyx_v_s, __pyx_t_5); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2778, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_8 = (__pyx_t_1 != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L11_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2780
 *         if is_list or isinstance(s, numpy.ndarray):
 *             # handle the case when s is an empty list
 *             s = array(s)             # <<<<<<<<<<<<<<
 *             if is_list and s.size == 0:
 *                 s = s.astype(numpy.int32)
 */
      __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_v_s, 0, NULL)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2780, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "cupy/core/core.pyx":2781
 *             # handle the case when s is an empty list
 *             s = array(s)
 *             if is_list and s.size == 0:             # <<<<<<<<<<<<<<
 *                 s = s.astype(numpy.int32)
 *             slice_list[i] = s
 */
      __pyx_t_8 = (__pyx_v_is_list != 0);
      if (__pyx_t_8) {
      } else {
        __pyx_t_2 = __pyx_t_8;
        goto __pyx_L14_bool_binop_done;
      }
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2781, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_t_5, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2781, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 2781, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_2 = __pyx_t_8;
      __pyx_L14_bool_binop_done:;
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":2782
 *             s = array(s)
 *             if is_list and s.size == 0:
 *                 s = s.astype(numpy.int32)             # <<<<<<<<<<<<<<
 *             slice_list[i] = s
 *         elif not isinstance(s, ndarray):
 */
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_astype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2782, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2782, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int32); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2782, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2782, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_5);
        __pyx_t_5 = 0;

        /* "cupy/core/core.pyx":2781
 *             # handle the case when s is an empty list
 *             s = array(s)
 *             if is_list and s.size == 0:             # <<<<<<<<<<<<<<
 *                 s = s.astype(numpy.int32)
 *             slice_list[i] = s
 */
      }

      /* "cupy/core/core.pyx":2783
 *             if is_list and s.size == 0:
 *                 s = s.astype(numpy.int32)
 *             slice_list[i] = s             # <<<<<<<<<<<<<<
 *         elif not isinstance(s, ndarray):
 *             continue
 */
      if (unlikely(__pyx_v_slice_list == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 2783, __pyx_L1_error)
      }
      if (unlikely(__Pyx_SetItemInt(__pyx_v_slice_list, __pyx_v_i, __pyx_v_s, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 2783, __pyx_L1_error)

      /* "cupy/core/core.pyx":2778
 *     for i, s in enumerate(slice_list):
 *         is_list = isinstance(s, list)
 *         if is_list or isinstance(s, numpy.ndarray):             # <<<<<<<<<<<<<<
 *             # handle the case when s is an empty list
 *             s = array(s)
 */
      goto __pyx_L10;
    }

    /* "cupy/core/core.pyx":2784
 *                 s = s.astype(numpy.int32)
 *             slice_list[i] = s
 *         elif not isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *             continue
 *         kind = s.dtype.kind
 */
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_8 = ((!(__pyx_t_2 != 0)) != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":2785
 *             slice_list[i] = s
 *         elif not isinstance(s, ndarray):
 *             continue             # <<<<<<<<<<<<<<
 *         kind = s.dtype.kind
 *         if kind == 'i' or kind == 'u':
 */
      goto __pyx_L8_continue;

      /* "cupy/core/core.pyx":2784
 *                 s = s.astype(numpy.int32)
 *             slice_list[i] = s
 *         elif not isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *             continue
 *         kind = s.dtype.kind
 */
    }
    __pyx_L10:;

    /* "cupy/core/core.pyx":2786
 *         elif not isinstance(s, ndarray):
 *             continue
 *         kind = s.dtype.kind             # <<<<<<<<<<<<<<
 *         if kind == 'i' or kind == 'u':
 *             advanced = True
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_kind); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (!(likely(PyString_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_9)->tp_name), 0))) __PYX_ERR(0, 2786, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_kind, ((PyObject*)__pyx_t_9));
    __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":2787
 *             continue
 *         kind = s.dtype.kind
 *         if kind == 'i' or kind == 'u':             # <<<<<<<<<<<<<<
 *             advanced = True
 *         elif kind == 'b':
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_kind, __pyx_n_s_i, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2787, __pyx_L1_error)
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (!__pyx_t_1) {
    } else {
      __pyx_t_8 = __pyx_t_1;
      goto __pyx_L17_bool_binop_done;
    }
    __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_kind, __pyx_n_s_u, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2787, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_1 != 0);
    __pyx_t_8 = __pyx_t_2;
    __pyx_L17_bool_binop_done:;
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":2788
 *         kind = s.dtype.kind
 *         if kind == 'i' or kind == 'u':
 *             advanced = True             # <<<<<<<<<<<<<<
 *         elif kind == 'b':
 *             mask_exists = not is_list
 */
      __pyx_v_advanced = 1;

      /* "cupy/core/core.pyx":2787
 *             continue
 *         kind = s.dtype.kind
 *         if kind == 'i' or kind == 'u':             # <<<<<<<<<<<<<<
 *             advanced = True
 *         elif kind == 'b':
 */
      goto __pyx_L16;
    }

    /* "cupy/core/core.pyx":2789
 *         if kind == 'i' or kind == 'u':
 *             advanced = True
 *         elif kind == 'b':             # <<<<<<<<<<<<<<
 *             mask_exists = not is_list
 *         else:
 */
    __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_kind, __pyx_n_s_b, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 2789, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_8 != 0);
    if (likely(__pyx_t_2)) {

      /* "cupy/core/core.pyx":2790
 *             advanced = True
 *         elif kind == 'b':
 *             mask_exists = not is_list             # <<<<<<<<<<<<<<
 *         else:
 *             raise IndexError(
 */
      __pyx_v_mask_exists = (!(__pyx_v_is_list != 0));

      /* "cupy/core/core.pyx":2789
 *         if kind == 'i' or kind == 'u':
 *             advanced = True
 *         elif kind == 'b':             # <<<<<<<<<<<<<<
 *             mask_exists = not is_list
 *         else:
 */
      goto __pyx_L16;
    }

    /* "cupy/core/core.pyx":2792
 *             mask_exists = not is_list
 *         else:
 *             raise IndexError(             # <<<<<<<<<<<<<<
 *                 'arrays used as indices must be of integer or boolean '
 *                 'type. (actual: {})'.format(s.dtype.type))
 */
    /*else*/ {

      /* "cupy/core/core.pyx":2794
 *             raise IndexError(
 *                 'arrays used as indices must be of integer or boolean '
 *                 'type. (actual: {})'.format(s.dtype.type))             # <<<<<<<<<<<<<<
 * 
 *     if not mask_exists and len(slice_list) > ndim + n_newaxes:
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_arrays_used_as_indices_must_be_o, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2794, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2794, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_type); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2794, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __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);
        }
      }
      if (!__pyx_t_6) {
        __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2794, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_10};
          __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2794, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_10};
          __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2794, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2794, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL;
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_10);
          __pyx_t_10 = 0;
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2794, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/core/core.pyx":2792
 *             mask_exists = not is_list
 *         else:
 *             raise IndexError(             # <<<<<<<<<<<<<<
 *                 'arrays used as indices must be of integer or boolean '
 *                 'type. (actual: {})'.format(s.dtype.type))
 */
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2792, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 2792, __pyx_L1_error)
    }
    __pyx_L16:;

    /* "cupy/core/core.pyx":2776
 *     advanced = False
 *     mask_exists = False
 *     for i, s in enumerate(slice_list):             # <<<<<<<<<<<<<<
 *         is_list = isinstance(s, list)
 *         if is_list or isinstance(s, numpy.ndarray):
 */
    __pyx_L8_continue:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2796
 *                 'type. (actual: {})'.format(s.dtype.type))
 * 
 *     if not mask_exists and len(slice_list) > ndim + n_newaxes:             # <<<<<<<<<<<<<<
 *         raise IndexError('too many indices for array')
 *     return slice_list, advanced, mask_exists
 */
  __pyx_t_8 = ((!(__pyx_v_mask_exists != 0)) != 0);
  if (__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L20_bool_binop_done;
  }
  if (unlikely(__pyx_v_slice_list == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 2796, __pyx_L1_error)
  }
  __pyx_t_4 = PyList_GET_SIZE(__pyx_v_slice_list); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2796, __pyx_L1_error)
  __pyx_t_8 = ((__pyx_t_4 > (__pyx_v_ndim + __pyx_v_n_newaxes)) != 0);
  __pyx_t_2 = __pyx_t_8;
  __pyx_L20_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "cupy/core/core.pyx":2797
 * 
 *     if not mask_exists and len(slice_list) > ndim + n_newaxes:
 *         raise IndexError('too many indices for array')             # <<<<<<<<<<<<<<
 *     return slice_list, advanced, mask_exists
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__108, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2797, __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(0, 2797, __pyx_L1_error)

    /* "cupy/core/core.pyx":2796
 *                 'type. (actual: {})'.format(s.dtype.type))
 * 
 *     if not mask_exists and len(slice_list) > ndim + n_newaxes:             # <<<<<<<<<<<<<<
 *         raise IndexError('too many indices for array')
 *     return slice_list, advanced, mask_exists
 */
  }

  /* "cupy/core/core.pyx":2798
 *     if not mask_exists and len(slice_list) > ndim + n_newaxes:
 *         raise IndexError('too many indices for array')
 *     return slice_list, advanced, mask_exists             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_advanced); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_mask_exists); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_v_slice_list);
  __Pyx_GIVEREF(__pyx_v_slice_list);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_slice_list);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_5);
  __pyx_t_3 = 0;
  __pyx_t_5 = 0;
  __pyx_r = __pyx_t_9;
  __pyx_t_9 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2753
 * # -----------------------------------------------------------------------------
 * 
 * cpdef _prepare_slice_list(slices, Py_ssize_t ndim):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, n_newaxes, axis
 *     cdef list slice_list
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core._prepare_slice_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_slice_list);
  __Pyx_XDECREF(__pyx_v_kind);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_79_prepare_slice_list(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_78_prepare_slice_list[] = "_prepare_slice_list(slices, Py_ssize_t ndim)";
static PyObject *__pyx_pw_4cupy_4core_4core_79_prepare_slice_list(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_slices = 0;
  Py_ssize_t __pyx_v_ndim;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_prepare_slice_list (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_slices,&__pyx_n_s_ndim,0};
    PyObject* values[2] = {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  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_slices)) != 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_ndim)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_prepare_slice_list", 1, 2, 2, 1); __PYX_ERR(0, 2753, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_prepare_slice_list") < 0)) __PYX_ERR(0, 2753, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_slices = values[0];
    __pyx_v_ndim = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_ndim == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2753, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_prepare_slice_list", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2753, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._prepare_slice_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_78_prepare_slice_list(__pyx_self, __pyx_v_slices, __pyx_v_ndim);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_78_prepare_slice_list(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_slices, Py_ssize_t __pyx_v_ndim) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_prepare_slice_list", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__prepare_slice_list(__pyx_v_slices, __pyx_v_ndim, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2753, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._prepare_slice_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2801
 * 
 * 
 * cdef Py_ssize_t _get_mask_index(list slice_list) except *:             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, n_not_slice_none, mask_i
 *     cdef slice none_slice = slice(None)
 */

static Py_ssize_t __pyx_f_4cupy_4core_4core__get_mask_index(PyObject *__pyx_v_slice_list) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_n_not_slice_none;
  Py_ssize_t __pyx_v_mask_i;
  PyObject *__pyx_v_none_slice = 0;
  PyObject *__pyx_v_s = NULL;
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("_get_mask_index", 0);

  /* "cupy/core/core.pyx":2803
 * cdef Py_ssize_t _get_mask_index(list slice_list) except *:
 *     cdef Py_ssize_t i, n_not_slice_none, mask_i
 *     cdef slice none_slice = slice(None)             # <<<<<<<<<<<<<<
 *     n_not_slice_none = 0
 *     mask_i = -1
 */
  __pyx_t_1 = __pyx_slice__109;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_none_slice = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2804
 *     cdef Py_ssize_t i, n_not_slice_none, mask_i
 *     cdef slice none_slice = slice(None)
 *     n_not_slice_none = 0             # <<<<<<<<<<<<<<
 *     mask_i = -1
 *     for i, s in enumerate(slice_list):
 */
  __pyx_v_n_not_slice_none = 0;

  /* "cupy/core/core.pyx":2805
 *     cdef slice none_slice = slice(None)
 *     n_not_slice_none = 0
 *     mask_i = -1             # <<<<<<<<<<<<<<
 *     for i, s in enumerate(slice_list):
 *         if not isinstance(s, slice) or s != none_slice:
 */
  __pyx_v_mask_i = -1L;

  /* "cupy/core/core.pyx":2806
 *     n_not_slice_none = 0
 *     mask_i = -1
 *     for i, s in enumerate(slice_list):             # <<<<<<<<<<<<<<
 *         if not isinstance(s, slice) or s != none_slice:
 *             n_not_slice_none += 1
 */
  __pyx_t_2 = 0;
  __pyx_t_1 = __pyx_v_slice_list; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 2806, __pyx_L1_error)
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2806, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_v_i = __pyx_t_2;
    __pyx_t_2 = (__pyx_t_2 + 1);

    /* "cupy/core/core.pyx":2807
 *     mask_i = -1
 *     for i, s in enumerate(slice_list):
 *         if not isinstance(s, slice) or s != none_slice:             # <<<<<<<<<<<<<<
 *             n_not_slice_none += 1
 *             if isinstance(s, ndarray) and s.dtype == numpy.bool_:
 */
    __pyx_t_6 = PySlice_Check(__pyx_v_s); 
    __pyx_t_7 = ((!(__pyx_t_6 != 0)) != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_5 = __pyx_t_7;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_s, __pyx_v_none_slice, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2807, __pyx_L1_error)
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2807, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __pyx_t_7;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_5) {

      /* "cupy/core/core.pyx":2808
 *     for i, s in enumerate(slice_list):
 *         if not isinstance(s, slice) or s != none_slice:
 *             n_not_slice_none += 1             # <<<<<<<<<<<<<<
 *             if isinstance(s, ndarray) and s.dtype == numpy.bool_:
 *                 mask_i = i
 */
      __pyx_v_n_not_slice_none = (__pyx_v_n_not_slice_none + 1);

      /* "cupy/core/core.pyx":2809
 *         if not isinstance(s, slice) or s != none_slice:
 *             n_not_slice_none += 1
 *             if isinstance(s, ndarray) and s.dtype == numpy.bool_:             # <<<<<<<<<<<<<<
 *                 mask_i = i
 *     if n_not_slice_none != 1 or mask_i == -1:
 */
      __pyx_t_7 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
      __pyx_t_6 = (__pyx_t_7 != 0);
      if (__pyx_t_6) {
      } else {
        __pyx_t_5 = __pyx_t_6;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2809, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2809, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_bool); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2809, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_4, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2809, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 2809, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_5 = __pyx_t_6;
      __pyx_L9_bool_binop_done:;
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":2810
 *             n_not_slice_none += 1
 *             if isinstance(s, ndarray) and s.dtype == numpy.bool_:
 *                 mask_i = i             # <<<<<<<<<<<<<<
 *     if n_not_slice_none != 1 or mask_i == -1:
 *         raise ValueError('currently, CuPy only supports slices that '
 */
        __pyx_v_mask_i = __pyx_v_i;

        /* "cupy/core/core.pyx":2809
 *         if not isinstance(s, slice) or s != none_slice:
 *             n_not_slice_none += 1
 *             if isinstance(s, ndarray) and s.dtype == numpy.bool_:             # <<<<<<<<<<<<<<
 *                 mask_i = i
 *     if n_not_slice_none != 1 or mask_i == -1:
 */
      }

      /* "cupy/core/core.pyx":2807
 *     mask_i = -1
 *     for i, s in enumerate(slice_list):
 *         if not isinstance(s, slice) or s != none_slice:             # <<<<<<<<<<<<<<
 *             n_not_slice_none += 1
 *             if isinstance(s, ndarray) and s.dtype == numpy.bool_:
 */
    }

    /* "cupy/core/core.pyx":2806
 *     n_not_slice_none = 0
 *     mask_i = -1
 *     for i, s in enumerate(slice_list):             # <<<<<<<<<<<<<<
 *         if not isinstance(s, slice) or s != none_slice:
 *             n_not_slice_none += 1
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2811
 *             if isinstance(s, ndarray) and s.dtype == numpy.bool_:
 *                 mask_i = i
 *     if n_not_slice_none != 1 or mask_i == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError('currently, CuPy only supports slices that '
 *                          'consist of one boolean array.')
 */
  __pyx_t_6 = ((__pyx_v_n_not_slice_none != 1) != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_5 = __pyx_t_6;
    goto __pyx_L12_bool_binop_done;
  }
  __pyx_t_6 = ((__pyx_v_mask_i == -1L) != 0);
  __pyx_t_5 = __pyx_t_6;
  __pyx_L12_bool_binop_done:;
  if (unlikely(__pyx_t_5)) {

    /* "cupy/core/core.pyx":2812
 *                 mask_i = i
 *     if n_not_slice_none != 1 or mask_i == -1:
 *         raise ValueError('currently, CuPy only supports slices that '             # <<<<<<<<<<<<<<
 *                          'consist of one boolean array.')
 *     return mask_i
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__110, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2812, __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(0, 2812, __pyx_L1_error)

    /* "cupy/core/core.pyx":2811
 *             if isinstance(s, ndarray) and s.dtype == numpy.bool_:
 *                 mask_i = i
 *     if n_not_slice_none != 1 or mask_i == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError('currently, CuPy only supports slices that '
 *                          'consist of one boolean array.')
 */
  }

  /* "cupy/core/core.pyx":2814
 *         raise ValueError('currently, CuPy only supports slices that '
 *                          'consist of one boolean array.')
 *     return mask_i             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_mask_i;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2801
 * 
 * 
 * cdef Py_ssize_t _get_mask_index(list slice_list) except *:             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, n_not_slice_none, mask_i
 *     cdef slice none_slice = slice(None)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core._get_mask_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_none_slice);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2817
 * 
 * 
 * cdef tuple _prepare_advanced_indexing(ndarray a, list slice_list):             # <<<<<<<<<<<<<<
 *     cdef slice none_slice = slice(None)
 * 
 */

static PyObject *__pyx_f_4cupy_4core_4core__prepare_advanced_indexing(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slice_list) {
  PyObject *__pyx_v_none_slice = 0;
  PyObject *__pyx_v_basic_slices = 0;
  PyObject *__pyx_v_adv_slices = 0;
  PyObject *__pyx_v_adv_mask = 0;
  int __pyx_v_use_basic_indexing;
  CYTHON_UNUSED Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_kind = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_scalar_array = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("_prepare_advanced_indexing", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_a);

  /* "cupy/core/core.pyx":2818
 * 
 * cdef tuple _prepare_advanced_indexing(ndarray a, list slice_list):
 *     cdef slice none_slice = slice(None)             # <<<<<<<<<<<<<<
 * 
 *     # split slices that can be handled by basic-indexing
 */
  __pyx_t_1 = __pyx_slice__111;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_none_slice = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2821
 * 
 *     # split slices that can be handled by basic-indexing
 *     cdef list basic_slices = []             # <<<<<<<<<<<<<<
 *     cdef list adv_slices = []
 *     cdef list adv_mask = []
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2821, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_basic_slices = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2822
 *     # split slices that can be handled by basic-indexing
 *     cdef list basic_slices = []
 *     cdef list adv_slices = []             # <<<<<<<<<<<<<<
 *     cdef list adv_mask = []
 *     cdef bint use_basic_indexing = False
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2822, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_adv_slices = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2823
 *     cdef list basic_slices = []
 *     cdef list adv_slices = []
 *     cdef list adv_mask = []             # <<<<<<<<<<<<<<
 *     cdef bint use_basic_indexing = False
 *     for i, s in enumerate(slice_list):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2823, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_adv_mask = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2824
 *     cdef list adv_slices = []
 *     cdef list adv_mask = []
 *     cdef bint use_basic_indexing = False             # <<<<<<<<<<<<<<
 *     for i, s in enumerate(slice_list):
 *         if s is None:
 */
  __pyx_v_use_basic_indexing = 0;

  /* "cupy/core/core.pyx":2825
 *     cdef list adv_mask = []
 *     cdef bint use_basic_indexing = False
 *     for i, s in enumerate(slice_list):             # <<<<<<<<<<<<<<
 *         if s is None:
 *             basic_slices.append(None)
 */
  __pyx_t_2 = 0;
  __pyx_t_1 = __pyx_v_slice_list; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 2825, __pyx_L1_error)
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2825, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_v_i = __pyx_t_2;
    __pyx_t_2 = (__pyx_t_2 + 1);

    /* "cupy/core/core.pyx":2826
 *     cdef bint use_basic_indexing = False
 *     for i, s in enumerate(slice_list):
 *         if s is None:             # <<<<<<<<<<<<<<
 *             basic_slices.append(None)
 *             adv_slices.append(none_slice)
 */
    __pyx_t_5 = (__pyx_v_s == Py_None);
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":2827
 *     for i, s in enumerate(slice_list):
 *         if s is None:
 *             basic_slices.append(None)             # <<<<<<<<<<<<<<
 *             adv_slices.append(none_slice)
 *             adv_mask.append(False)
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_basic_slices, Py_None); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 2827, __pyx_L1_error)

      /* "cupy/core/core.pyx":2828
 *         if s is None:
 *             basic_slices.append(None)
 *             adv_slices.append(none_slice)             # <<<<<<<<<<<<<<
 *             adv_mask.append(False)
 *             use_basic_indexing = True
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_adv_slices, __pyx_v_none_slice); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 2828, __pyx_L1_error)

      /* "cupy/core/core.pyx":2829
 *             basic_slices.append(None)
 *             adv_slices.append(none_slice)
 *             adv_mask.append(False)             # <<<<<<<<<<<<<<
 *             use_basic_indexing = True
 *         elif isinstance(s, slice):
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_adv_mask, Py_False); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 2829, __pyx_L1_error)

      /* "cupy/core/core.pyx":2830
 *             adv_slices.append(none_slice)
 *             adv_mask.append(False)
 *             use_basic_indexing = True             # <<<<<<<<<<<<<<
 *         elif isinstance(s, slice):
 *             basic_slices.append(s)
 */
      __pyx_v_use_basic_indexing = 1;

      /* "cupy/core/core.pyx":2826
 *     cdef bint use_basic_indexing = False
 *     for i, s in enumerate(slice_list):
 *         if s is None:             # <<<<<<<<<<<<<<
 *             basic_slices.append(None)
 *             adv_slices.append(none_slice)
 */
      goto __pyx_L5;
    }

    /* "cupy/core/core.pyx":2831
 *             adv_mask.append(False)
 *             use_basic_indexing = True
 *         elif isinstance(s, slice):             # <<<<<<<<<<<<<<
 *             basic_slices.append(s)
 *             adv_slices.append(none_slice)
 */
    __pyx_t_6 = PySlice_Check(__pyx_v_s); 
    __pyx_t_5 = (__pyx_t_6 != 0);
    if (__pyx_t_5) {

      /* "cupy/core/core.pyx":2832
 *             use_basic_indexing = True
 *         elif isinstance(s, slice):
 *             basic_slices.append(s)             # <<<<<<<<<<<<<<
 *             adv_slices.append(none_slice)
 *             adv_mask.append(False)
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_basic_slices, __pyx_v_s); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 2832, __pyx_L1_error)

      /* "cupy/core/core.pyx":2833
 *         elif isinstance(s, slice):
 *             basic_slices.append(s)
 *             adv_slices.append(none_slice)             # <<<<<<<<<<<<<<
 *             adv_mask.append(False)
 *             use_basic_indexing |= s != none_slice
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_adv_slices, __pyx_v_none_slice); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 2833, __pyx_L1_error)

      /* "cupy/core/core.pyx":2834
 *             basic_slices.append(s)
 *             adv_slices.append(none_slice)
 *             adv_mask.append(False)             # <<<<<<<<<<<<<<
 *             use_basic_indexing |= s != none_slice
 *         elif isinstance(s, ndarray):
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_adv_mask, Py_False); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 2834, __pyx_L1_error)

      /* "cupy/core/core.pyx":2835
 *             adv_slices.append(none_slice)
 *             adv_mask.append(False)
 *             use_basic_indexing |= s != none_slice             # <<<<<<<<<<<<<<
 *         elif isinstance(s, ndarray):
 *             kind = s.dtype.kind
 */
      __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_use_basic_indexing); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2835, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = PyObject_RichCompare(__pyx_v_s, __pyx_v_none_slice, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2835, __pyx_L1_error)
      __pyx_t_9 = PyNumber_InPlaceOr(__pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2835, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2835, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_use_basic_indexing = __pyx_t_5;

      /* "cupy/core/core.pyx":2831
 *             adv_mask.append(False)
 *             use_basic_indexing = True
 *         elif isinstance(s, slice):             # <<<<<<<<<<<<<<
 *             basic_slices.append(s)
 *             adv_slices.append(none_slice)
 */
      goto __pyx_L5;
    }

    /* "cupy/core/core.pyx":2836
 *             adv_mask.append(False)
 *             use_basic_indexing |= s != none_slice
 *         elif isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *             kind = s.dtype.kind
 *             assert kind == 'i' or kind == 'u'
 */
    __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":2837
 *             use_basic_indexing |= s != none_slice
 *         elif isinstance(s, ndarray):
 *             kind = s.dtype.kind             # <<<<<<<<<<<<<<
 *             assert kind == 'i' or kind == 'u'
 *             basic_slices.append(none_slice)
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_kind); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF_SET(__pyx_v_kind, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":2838
 *         elif isinstance(s, ndarray):
 *             kind = s.dtype.kind
 *             assert kind == 'i' or kind == 'u'             # <<<<<<<<<<<<<<
 *             basic_slices.append(none_slice)
 *             adv_slices.append(s)
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_kind, __pyx_n_s_i, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2838, __pyx_L1_error)
        if (!__pyx_t_5) {
        } else {
          __pyx_t_6 = __pyx_t_5;
          goto __pyx_L6_bool_binop_done;
        }
        __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_kind, __pyx_n_s_u, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2838, __pyx_L1_error)
        __pyx_t_6 = __pyx_t_5;
        __pyx_L6_bool_binop_done:;
        if (unlikely(!__pyx_t_6)) {
          PyErr_SetNone(PyExc_AssertionError);
          __PYX_ERR(0, 2838, __pyx_L1_error)
        }
      }
      #endif

      /* "cupy/core/core.pyx":2839
 *             kind = s.dtype.kind
 *             assert kind == 'i' or kind == 'u'
 *             basic_slices.append(none_slice)             # <<<<<<<<<<<<<<
 *             adv_slices.append(s)
 *             adv_mask.append(True)
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_basic_slices, __pyx_v_none_slice); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 2839, __pyx_L1_error)

      /* "cupy/core/core.pyx":2840
 *             assert kind == 'i' or kind == 'u'
 *             basic_slices.append(none_slice)
 *             adv_slices.append(s)             # <<<<<<<<<<<<<<
 *             adv_mask.append(True)
 *         elif isinstance(s, int):
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_adv_slices, __pyx_v_s); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 2840, __pyx_L1_error)

      /* "cupy/core/core.pyx":2841
 *             basic_slices.append(none_slice)
 *             adv_slices.append(s)
 *             adv_mask.append(True)             # <<<<<<<<<<<<<<
 *         elif isinstance(s, int):
 *             basic_slices.append(none_slice)
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_adv_mask, Py_True); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 2841, __pyx_L1_error)

      /* "cupy/core/core.pyx":2836
 *             adv_mask.append(False)
 *             use_basic_indexing |= s != none_slice
 *         elif isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *             kind = s.dtype.kind
 *             assert kind == 'i' or kind == 'u'
 */
      goto __pyx_L5;
    }

    /* "cupy/core/core.pyx":2842
 *             adv_slices.append(s)
 *             adv_mask.append(True)
 *         elif isinstance(s, int):             # <<<<<<<<<<<<<<
 *             basic_slices.append(none_slice)
 *             scalar_array = ndarray((), dtype=numpy.int64)
 */
    __pyx_t_6 = PyInt_Check(__pyx_v_s); 
    __pyx_t_5 = (__pyx_t_6 != 0);
    if (likely(__pyx_t_5)) {

      /* "cupy/core/core.pyx":2843
 *             adv_mask.append(True)
 *         elif isinstance(s, int):
 *             basic_slices.append(none_slice)             # <<<<<<<<<<<<<<
 *             scalar_array = ndarray((), dtype=numpy.int64)
 *             scalar_array.fill(s)
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_basic_slices, __pyx_v_none_slice); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 2843, __pyx_L1_error)

      /* "cupy/core/core.pyx":2844
 *         elif isinstance(s, int):
 *             basic_slices.append(none_slice)
 *             scalar_array = ndarray((), dtype=numpy.int64)             # <<<<<<<<<<<<<<
 *             scalar_array.fill(s)
 *             adv_slices.append(scalar_array)
 */
      __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2844, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2844, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_int64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2844, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 2844, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_tuple__112, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2844, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF_SET(__pyx_v_scalar_array, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2845
 *             basic_slices.append(none_slice)
 *             scalar_array = ndarray((), dtype=numpy.int64)
 *             scalar_array.fill(s)             # <<<<<<<<<<<<<<
 *             adv_slices.append(scalar_array)
 *             adv_mask.append(True)
 */
      __pyx_t_4 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_scalar_array->__pyx_vtab)->fill(__pyx_v_scalar_array, __pyx_v_s, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2845, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2846
 *             scalar_array = ndarray((), dtype=numpy.int64)
 *             scalar_array.fill(s)
 *             adv_slices.append(scalar_array)             # <<<<<<<<<<<<<<
 *             adv_mask.append(True)
 *         else:
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_adv_slices, ((PyObject *)__pyx_v_scalar_array)); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 2846, __pyx_L1_error)

      /* "cupy/core/core.pyx":2847
 *             scalar_array.fill(s)
 *             adv_slices.append(scalar_array)
 *             adv_mask.append(True)             # <<<<<<<<<<<<<<
 *         else:
 *             raise IndexError(
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_adv_mask, Py_True); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 2847, __pyx_L1_error)

      /* "cupy/core/core.pyx":2842
 *             adv_slices.append(s)
 *             adv_mask.append(True)
 *         elif isinstance(s, int):             # <<<<<<<<<<<<<<
 *             basic_slices.append(none_slice)
 *             scalar_array = ndarray((), dtype=numpy.int64)
 */
      goto __pyx_L5;
    }

    /* "cupy/core/core.pyx":2849
 *             adv_mask.append(True)
 *         else:
 *             raise IndexError(             # <<<<<<<<<<<<<<
 *                 'only integers, slices (`:`), ellipsis (`...`),'
 *                 'numpy.newaxis (`None`) and integer or '
 */
    /*else*/ {
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__113, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2849, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 2849, __pyx_L1_error)
    }
    __pyx_L5:;

    /* "cupy/core/core.pyx":2825
 *     cdef list adv_mask = []
 *     cdef bint use_basic_indexing = False
 *     for i, s in enumerate(slice_list):             # <<<<<<<<<<<<<<
 *         if s is None:
 *             basic_slices.append(None)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2855
 * 
 *     # check if this is a combination of basic and advanced indexing
 *     if use_basic_indexing:             # <<<<<<<<<<<<<<
 *         a = _simple_getitem(a, basic_slices)
 * 
 */
  __pyx_t_5 = (__pyx_v_use_basic_indexing != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":2856
 *     # check if this is a combination of basic and advanced indexing
 *     if use_basic_indexing:
 *         a = _simple_getitem(a, basic_slices)             # <<<<<<<<<<<<<<
 * 
 *     return a, adv_slices, adv_mask
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__simple_getitem(__pyx_v_a, __pyx_v_basic_slices)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2855
 * 
 *     # check if this is a combination of basic and advanced indexing
 *     if use_basic_indexing:             # <<<<<<<<<<<<<<
 *         a = _simple_getitem(a, basic_slices)
 * 
 */
  }

  /* "cupy/core/core.pyx":2858
 *         a = _simple_getitem(a, basic_slices)
 * 
 *     return a, adv_slices, adv_mask             # <<<<<<<<<<<<<<
 * 
 * cdef ndarray _simple_getitem(ndarray a, list slice_list):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2858, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_a));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_a));
  __Pyx_INCREF(__pyx_v_adv_slices);
  __Pyx_GIVEREF(__pyx_v_adv_slices);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_adv_slices);
  __Pyx_INCREF(__pyx_v_adv_mask);
  __Pyx_GIVEREF(__pyx_v_adv_mask);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_adv_mask);
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2817
 * 
 * 
 * cdef tuple _prepare_advanced_indexing(ndarray a, list slice_list):             # <<<<<<<<<<<<<<
 *     cdef slice none_slice = slice(None)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core._prepare_advanced_indexing", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_none_slice);
  __Pyx_XDECREF(__pyx_v_basic_slices);
  __Pyx_XDECREF(__pyx_v_adv_slices);
  __Pyx_XDECREF(__pyx_v_adv_mask);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_kind);
  __Pyx_XDECREF((PyObject *)__pyx_v_scalar_array);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2860
 *     return a, adv_slices, adv_mask
 * 
 * cdef ndarray _simple_getitem(ndarray a, list slice_list):             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] shape, strides
 *     cdef ndarray v
 */

static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__simple_getitem(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slice_list) {
  std::vector<Py_ssize_t>  __pyx_v_shape;
  std::vector<Py_ssize_t>  __pyx_v_strides;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_v = 0;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_j;
  Py_ssize_t __pyx_v_offset;
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_s_start;
  Py_ssize_t __pyx_v_s_stop;
  Py_ssize_t __pyx_v_s_step;
  Py_ssize_t __pyx_v_dim;
  Py_ssize_t __pyx_v_ind;
  PyObject *__pyx_v_ss = 0;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_msg = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("_simple_getitem", 0);

  /* "cupy/core/core.pyx":2868
 * 
 *     # Create new shape and stride
 *     j = 0             # <<<<<<<<<<<<<<
 *     offset = 0
 *     ndim = a._shape.size()
 */
  __pyx_v_j = 0;

  /* "cupy/core/core.pyx":2869
 *     # Create new shape and stride
 *     j = 0
 *     offset = 0             # <<<<<<<<<<<<<<
 *     ndim = a._shape.size()
 *     for i, s in enumerate(slice_list):
 */
  __pyx_v_offset = 0;

  /* "cupy/core/core.pyx":2870
 *     j = 0
 *     offset = 0
 *     ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *     for i, s in enumerate(slice_list):
 *         if s is None:
 */
  __pyx_v_ndim = __pyx_v_a->_shape.size();

  /* "cupy/core/core.pyx":2871
 *     offset = 0
 *     ndim = a._shape.size()
 *     for i, s in enumerate(slice_list):             # <<<<<<<<<<<<<<
 *         if s is None:
 *             shape.push_back(1)
 */
  __pyx_t_1 = 0;
  __pyx_t_2 = __pyx_v_slice_list; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 2871, __pyx_L1_error)
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2871, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_v_i = __pyx_t_1;
    __pyx_t_1 = (__pyx_t_1 + 1);

    /* "cupy/core/core.pyx":2872
 *     ndim = a._shape.size()
 *     for i, s in enumerate(slice_list):
 *         if s is None:             # <<<<<<<<<<<<<<
 *             shape.push_back(1)
 *             if j < ndim:
 */
    __pyx_t_5 = (__pyx_v_s == Py_None);
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":2873
 *     for i, s in enumerate(slice_list):
 *         if s is None:
 *             shape.push_back(1)             # <<<<<<<<<<<<<<
 *             if j < ndim:
 *                 strides.push_back(a._strides[j])
 */
      try {
        __pyx_v_shape.push_back(1);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 2873, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":2874
 *         if s is None:
 *             shape.push_back(1)
 *             if j < ndim:             # <<<<<<<<<<<<<<
 *                 strides.push_back(a._strides[j])
 *             elif ndim > 0:
 */
      __pyx_t_6 = ((__pyx_v_j < __pyx_v_ndim) != 0);
      if (__pyx_t_6) {

        /* "cupy/core/core.pyx":2875
 *             shape.push_back(1)
 *             if j < ndim:
 *                 strides.push_back(a._strides[j])             # <<<<<<<<<<<<<<
 *             elif ndim > 0:
 *                 strides.push_back(a._strides[ndim - 1])
 */
        try {
          __pyx_v_strides.push_back((__pyx_v_a->_strides[__pyx_v_j]));
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 2875, __pyx_L1_error)
        }

        /* "cupy/core/core.pyx":2874
 *         if s is None:
 *             shape.push_back(1)
 *             if j < ndim:             # <<<<<<<<<<<<<<
 *                 strides.push_back(a._strides[j])
 *             elif ndim > 0:
 */
        goto __pyx_L6;
      }

      /* "cupy/core/core.pyx":2876
 *             if j < ndim:
 *                 strides.push_back(a._strides[j])
 *             elif ndim > 0:             # <<<<<<<<<<<<<<
 *                 strides.push_back(a._strides[ndim - 1])
 *             else:
 */
      __pyx_t_6 = ((__pyx_v_ndim > 0) != 0);
      if (__pyx_t_6) {

        /* "cupy/core/core.pyx":2877
 *                 strides.push_back(a._strides[j])
 *             elif ndim > 0:
 *                 strides.push_back(a._strides[ndim - 1])             # <<<<<<<<<<<<<<
 *             else:
 *                 strides.push_back(a.itemsize)
 */
        try {
          __pyx_v_strides.push_back((__pyx_v_a->_strides[(__pyx_v_ndim - 1)]));
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 2877, __pyx_L1_error)
        }

        /* "cupy/core/core.pyx":2876
 *             if j < ndim:
 *                 strides.push_back(a._strides[j])
 *             elif ndim > 0:             # <<<<<<<<<<<<<<
 *                 strides.push_back(a._strides[ndim - 1])
 *             else:
 */
        goto __pyx_L6;
      }

      /* "cupy/core/core.pyx":2879
 *                 strides.push_back(a._strides[ndim - 1])
 *             else:
 *                 strides.push_back(a.itemsize)             # <<<<<<<<<<<<<<
 *         elif ndim <= j:
 *             raise IndexError("too many indices for array")
 */
      /*else*/ {
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2879, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2879, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        try {
          __pyx_v_strides.push_back(__pyx_t_7);
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 2879, __pyx_L1_error)
        }
      }
      __pyx_L6:;

      /* "cupy/core/core.pyx":2872
 *     ndim = a._shape.size()
 *     for i, s in enumerate(slice_list):
 *         if s is None:             # <<<<<<<<<<<<<<
 *             shape.push_back(1)
 *             if j < ndim:
 */
      goto __pyx_L5;
    }

    /* "cupy/core/core.pyx":2880
 *             else:
 *                 strides.push_back(a.itemsize)
 *         elif ndim <= j:             # <<<<<<<<<<<<<<
 *             raise IndexError("too many indices for array")
 *         elif isinstance(s, slice):
 */
    __pyx_t_6 = ((__pyx_v_ndim <= __pyx_v_j) != 0);
    if (unlikely(__pyx_t_6)) {

      /* "cupy/core/core.pyx":2881
 *                 strides.push_back(a.itemsize)
 *         elif ndim <= j:
 *             raise IndexError("too many indices for array")             # <<<<<<<<<<<<<<
 *         elif isinstance(s, slice):
 *             ss = internal.complete_slice(s, a._shape[j])
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__114, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 2881, __pyx_L1_error)

      /* "cupy/core/core.pyx":2880
 *             else:
 *                 strides.push_back(a.itemsize)
 *         elif ndim <= j:             # <<<<<<<<<<<<<<
 *             raise IndexError("too many indices for array")
 *         elif isinstance(s, slice):
 */
    }

    /* "cupy/core/core.pyx":2882
 *         elif ndim <= j:
 *             raise IndexError("too many indices for array")
 *         elif isinstance(s, slice):             # <<<<<<<<<<<<<<
 *             ss = internal.complete_slice(s, a._shape[j])
 *             s_start = ss.start
 */
    __pyx_t_6 = PySlice_Check(__pyx_v_s); 
    __pyx_t_5 = (__pyx_t_6 != 0);
    if (__pyx_t_5) {

      /* "cupy/core/core.pyx":2883
 *             raise IndexError("too many indices for array")
 *         elif isinstance(s, slice):
 *             ss = internal.complete_slice(s, a._shape[j])             # <<<<<<<<<<<<<<
 *             s_start = ss.start
 *             s_stop = ss.stop
 */
      if (!(likely(PySlice_Check(__pyx_v_s))||((__pyx_v_s) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "slice", Py_TYPE(__pyx_v_s)->tp_name), 0))) __PYX_ERR(0, 2883, __pyx_L1_error)
      __pyx_t_4 = __pyx_f_4cupy_4core_8internal_complete_slice(((PyObject*)__pyx_v_s), (__pyx_v_a->_shape[__pyx_v_j]), 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2883, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_ss, ((PyObject*)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2884
 *         elif isinstance(s, slice):
 *             ss = internal.complete_slice(s, a._shape[j])
 *             s_start = ss.start             # <<<<<<<<<<<<<<
 *             s_stop = ss.stop
 *             s_step = ss.step
 */
      __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(((PySliceObject*)__pyx_v_ss)->start); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2884, __pyx_L1_error)
      __pyx_v_s_start = __pyx_t_7;

      /* "cupy/core/core.pyx":2885
 *             ss = internal.complete_slice(s, a._shape[j])
 *             s_start = ss.start
 *             s_stop = ss.stop             # <<<<<<<<<<<<<<
 *             s_step = ss.step
 *             if s_step > 0:
 */
      __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(((PySliceObject*)__pyx_v_ss)->stop); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2885, __pyx_L1_error)
      __pyx_v_s_stop = __pyx_t_7;

      /* "cupy/core/core.pyx":2886
 *             s_start = ss.start
 *             s_stop = ss.stop
 *             s_step = ss.step             # <<<<<<<<<<<<<<
 *             if s_step > 0:
 *                 dim = (s_stop - s_start - 1) // s_step + 1
 */
      __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(((PySliceObject*)__pyx_v_ss)->step); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2886, __pyx_L1_error)
      __pyx_v_s_step = __pyx_t_7;

      /* "cupy/core/core.pyx":2887
 *             s_stop = ss.stop
 *             s_step = ss.step
 *             if s_step > 0:             # <<<<<<<<<<<<<<
 *                 dim = (s_stop - s_start - 1) // s_step + 1
 *             else:
 */
      __pyx_t_5 = ((__pyx_v_s_step > 0) != 0);
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":2888
 *             s_step = ss.step
 *             if s_step > 0:
 *                 dim = (s_stop - s_start - 1) // s_step + 1             # <<<<<<<<<<<<<<
 *             else:
 *                 dim = (s_stop - s_start + 1) // s_step + 1
 */
        __pyx_t_7 = ((__pyx_v_s_stop - __pyx_v_s_start) - 1);
        if (unlikely(__pyx_v_s_step == 0)) {
          PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
          __PYX_ERR(0, 2888, __pyx_L1_error)
        }
        else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_s_step == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_7))) {
          PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
          __PYX_ERR(0, 2888, __pyx_L1_error)
        }
        __pyx_v_dim = (__Pyx_div_Py_ssize_t(__pyx_t_7, __pyx_v_s_step) + 1);

        /* "cupy/core/core.pyx":2887
 *             s_stop = ss.stop
 *             s_step = ss.step
 *             if s_step > 0:             # <<<<<<<<<<<<<<
 *                 dim = (s_stop - s_start - 1) // s_step + 1
 *             else:
 */
        goto __pyx_L7;
      }

      /* "cupy/core/core.pyx":2890
 *                 dim = (s_stop - s_start - 1) // s_step + 1
 *             else:
 *                 dim = (s_stop - s_start + 1) // s_step + 1             # <<<<<<<<<<<<<<
 * 
 *             if dim == 0:
 */
      /*else*/ {
        __pyx_t_7 = ((__pyx_v_s_stop - __pyx_v_s_start) + 1);
        if (unlikely(__pyx_v_s_step == 0)) {
          PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
          __PYX_ERR(0, 2890, __pyx_L1_error)
        }
        else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_s_step == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_7))) {
          PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
          __PYX_ERR(0, 2890, __pyx_L1_error)
        }
        __pyx_v_dim = (__Pyx_div_Py_ssize_t(__pyx_t_7, __pyx_v_s_step) + 1);
      }
      __pyx_L7:;

      /* "cupy/core/core.pyx":2892
 *                 dim = (s_stop - s_start + 1) // s_step + 1
 * 
 *             if dim == 0:             # <<<<<<<<<<<<<<
 *                 strides.push_back(a._strides[j])
 *             else:
 */
      __pyx_t_5 = ((__pyx_v_dim == 0) != 0);
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":2893
 * 
 *             if dim == 0:
 *                 strides.push_back(a._strides[j])             # <<<<<<<<<<<<<<
 *             else:
 *                 strides.push_back(a._strides[j] * s_step)
 */
        try {
          __pyx_v_strides.push_back((__pyx_v_a->_strides[__pyx_v_j]));
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 2893, __pyx_L1_error)
        }

        /* "cupy/core/core.pyx":2892
 *                 dim = (s_stop - s_start + 1) // s_step + 1
 * 
 *             if dim == 0:             # <<<<<<<<<<<<<<
 *                 strides.push_back(a._strides[j])
 *             else:
 */
        goto __pyx_L8;
      }

      /* "cupy/core/core.pyx":2895
 *                 strides.push_back(a._strides[j])
 *             else:
 *                 strides.push_back(a._strides[j] * s_step)             # <<<<<<<<<<<<<<
 * 
 *             if s_start > 0:
 */
      /*else*/ {
        try {
          __pyx_v_strides.push_back(((__pyx_v_a->_strides[__pyx_v_j]) * __pyx_v_s_step));
        } catch(...) {
          __Pyx_CppExn2PyErr();
          __PYX_ERR(0, 2895, __pyx_L1_error)
        }
      }
      __pyx_L8:;

      /* "cupy/core/core.pyx":2897
 *                 strides.push_back(a._strides[j] * s_step)
 * 
 *             if s_start > 0:             # <<<<<<<<<<<<<<
 *                 offset += a._strides[j] * s_start
 *             shape.push_back(dim)
 */
      __pyx_t_5 = ((__pyx_v_s_start > 0) != 0);
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":2898
 * 
 *             if s_start > 0:
 *                 offset += a._strides[j] * s_start             # <<<<<<<<<<<<<<
 *             shape.push_back(dim)
 *             j += 1
 */
        __pyx_v_offset = (__pyx_v_offset + ((__pyx_v_a->_strides[__pyx_v_j]) * __pyx_v_s_start));

        /* "cupy/core/core.pyx":2897
 *                 strides.push_back(a._strides[j] * s_step)
 * 
 *             if s_start > 0:             # <<<<<<<<<<<<<<
 *                 offset += a._strides[j] * s_start
 *             shape.push_back(dim)
 */
      }

      /* "cupy/core/core.pyx":2899
 *             if s_start > 0:
 *                 offset += a._strides[j] * s_start
 *             shape.push_back(dim)             # <<<<<<<<<<<<<<
 *             j += 1
 *         elif numpy.isscalar(s):
 */
      try {
        __pyx_v_shape.push_back(__pyx_v_dim);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 2899, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":2900
 *                 offset += a._strides[j] * s_start
 *             shape.push_back(dim)
 *             j += 1             # <<<<<<<<<<<<<<
 *         elif numpy.isscalar(s):
 *             ind = int(s)
 */
      __pyx_v_j = (__pyx_v_j + 1);

      /* "cupy/core/core.pyx":2882
 *         elif ndim <= j:
 *             raise IndexError("too many indices for array")
 *         elif isinstance(s, slice):             # <<<<<<<<<<<<<<
 *             ss = internal.complete_slice(s, a._shape[j])
 *             s_start = ss.start
 */
      goto __pyx_L5;
    }

    /* "cupy/core/core.pyx":2901
 *             shape.push_back(dim)
 *             j += 1
 *         elif numpy.isscalar(s):             # <<<<<<<<<<<<<<
 *             ind = int(s)
 *             if ind < 0:
 */
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2901, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_isscalar); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2901, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_s); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2901, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_s};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2901, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_s};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2901, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2901, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_INCREF(__pyx_v_s);
        __Pyx_GIVEREF(__pyx_v_s);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_s);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2901, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 2901, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (likely(__pyx_t_5)) {

      /* "cupy/core/core.pyx":2902
 *             j += 1
 *         elif numpy.isscalar(s):
 *             ind = int(s)             # <<<<<<<<<<<<<<
 *             if ind < 0:
 *                 ind += a._shape[j]
 */
      __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_v_s); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2902, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2902, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_ind = __pyx_t_7;

      /* "cupy/core/core.pyx":2903
 *         elif numpy.isscalar(s):
 *             ind = int(s)
 *             if ind < 0:             # <<<<<<<<<<<<<<
 *                 ind += a._shape[j]
 *             if not (0 <= ind < a._shape[j]):
 */
      __pyx_t_5 = ((__pyx_v_ind < 0) != 0);
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":2904
 *             ind = int(s)
 *             if ind < 0:
 *                 ind += a._shape[j]             # <<<<<<<<<<<<<<
 *             if not (0 <= ind < a._shape[j]):
 *                 msg = ('Index %s is out of bounds for axis %s with '
 */
        __pyx_v_ind = (__pyx_v_ind + (__pyx_v_a->_shape[__pyx_v_j]));

        /* "cupy/core/core.pyx":2903
 *         elif numpy.isscalar(s):
 *             ind = int(s)
 *             if ind < 0:             # <<<<<<<<<<<<<<
 *                 ind += a._shape[j]
 *             if not (0 <= ind < a._shape[j]):
 */
      }

      /* "cupy/core/core.pyx":2905
 *             if ind < 0:
 *                 ind += a._shape[j]
 *             if not (0 <= ind < a._shape[j]):             # <<<<<<<<<<<<<<
 *                 msg = ('Index %s is out of bounds for axis %s with '
 *                        'size %s' % (s, j, a._shape[j]))
 */
      __pyx_t_5 = (0 <= __pyx_v_ind);
      if (__pyx_t_5) {
        __pyx_t_5 = (__pyx_v_ind < (__pyx_v_a->_shape[__pyx_v_j]));
      }
      __pyx_t_6 = ((!(__pyx_t_5 != 0)) != 0);
      if (unlikely(__pyx_t_6)) {

        /* "cupy/core/core.pyx":2907
 *             if not (0 <= ind < a._shape[j]):
 *                 msg = ('Index %s is out of bounds for axis %s with '
 *                        'size %s' % (s, j, a._shape[j]))             # <<<<<<<<<<<<<<
 *                 raise IndexError(msg)
 *             offset += ind * a._strides[j]
 */
        __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_j); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2907, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_9 = PyInt_FromSsize_t((__pyx_v_a->_shape[__pyx_v_j])); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2907, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2907, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_v_s);
        __Pyx_GIVEREF(__pyx_v_s);
        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_s);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_9);
        __pyx_t_4 = 0;
        __pyx_t_9 = 0;
        __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_Index_s_is_out_of_bounds_for_axi, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2907, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_v_msg = ((PyObject*)__pyx_t_9);
        __pyx_t_9 = 0;

        /* "cupy/core/core.pyx":2908
 *                 msg = ('Index %s is out of bounds for axis %s with '
 *                        'size %s' % (s, j, a._shape[j]))
 *                 raise IndexError(msg)             # <<<<<<<<<<<<<<
 *             offset += ind * a._strides[j]
 *             j += 1
 */
        __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_v_msg); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2908, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_Raise(__pyx_t_9, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __PYX_ERR(0, 2908, __pyx_L1_error)

        /* "cupy/core/core.pyx":2905
 *             if ind < 0:
 *                 ind += a._shape[j]
 *             if not (0 <= ind < a._shape[j]):             # <<<<<<<<<<<<<<
 *                 msg = ('Index %s is out of bounds for axis %s with '
 *                        'size %s' % (s, j, a._shape[j]))
 */
      }

      /* "cupy/core/core.pyx":2909
 *                        'size %s' % (s, j, a._shape[j]))
 *                 raise IndexError(msg)
 *             offset += ind * a._strides[j]             # <<<<<<<<<<<<<<
 *             j += 1
 *         else:
 */
      __pyx_v_offset = (__pyx_v_offset + (__pyx_v_ind * (__pyx_v_a->_strides[__pyx_v_j])));

      /* "cupy/core/core.pyx":2910
 *                 raise IndexError(msg)
 *             offset += ind * a._strides[j]
 *             j += 1             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError('Invalid index type: %s' % type(slice_list[i]))
 */
      __pyx_v_j = (__pyx_v_j + 1);

      /* "cupy/core/core.pyx":2901
 *             shape.push_back(dim)
 *             j += 1
 *         elif numpy.isscalar(s):             # <<<<<<<<<<<<<<
 *             ind = int(s)
 *             if ind < 0:
 */
      goto __pyx_L5;
    }

    /* "cupy/core/core.pyx":2912
 *             j += 1
 *         else:
 *             raise TypeError('Invalid index type: %s' % type(slice_list[i]))             # <<<<<<<<<<<<<<
 * 
 *     v = a.view()
 */
    /*else*/ {
      if (unlikely(__pyx_v_slice_list == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 2912, __pyx_L1_error)
      }
      __pyx_t_9 = __Pyx_GetItemInt_List(__pyx_v_slice_list, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2912, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_index_type_s, ((PyObject *)Py_TYPE(__pyx_t_9))); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2912, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2912, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 2912, __pyx_L1_error)
    }
    __pyx_L5:;

    /* "cupy/core/core.pyx":2871
 *     offset = 0
 *     ndim = a._shape.size()
 *     for i, s in enumerate(slice_list):             # <<<<<<<<<<<<<<
 *         if s is None:
 *             shape.push_back(1)
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2914
 *             raise TypeError('Invalid index type: %s' % type(slice_list[i]))
 * 
 *     v = a.view()             # <<<<<<<<<<<<<<
 *     if a.size != 0:
 *         v.data = a.data + offset
 */
  __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2914, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2915
 * 
 *     v = a.view()
 *     if a.size != 0:             # <<<<<<<<<<<<<<
 *         v.data = a.data + offset
 *     v._set_shape_and_strides(shape, strides)
 */
  __pyx_t_6 = ((__pyx_v_a->size != 0) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2916
 *     v = a.view()
 *     if a.size != 0:
 *         v.data = a.data + offset             # <<<<<<<<<<<<<<
 *     v._set_shape_and_strides(shape, strides)
 *     return v
 */
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2916, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = PyNumber_Add(((PyObject *)__pyx_v_a->data), __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2916, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer))))) __PYX_ERR(0, 2916, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_9);
    __Pyx_GOTREF(__pyx_v_v->data);
    __Pyx_DECREF(((PyObject *)__pyx_v_v->data));
    __pyx_v_v->data = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_9);
    __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":2915
 * 
 *     v = a.view()
 *     if a.size != 0:             # <<<<<<<<<<<<<<
 *         v.data = a.data + offset
 *     v._set_shape_and_strides(shape, strides)
 */
  }

  /* "cupy/core/core.pyx":2917
 *     if a.size != 0:
 *         v.data = a.data + offset
 *     v._set_shape_and_strides(shape, strides)             # <<<<<<<<<<<<<<
 *     return v
 * 
 */
  __pyx_t_9 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_v->__pyx_vtab)->_set_shape_and_strides(__pyx_v_v, __pyx_v_shape, __pyx_v_strides, 0, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2917, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":2918
 *         v.data = a.data + offset
 *     v._set_shape_and_strides(shape, strides)
 *     return v             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_v));
  __pyx_r = __pyx_v_v;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2860
 *     return a, adv_slices, adv_mask
 * 
 * cdef ndarray _simple_getitem(ndarray a, list slice_list):             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] shape, strides
 *     cdef ndarray v
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.core.core._simple_getitem", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_ss);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3016
 * 
 * 
 * cpdef _prepare_mask_indexing_single(ndarray a, ndarray mask, Py_ssize_t axis):             # <<<<<<<<<<<<<<
 *     cdef ndarray mask_scanned, mask_br, mask_br_scanned
 *     cdef int n_true
 */

static PyObject *__pyx_pw_4cupy_4core_4core_81_prepare_mask_indexing_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__prepare_mask_indexing_single(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, Py_ssize_t __pyx_v_axis, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask_scanned = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask_br = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask_br_scanned = 0;
  int __pyx_v_n_true;
  PyObject *__pyx_v_lshape = 0;
  PyObject *__pyx_v_rshape = 0;
  PyObject *__pyx_v_masked_shape = NULL;
  PyObject *__pyx_v_mask_type = 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;
  int __pyx_t_5;
  std::vector<Py_ssize_t>  __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("_prepare_mask_indexing_single", 0);

  /* "cupy/core/core.pyx":3021
 *     cdef tuple lshape, rshape, out_shape
 * 
 *     lshape = a.shape[:axis]             # <<<<<<<<<<<<<<
 *     rshape = a.shape[axis + mask.ndim:]
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3021, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_1, 0, __pyx_v_axis, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3021, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 3021, __pyx_L1_error)
  __pyx_v_lshape = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3022
 * 
 *     lshape = a.shape[:axis]
 *     rshape = a.shape[axis + mask.ndim:]             # <<<<<<<<<<<<<<
 * 
 *     if mask.size == 0:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3022, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_axis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3022, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mask), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3022, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3022, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, 0, &__pyx_t_4, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3022, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 3022, __pyx_L1_error)
  __pyx_v_rshape = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3024
 *     rshape = a.shape[axis + mask.ndim:]
 * 
 *     if mask.size == 0:             # <<<<<<<<<<<<<<
 *         masked_shape = lshape + (0,) + rshape
 *         mask_br = mask._reshape(masked_shape)
 */
  __pyx_t_5 = ((__pyx_v_mask->size == 0) != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":3025
 * 
 *     if mask.size == 0:
 *         masked_shape = lshape + (0,) + rshape             # <<<<<<<<<<<<<<
 *         mask_br = mask._reshape(masked_shape)
 *         return mask_br, mask_br, masked_shape
 */
    __pyx_t_3 = PyNumber_Add(__pyx_v_lshape, __pyx_tuple__115); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3025, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_v_rshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3025, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_masked_shape = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3026
 *     if mask.size == 0:
 *         masked_shape = lshape + (0,) + rshape
 *         mask_br = mask._reshape(masked_shape)             # <<<<<<<<<<<<<<
 *         return mask_br, mask_br, masked_shape
 * 
 */
    __pyx_t_6 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_masked_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3026, __pyx_L1_error)
    __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_mask->__pyx_vtab)->_reshape(__pyx_v_mask, __pyx_t_6, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3026, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_mask_br = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3027
 *         masked_shape = lshape + (0,) + rshape
 *         mask_br = mask._reshape(masked_shape)
 *         return mask_br, mask_br, masked_shape             # <<<<<<<<<<<<<<
 * 
 *     # Get number of True in the mask to determine the shape of the array
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3027, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_mask_br));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_mask_br));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_mask_br));
    __Pyx_INCREF(((PyObject *)__pyx_v_mask_br));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_mask_br));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_mask_br));
    __Pyx_INCREF(__pyx_v_masked_shape);
    __Pyx_GIVEREF(__pyx_v_masked_shape);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_masked_shape);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3024
 *     rshape = a.shape[axis + mask.ndim:]
 * 
 *     if mask.size == 0:             # <<<<<<<<<<<<<<
 *         masked_shape = lshape + (0,) + rshape
 *         mask_br = mask._reshape(masked_shape)
 */
  }

  /* "cupy/core/core.pyx":3031
 *     # Get number of True in the mask to determine the shape of the array
 *     # after masking.
 *     if mask.size <= 2 ** 31 - 1:             # <<<<<<<<<<<<<<
 *         mask_type = numpy.int32
 *     else:
 */
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_mask->size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3031, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_4, __pyx_int_2147483647, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3031, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 3031, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":3032
 *     # after masking.
 *     if mask.size <= 2 ** 31 - 1:
 *         mask_type = numpy.int32             # <<<<<<<<<<<<<<
 *     else:
 *         mask_type = numpy.int64
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3032, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3032, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_mask_type = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3031
 *     # Get number of True in the mask to determine the shape of the array
 *     # after masking.
 *     if mask.size <= 2 ** 31 - 1:             # <<<<<<<<<<<<<<
 *         mask_type = numpy.int32
 *     else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":3034
 *         mask_type = numpy.int32
 *     else:
 *         mask_type = numpy.int64             # <<<<<<<<<<<<<<
 *     mask_scanned = scan(mask.astype(mask_type).ravel())  # starts with 1
 *     n_true = int(mask_scanned[-1])
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3034, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3034, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_mask_type = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":3035
 *     else:
 *         mask_type = numpy.int64
 *     mask_scanned = scan(mask.astype(mask_type).ravel())  # starts with 1             # <<<<<<<<<<<<<<
 *     n_true = int(mask_scanned[-1])
 *     masked_shape = lshape + (n_true,) + rshape
 */
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_mask->__pyx_vtab)->astype(__pyx_v_mask, __pyx_v_mask_type, 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3035, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3)->__pyx_vtab)->ravel(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3), 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3035, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_scan(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4), 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3035, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_mask_scanned = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3036
 *         mask_type = numpy.int64
 *     mask_scanned = scan(mask.astype(mask_type).ravel())  # starts with 1
 *     n_true = int(mask_scanned[-1])             # <<<<<<<<<<<<<<
 *     masked_shape = lshape + (n_true,) + rshape
 * 
 */
  __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_mask_scanned), -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3036, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3036, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3036, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_n_true = __pyx_t_7;

  /* "cupy/core/core.pyx":3037
 *     mask_scanned = scan(mask.astype(mask_type).ravel())  # starts with 1
 *     n_true = int(mask_scanned[-1])
 *     masked_shape = lshape + (n_true,) + rshape             # <<<<<<<<<<<<<<
 * 
 *     # When mask covers the entire array, broadcasting is not necessary.
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_true); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3037, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3037, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Add(__pyx_v_lshape, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3037, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_v_rshape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3037, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_masked_shape = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3040
 * 
 *     # When mask covers the entire array, broadcasting is not necessary.
 *     if mask.ndim == a.ndim and axis == 0:             # <<<<<<<<<<<<<<
 *         return mask, mask_scanned._reshape(mask._shape), masked_shape
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mask), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3040, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3040, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3040, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 3040, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_8) {
  } else {
    __pyx_t_5 = __pyx_t_8;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_8 = ((__pyx_v_axis == 0) != 0);
  __pyx_t_5 = __pyx_t_8;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":3041
 *     # When mask covers the entire array, broadcasting is not necessary.
 *     if mask.ndim == a.ndim and axis == 0:
 *         return mask, mask_scanned._reshape(mask._shape), masked_shape             # <<<<<<<<<<<<<<
 * 
 *     # The scan of the broadcasted array is used to index on kernel.
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_mask_scanned->__pyx_vtab)->_reshape(__pyx_v_mask_scanned, __pyx_v_mask->_shape, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3041, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3041, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_mask));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_mask));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_mask));
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_masked_shape);
    __Pyx_GIVEREF(__pyx_v_masked_shape);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_masked_shape);
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3040
 * 
 *     # When mask covers the entire array, broadcasting is not necessary.
 *     if mask.ndim == a.ndim and axis == 0:             # <<<<<<<<<<<<<<
 *         return mask, mask_scanned._reshape(mask._shape), masked_shape
 * 
 */
  }

  /* "cupy/core/core.pyx":3045
 *     # The scan of the broadcasted array is used to index on kernel.
 *     mask_br = mask._reshape(
 *         axis * (1,) + mask.shape + (a.ndim - axis - mask.ndim) * (1,))             # <<<<<<<<<<<<<<
 *     mask_br = broadcast_to(mask_br, a.shape)
 *     if mask.size <= 2 ** 31 - 1:
 */
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_axis); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_4, __pyx_tuple__116); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mask), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_axis); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mask), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_4, __pyx_tuple__117); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3045, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3044
 * 
 *     # The scan of the broadcasted array is used to index on kernel.
 *     mask_br = mask._reshape(             # <<<<<<<<<<<<<<
 *         axis * (1,) + mask.shape + (a.ndim - axis - mask.ndim) * (1,))
 *     mask_br = broadcast_to(mask_br, a.shape)
 */
  __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_mask->__pyx_vtab)->_reshape(__pyx_v_mask, __pyx_t_6, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3044, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_mask_br = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3046
 *     mask_br = mask._reshape(
 *         axis * (1,) + mask.shape + (a.ndim - axis - mask.ndim) * (1,))
 *     mask_br = broadcast_to(mask_br, a.shape)             # <<<<<<<<<<<<<<
 *     if mask.size <= 2 ** 31 - 1:
 *         mask_type = numpy.int32
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3046, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core_broadcast_to(__pyx_v_mask_br, __pyx_t_4, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3046, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_mask_br, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3047
 *         axis * (1,) + mask.shape + (a.ndim - axis - mask.ndim) * (1,))
 *     mask_br = broadcast_to(mask_br, a.shape)
 *     if mask.size <= 2 ** 31 - 1:             # <<<<<<<<<<<<<<
 *         mask_type = numpy.int32
 *     else:
 */
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_mask->size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3047, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_int_2147483647, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3047, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 3047, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":3048
 *     mask_br = broadcast_to(mask_br, a.shape)
 *     if mask.size <= 2 ** 31 - 1:
 *         mask_type = numpy.int32             # <<<<<<<<<<<<<<
 *     else:
 *         mask_type = numpy.int64
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3048, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3048, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_mask_type, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3047
 *         axis * (1,) + mask.shape + (a.ndim - axis - mask.ndim) * (1,))
 *     mask_br = broadcast_to(mask_br, a.shape)
 *     if mask.size <= 2 ** 31 - 1:             # <<<<<<<<<<<<<<
 *         mask_type = numpy.int32
 *     else:
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":3050
 *         mask_type = numpy.int32
 *     else:
 *         mask_type = numpy.int64             # <<<<<<<<<<<<<<
 *     mask_br_scanned = scan(mask_br.astype(mask_type).ravel())
 *     mask_br_scanned = mask_br_scanned._reshape(mask_br._shape)
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3050, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3050, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_mask_type, __pyx_t_4);
    __pyx_t_4 = 0;
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":3051
 *     else:
 *         mask_type = numpy.int64
 *     mask_br_scanned = scan(mask_br.astype(mask_type).ravel())             # <<<<<<<<<<<<<<
 *     mask_br_scanned = mask_br_scanned._reshape(mask_br._shape)
 *     return mask_br, mask_br_scanned, masked_shape
 */
  __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_mask_br->__pyx_vtab)->astype(__pyx_v_mask_br, __pyx_v_mask_type, 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4)->__pyx_vtab)->ravel(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4), 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core_scan(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2), 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_mask_br_scanned = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3052
 *         mask_type = numpy.int64
 *     mask_br_scanned = scan(mask_br.astype(mask_type).ravel())
 *     mask_br_scanned = mask_br_scanned._reshape(mask_br._shape)             # <<<<<<<<<<<<<<
 *     return mask_br, mask_br_scanned, masked_shape
 * 
 */
  __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_mask_br_scanned->__pyx_vtab)->_reshape(__pyx_v_mask_br_scanned, __pyx_v_mask_br->_shape, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3052, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF_SET(__pyx_v_mask_br_scanned, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3053
 *     mask_br_scanned = scan(mask_br.astype(mask_type).ravel())
 *     mask_br_scanned = mask_br_scanned._reshape(mask_br._shape)
 *     return mask_br, mask_br_scanned, masked_shape             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3053, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_mask_br));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_mask_br));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_mask_br));
  __Pyx_INCREF(((PyObject *)__pyx_v_mask_br_scanned));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_mask_br_scanned));
  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_mask_br_scanned));
  __Pyx_INCREF(__pyx_v_masked_shape);
  __Pyx_GIVEREF(__pyx_v_masked_shape);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_masked_shape);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3016
 * 
 * 
 * cpdef _prepare_mask_indexing_single(ndarray a, ndarray mask, Py_ssize_t axis):             # <<<<<<<<<<<<<<
 *     cdef ndarray mask_scanned, mask_br, mask_br_scanned
 *     cdef int n_true
 */

  /* 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("cupy.core.core._prepare_mask_indexing_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mask_scanned);
  __Pyx_XDECREF((PyObject *)__pyx_v_mask_br);
  __Pyx_XDECREF((PyObject *)__pyx_v_mask_br_scanned);
  __Pyx_XDECREF(__pyx_v_lshape);
  __Pyx_XDECREF(__pyx_v_rshape);
  __Pyx_XDECREF(__pyx_v_masked_shape);
  __Pyx_XDECREF(__pyx_v_mask_type);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_81_prepare_mask_indexing_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_80_prepare_mask_indexing_single[] = "_prepare_mask_indexing_single(ndarray a, ndarray mask, Py_ssize_t axis)";
static PyObject *__pyx_pw_4cupy_4core_4core_81_prepare_mask_indexing_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask = 0;
  Py_ssize_t __pyx_v_axis;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_prepare_mask_indexing_single (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_mask,&__pyx_n_s_axis,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_a)) != 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_mask)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_prepare_mask_indexing_single", 1, 3, 3, 1); __PYX_ERR(0, 3016, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_prepare_mask_indexing_single", 1, 3, 3, 2); __PYX_ERR(0, 3016, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_prepare_mask_indexing_single") < 0)) __PYX_ERR(0, 3016, __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_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_mask = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_axis = __Pyx_PyIndex_AsSsize_t(values[2]); if (unlikely((__pyx_v_axis == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3016, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_prepare_mask_indexing_single", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3016, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._prepare_mask_indexing_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3016, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mask), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "mask", 0))) __PYX_ERR(0, 3016, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_80_prepare_mask_indexing_single(__pyx_self, __pyx_v_a, __pyx_v_mask, __pyx_v_axis);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_80_prepare_mask_indexing_single(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, Py_ssize_t __pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_prepare_mask_indexing_single", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__prepare_mask_indexing_single(__pyx_v_a, __pyx_v_mask, __pyx_v_axis, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._prepare_mask_indexing_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3056
 * 
 * 
 * cpdef ndarray _getitem_mask_single(ndarray a, ndarray mask, int axis):             # <<<<<<<<<<<<<<
 *     cdef ndarray mask_scanned
 *     cdef tuple masked_shape
 */

static PyObject *__pyx_pw_4cupy_4core_4core_83_getitem_mask_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__getitem_mask_single(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, int __pyx_v_axis, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask_scanned = 0;
  PyObject *__pyx_v_masked_shape = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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)(PyObject *);
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("_getitem_mask_single", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_mask);

  /* "cupy/core/core.pyx":3060
 *     cdef tuple masked_shape
 * 
 *     mask, mask_scanned, masked_shape = _prepare_mask_indexing_single(             # <<<<<<<<<<<<<<
 *         a, mask, axis)
 *     out = ndarray(masked_shape, dtype=a.dtype)
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__prepare_mask_indexing_single(__pyx_v_a, __pyx_v_mask, __pyx_v_axis, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 3060, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3060, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3060, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3060, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3060, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 2; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 3) < 0) __PYX_ERR(0, 3060, __pyx_L1_error)
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 3060, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3060, __pyx_L1_error)
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3060, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 3060, __pyx_L1_error)
  __Pyx_DECREF_SET(__pyx_v_mask, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_v_mask_scanned = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_masked_shape = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3062
 *     mask, mask_scanned, masked_shape = _prepare_mask_indexing_single(
 *         a, mask, axis)
 *     out = ndarray(masked_shape, dtype=a.dtype)             # <<<<<<<<<<<<<<
 *     if out.size == 0:
 *         return out
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3062, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_masked_shape);
  __Pyx_GIVEREF(__pyx_v_masked_shape);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_masked_shape);
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3062, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) __PYX_ERR(0, 3062, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3062, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3063
 *         a, mask, axis)
 *     out = ndarray(masked_shape, dtype=a.dtype)
 *     if out.size == 0:             # <<<<<<<<<<<<<<
 *         return out
 *     return _getitem_mask_kernel(a, mask, mask_scanned, out)
 */
  __pyx_t_7 = ((__pyx_v_out->size == 0) != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":3064
 *     out = ndarray(masked_shape, dtype=a.dtype)
 *     if out.size == 0:
 *         return out             # <<<<<<<<<<<<<<
 *     return _getitem_mask_kernel(a, mask, mask_scanned, out)
 * 
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __pyx_r = __pyx_v_out;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3063
 *         a, mask, axis)
 *     out = ndarray(masked_shape, dtype=a.dtype)
 *     if out.size == 0:             # <<<<<<<<<<<<<<
 *         return out
 *     return _getitem_mask_kernel(a, mask, mask_scanned, out)
 */
  }

  /* "cupy/core/core.pyx":3065
 *     if out.size == 0:
 *         return out
 *     return _getitem_mask_kernel(a, mask, mask_scanned, out)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__getitem_mask_kernel);
  __pyx_t_4 = __pyx_v_4cupy_4core_4core__getitem_mask_kernel; __pyx_t_1 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[5] = {__pyx_t_1, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_mask), ((PyObject *)__pyx_v_mask_scanned), ((PyObject *)__pyx_v_out)};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3065, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[5] = {__pyx_t_1, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_mask), ((PyObject *)__pyx_v_mask_scanned), ((PyObject *)__pyx_v_out)};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3065, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  {
    __pyx_t_2 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3065, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_8, ((PyObject *)__pyx_v_a));
    __Pyx_INCREF(((PyObject *)__pyx_v_mask));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_mask));
    PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_8, ((PyObject *)__pyx_v_mask));
    __Pyx_INCREF(((PyObject *)__pyx_v_mask_scanned));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_mask_scanned));
    PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_8, ((PyObject *)__pyx_v_mask_scanned));
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
    PyTuple_SET_ITEM(__pyx_t_2, 3+__pyx_t_8, ((PyObject *)__pyx_v_out));
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3065, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3065, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3056
 * 
 * 
 * cpdef ndarray _getitem_mask_single(ndarray a, ndarray mask, int axis):             # <<<<<<<<<<<<<<
 *     cdef ndarray mask_scanned
 *     cdef tuple masked_shape
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core._getitem_mask_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mask_scanned);
  __Pyx_XDECREF(__pyx_v_masked_shape);
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XDECREF((PyObject *)__pyx_v_mask);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_83_getitem_mask_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_82_getitem_mask_single[] = "_getitem_mask_single(ndarray a, ndarray mask, int axis) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_83_getitem_mask_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask = 0;
  int __pyx_v_axis;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_getitem_mask_single (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_mask,&__pyx_n_s_axis,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_a)) != 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_mask)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_getitem_mask_single", 1, 3, 3, 1); __PYX_ERR(0, 3056, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_getitem_mask_single", 1, 3, 3, 2); __PYX_ERR(0, 3056, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_getitem_mask_single") < 0)) __PYX_ERR(0, 3056, __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_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_mask = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_axis = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_axis == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3056, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_getitem_mask_single", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3056, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._getitem_mask_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3056, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mask), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "mask", 0))) __PYX_ERR(0, 3056, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_82_getitem_mask_single(__pyx_self, __pyx_v_a, __pyx_v_mask, __pyx_v_axis);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_82_getitem_mask_single(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, int __pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_getitem_mask_single", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__getitem_mask_single(__pyx_v_a, __pyx_v_mask, __pyx_v_axis, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._getitem_mask_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3068
 * 
 * 
 * cpdef ndarray _take(ndarray a, indices, li=None, ri=None, ndarray out=None):             # <<<<<<<<<<<<<<
 *     # When li == ri, this function behaves similarly to np.take
 *     if a.ndim == 0:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_85_take(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__take(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_indices, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__take *__pyx_optional_args) {
  PyObject *__pyx_v_li = ((PyObject *)Py_None);
  PyObject *__pyx_v_ri = ((PyObject *)Py_None);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
  PyObject *__pyx_v_lshape = NULL;
  PyObject *__pyx_v_rshape = NULL;
  Py_ssize_t __pyx_v_adim;
  PyObject *__pyx_v_index_range = NULL;
  PyObject *__pyx_v_out_shape = NULL;
  PyObject *__pyx_v_cdim = NULL;
  Py_ssize_t __pyx_v_rdim;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_array __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  __Pyx_RefNannySetupContext("_take", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_li = __pyx_optional_args->li;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_ri = __pyx_optional_args->ri;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
        }
      }
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF(__pyx_v_indices);
  __Pyx_INCREF(__pyx_v_li);
  __Pyx_INCREF(__pyx_v_ri);
  __Pyx_INCREF((PyObject *)__pyx_v_out);

  /* "cupy/core/core.pyx":3070
 * cpdef ndarray _take(ndarray a, indices, li=None, ri=None, ndarray out=None):
 *     # When li == ri, this function behaves similarly to np.take
 *     if a.ndim == 0:             # <<<<<<<<<<<<<<
 *         a = a[None]
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3070, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3070, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3070, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3071
 *     # When li == ri, this function behaves similarly to np.take
 *     if a.ndim == 0:
 *         a = a[None]             # <<<<<<<<<<<<<<
 * 
 *     if li is None and ri is None:
 */
    __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_a), Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3071, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3071, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3070
 * cpdef ndarray _take(ndarray a, indices, li=None, ri=None, ndarray out=None):
 *     # When li == ri, this function behaves similarly to np.take
 *     if a.ndim == 0:             # <<<<<<<<<<<<<<
 *         a = a[None]
 * 
 */
  }

  /* "cupy/core/core.pyx":3073
 *         a = a[None]
 * 
 *     if li is None and ri is None:             # <<<<<<<<<<<<<<
 *         a = a.ravel()
 *         lshape = ()
 */
  __pyx_t_4 = (__pyx_v_li == Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_5 = (__pyx_v_ri == Py_None);
  __pyx_t_4 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3074
 * 
 *     if li is None and ri is None:
 *         a = a.ravel()             # <<<<<<<<<<<<<<
 *         lshape = ()
 *         rshape = ()
 */
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->ravel(__pyx_v_a, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3074, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3075
 *     if li is None and ri is None:
 *         a = a.ravel()
 *         lshape = ()             # <<<<<<<<<<<<<<
 *         rshape = ()
 *         adim = 1
 */
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_v_lshape = __pyx_empty_tuple;

    /* "cupy/core/core.pyx":3076
 *         a = a.ravel()
 *         lshape = ()
 *         rshape = ()             # <<<<<<<<<<<<<<
 *         adim = 1
 *         index_range = a.size
 */
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_v_rshape = __pyx_empty_tuple;

    /* "cupy/core/core.pyx":3077
 *         lshape = ()
 *         rshape = ()
 *         adim = 1             # <<<<<<<<<<<<<<
 *         index_range = a.size
 *     else:
 */
    __pyx_v_adim = 1;

    /* "cupy/core/core.pyx":3078
 *         rshape = ()
 *         adim = 1
 *         index_range = a.size             # <<<<<<<<<<<<<<
 *     else:
 *         if not (-a.ndim <= li < a.ndim and -a.ndim <= ri < a.ndim):
 */
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_a->size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3078, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_index_range = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3073
 *         a = a[None]
 * 
 *     if li is None and ri is None:             # <<<<<<<<<<<<<<
 *         a = a.ravel()
 *         lshape = ()
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":3080
 *         index_range = a.size
 *     else:
 *         if not (-a.ndim <= li < a.ndim and -a.ndim <= ri < a.ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis overrun')
 *         if a.ndim != 0:
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3080, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Negative(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3080, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_v_li, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3080, __pyx_L1_error)
    if (__Pyx_PyObject_IsTrue(__pyx_t_2)) {
      __Pyx_DECREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3080, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_li, __pyx_t_6, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3080, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3080, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_4) {
    } else {
      __pyx_t_3 = __pyx_t_4;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3080, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Negative(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3080, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_v_ri, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3080, __pyx_L1_error)
    if (__Pyx_PyObject_IsTrue(__pyx_t_2)) {
      __Pyx_DECREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3080, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_ri, __pyx_t_6, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3080, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3080, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = __pyx_t_4;
    __pyx_L8_bool_binop_done:;
    __pyx_t_4 = ((!__pyx_t_3) != 0);
    if (unlikely(__pyx_t_4)) {

      /* "cupy/core/core.pyx":3081
 *     else:
 *         if not (-a.ndim <= li < a.ndim and -a.ndim <= ri < a.ndim):
 *             raise _AxisError('Axis overrun')             # <<<<<<<<<<<<<<
 *         if a.ndim != 0:
 *             li %= a.ndim
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_AxisError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3081, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__118, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3081, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(0, 3081, __pyx_L1_error)

      /* "cupy/core/core.pyx":3080
 *         index_range = a.size
 *     else:
 *         if not (-a.ndim <= li < a.ndim and -a.ndim <= ri < a.ndim):             # <<<<<<<<<<<<<<
 *             raise _AxisError('Axis overrun')
 *         if a.ndim != 0:
 */
    }

    /* "cupy/core/core.pyx":3082
 *         if not (-a.ndim <= li < a.ndim and -a.ndim <= ri < a.ndim):
 *             raise _AxisError('Axis overrun')
 *         if a.ndim != 0:             # <<<<<<<<<<<<<<
 *             li %= a.ndim
 *             ri %= a.ndim
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3082, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3082, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3082, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":3083
 *             raise _AxisError('Axis overrun')
 *         if a.ndim != 0:
 *             li %= a.ndim             # <<<<<<<<<<<<<<
 *             ri %= a.ndim
 * 
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3083, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyNumber_InPlaceRemainder(__pyx_v_li, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3083, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_li, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":3084
 *         if a.ndim != 0:
 *             li %= a.ndim
 *             ri %= a.ndim             # <<<<<<<<<<<<<<
 * 
 *         lshape = a.shape[:li]
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3084, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_InPlaceRemainder(__pyx_v_ri, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3084, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_ri, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":3082
 *         if not (-a.ndim <= li < a.ndim and -a.ndim <= ri < a.ndim):
 *             raise _AxisError('Axis overrun')
 *         if a.ndim != 0:             # <<<<<<<<<<<<<<
 *             li %= a.ndim
 *             ri %= a.ndim
 */
    }

    /* "cupy/core/core.pyx":3086
 *             ri %= a.ndim
 * 
 *         lshape = a.shape[:li]             # <<<<<<<<<<<<<<
 *         rshape = a.shape[ri + 1:]
 *         adim = internal.prod(a.shape[li:ri + 1])
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3086, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, 0, NULL, &__pyx_v_li, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3086, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_lshape = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3087
 * 
 *         lshape = a.shape[:li]
 *         rshape = a.shape[ri + 1:]             # <<<<<<<<<<<<<<
 *         adim = internal.prod(a.shape[li:ri + 1])
 *         index_range = adim
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3087, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_ri, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3087, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_t_1, 0, 0, &__pyx_t_2, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3087, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_rshape = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":3088
 *         lshape = a.shape[:li]
 *         rshape = a.shape[ri + 1:]
 *         adim = internal.prod(a.shape[li:ri + 1])             # <<<<<<<<<<<<<<
 *         index_range = adim
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3088, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_ri, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3088, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_6, 0, 0, &__pyx_v_li, &__pyx_t_2, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3088, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = __pyx_f_4cupy_4core_8internal_prod(__pyx_t_1, 0, NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3088, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_adim = __pyx_t_7;

    /* "cupy/core/core.pyx":3089
 *         rshape = a.shape[ri + 1:]
 *         adim = internal.prod(a.shape[li:ri + 1])
 *         index_range = adim             # <<<<<<<<<<<<<<
 * 
 *     if numpy.isscalar(indices):
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_adim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3089, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_index_range = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":3091
 *         index_range = adim
 * 
 *     if numpy.isscalar(indices):             # <<<<<<<<<<<<<<
 *         indices %= index_range
 *         if li is not None and ri is not None and li == ri:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3091, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_isscalar); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3091, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3091, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_indices};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3091, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_indices};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3091, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3091, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(__pyx_v_indices);
      __Pyx_GIVEREF(__pyx_v_indices);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_indices);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3091, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3091, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":3092
 * 
 *     if numpy.isscalar(indices):
 *         indices %= index_range             # <<<<<<<<<<<<<<
 *         if li is not None and ri is not None and li == ri:
 *             a = rollaxis(a, li)
 */
    __pyx_t_1 = PyNumber_InPlaceRemainder(__pyx_v_indices, __pyx_v_index_range); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3092, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3093
 *     if numpy.isscalar(indices):
 *         indices %= index_range
 *         if li is not None and ri is not None and li == ri:             # <<<<<<<<<<<<<<
 *             a = rollaxis(a, li)
 *         if out is None:
 */
    __pyx_t_3 = (__pyx_v_li != Py_None);
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_ri != Py_None);
    __pyx_t_3 = (__pyx_t_5 != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_li, __pyx_v_ri, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3093, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3093, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __pyx_t_3;
    __pyx_L13_bool_binop_done:;
    if (__pyx_t_4) {

      /* "cupy/core/core.pyx":3094
 *         indices %= index_range
 *         if li is not None and ri is not None and li == ri:
 *             a = rollaxis(a, li)             # <<<<<<<<<<<<<<
 *         if out is None:
 *             return a[indices].copy()
 */
      __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_v_li); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3094, __pyx_L1_error)
      __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_rollaxis(__pyx_v_a, __pyx_t_7, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3094, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":3093
 *     if numpy.isscalar(indices):
 *         indices %= index_range
 *         if li is not None and ri is not None and li == ri:             # <<<<<<<<<<<<<<
 *             a = rollaxis(a, li)
 *         if out is None:
 */
    }

    /* "cupy/core/core.pyx":3095
 *         if li is not None and ri is not None and li == ri:
 *             a = rollaxis(a, li)
 *         if out is None:             # <<<<<<<<<<<<<<
 *             return a[indices].copy()
 *         else:
 */
    __pyx_t_4 = (((PyObject *)__pyx_v_out) == Py_None);
    __pyx_t_3 = (__pyx_t_4 != 0);
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":3096
 *             a = rollaxis(a, li)
 *         if out is None:
 *             return a[indices].copy()             # <<<<<<<<<<<<<<
 *         else:
 *             if out.dtype != a.dtype:
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_6 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_v_indices); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_copy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_6) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3096, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else {
        __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3096, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3096, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
      __pyx_t_1 = 0;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":3095
 *         if li is not None and ri is not None and li == ri:
 *             a = rollaxis(a, li)
 *         if out is None:             # <<<<<<<<<<<<<<
 *             return a[indices].copy()
 *         else:
 */
    }

    /* "cupy/core/core.pyx":3098
 *             return a[indices].copy()
 *         else:
 *             if out.dtype != a.dtype:             # <<<<<<<<<<<<<<
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:
 */
    /*else*/ {
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_out->dtype, __pyx_v_a->dtype, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3098, __pyx_L1_error)
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3098, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(__pyx_t_3)) {

        /* "cupy/core/core.pyx":3099
 *         else:
 *             if out.dtype != a.dtype:
 *                 raise TypeError('Output dtype mismatch')             # <<<<<<<<<<<<<<
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')
 */
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__119, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3099, __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(0, 3099, __pyx_L1_error)

        /* "cupy/core/core.pyx":3098
 *             return a[indices].copy()
 *         else:
 *             if out.dtype != a.dtype:             # <<<<<<<<<<<<<<
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:
 */
      }

      /* "cupy/core/core.pyx":3100
 *             if out.dtype != a.dtype:
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Output shape mismatch')
 *             elementwise_copy(a[indices], out)
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3100, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3100, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_t_8, 1, 0, NULL, NULL, &__pyx_slice__120, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3100, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_1, __pyx_t_6, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3100, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3100, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(__pyx_t_3)) {

        /* "cupy/core/core.pyx":3101
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')             # <<<<<<<<<<<<<<
 *             elementwise_copy(a[indices], out)
 *             return out
 */
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__121, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3101, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_Raise(__pyx_t_8, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __PYX_ERR(0, 3101, __pyx_L1_error)

        /* "cupy/core/core.pyx":3100
 *             if out.dtype != a.dtype:
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Output shape mismatch')
 *             elementwise_copy(a[indices], out)
 */
      }

      /* "cupy/core/core.pyx":3102
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')
 *             elementwise_copy(a[indices], out)             # <<<<<<<<<<<<<<
 *             return out
 *     elif not isinstance(indices, ndarray):
 */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3102, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_v_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3102, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_1, ((PyObject *)__pyx_v_out)};
        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3102, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_8);
        __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_2, __pyx_t_1, ((PyObject *)__pyx_v_out)};
        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3102, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3102, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (__pyx_t_2) {
          __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __pyx_t_2 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_1);
        __Pyx_INCREF(((PyObject *)__pyx_v_out));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, ((PyObject *)__pyx_v_out));
        __pyx_t_1 = 0;
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3102, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":3103
 *                 raise ValueError('Output shape mismatch')
 *             elementwise_copy(a[indices], out)
 *             return out             # <<<<<<<<<<<<<<
 *     elif not isinstance(indices, ndarray):
 *         indices = array(indices, dtype=int)
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(((PyObject *)__pyx_v_out));
      __pyx_r = __pyx_v_out;
      goto __pyx_L0;
    }

    /* "cupy/core/core.pyx":3091
 *         index_range = adim
 * 
 *     if numpy.isscalar(indices):             # <<<<<<<<<<<<<<
 *         indices %= index_range
 *         if li is not None and ri is not None and li == ri:
 */
  }

  /* "cupy/core/core.pyx":3104
 *             elementwise_copy(a[indices], out)
 *             return out
 *     elif not isinstance(indices, ndarray):             # <<<<<<<<<<<<<<
 *         indices = array(indices, dtype=int)
 * 
 */
  __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_indices, __pyx_ptype_4cupy_4core_4core_ndarray); 
  __pyx_t_4 = ((!(__pyx_t_3 != 0)) != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":3105
 *             return out
 *     elif not isinstance(indices, ndarray):
 *         indices = array(indices, dtype=int)             # <<<<<<<<<<<<<<
 * 
 *     out_shape = lshape + indices.shape + rshape
 */
    __pyx_t_11.__pyx_n = 1;
    __pyx_t_11.dtype = ((PyObject *)(&PyInt_Type));
    __pyx_t_8 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_v_indices, 0, &__pyx_t_11)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3105, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3104
 *             elementwise_copy(a[indices], out)
 *             return out
 *     elif not isinstance(indices, ndarray):             # <<<<<<<<<<<<<<
 *         indices = array(indices, dtype=int)
 * 
 */
  }

  /* "cupy/core/core.pyx":3107
 *         indices = array(indices, dtype=int)
 * 
 *     out_shape = lshape + indices.shape + rshape             # <<<<<<<<<<<<<<
 *     if out is None:
 *         out = ndarray(out_shape, dtype=a.dtype)
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = PyNumber_Add(__pyx_v_lshape, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyNumber_Add(__pyx_t_6, __pyx_v_rshape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_out_shape = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3108
 * 
 *     out_shape = lshape + indices.shape + rshape
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(out_shape, dtype=a.dtype)
 *     else:
 */
  __pyx_t_4 = (((PyObject *)__pyx_v_out) == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3109
 *     out_shape = lshape + indices.shape + rshape
 *     if out is None:
 *         out = ndarray(out_shape, dtype=a.dtype)             # <<<<<<<<<<<<<<
 *     else:
 *         if out.dtype != a.dtype:
 */
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3109, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_out_shape);
    __Pyx_GIVEREF(__pyx_v_out_shape);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_out_shape);
    __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3109, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) __PYX_ERR(0, 3109, __pyx_L1_error)
    __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3109, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10));
    __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":3108
 * 
 *     out_shape = lshape + indices.shape + rshape
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(out_shape, dtype=a.dtype)
 *     else:
 */
    goto __pyx_L19;
  }

  /* "cupy/core/core.pyx":3111
 *         out = ndarray(out_shape, dtype=a.dtype)
 *     else:
 *         if out.dtype != a.dtype:             # <<<<<<<<<<<<<<
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:
 */
  /*else*/ {
    __pyx_t_10 = PyObject_RichCompare(__pyx_v_out->dtype, __pyx_v_a->dtype, Py_NE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3111, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3111, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(__pyx_t_3)) {

      /* "cupy/core/core.pyx":3112
 *     else:
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')             # <<<<<<<<<<<<<<
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')
 */
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__122, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3112, __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(0, 3112, __pyx_L1_error)

      /* "cupy/core/core.pyx":3111
 *         out = ndarray(out_shape, dtype=a.dtype)
 *     else:
 *         if out.dtype != a.dtype:             # <<<<<<<<<<<<<<
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:
 */
    }

    /* "cupy/core/core.pyx":3113
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Output shape mismatch')
 * 
 */
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_10, __pyx_v_out_shape, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3113, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3113, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_t_3)) {

      /* "cupy/core/core.pyx":3114
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')             # <<<<<<<<<<<<<<
 * 
 *     cdim = indices.size
 */
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__123, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3114, __pyx_L1_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(0, 3114, __pyx_L1_error)

      /* "cupy/core/core.pyx":3113
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Output shape mismatch')
 * 
 */
    }
  }
  __pyx_L19:;

  /* "cupy/core/core.pyx":3116
 *             raise ValueError('Output shape mismatch')
 * 
 *     cdim = indices.size             # <<<<<<<<<<<<<<
 *     rdim = internal.prod(rshape)
 *     indices = indices.reshape(
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_cdim = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3117
 * 
 *     cdim = indices.size
 *     rdim = internal.prod(rshape)             # <<<<<<<<<<<<<<
 *     indices = indices.reshape(
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 */
  __pyx_t_7 = __pyx_f_4cupy_4core_8internal_prod(__pyx_v_rshape, 0, NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3117, __pyx_L1_error)
  __pyx_v_rdim = __pyx_t_7;

  /* "cupy/core/core.pyx":3118
 *     cdim = indices.size
 *     rdim = internal.prod(rshape)
 *     indices = indices.reshape(             # <<<<<<<<<<<<<<
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if (li == 0 and ri == 0) or (li is None and ri is None):
 */
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);

  /* "cupy/core/core.pyx":3119
 *     rdim = internal.prod(rshape)
 *     indices = indices.reshape(
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))             # <<<<<<<<<<<<<<
 *     if (li == 0 and ri == 0) or (li is None and ri is None):
 *         return _take_kernel_0axis(
 */
  __pyx_t_7 = PyObject_Length(__pyx_v_lshape); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3119, __pyx_L1_error)
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = PyNumber_Multiply(__pyx_tuple__124, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_7 = PyObject_Length(__pyx_v_rshape); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3119, __pyx_L1_error)
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = PyNumber_Multiply(__pyx_tuple__125, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3118, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_8};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3118, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_8};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3118, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3118, __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 = NULL;
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3118, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3120
 *     indices = indices.reshape(
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if (li == 0 and ri == 0) or (li is None and ri is None):             # <<<<<<<<<<<<<<
 *         return _take_kernel_0axis(
 *             a.reduced_view(), indices, rdim, index_range, out)
 */
  __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_v_li, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3120, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3120, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!__pyx_t_4) {
    goto __pyx_L24_next_or;
  } else {
  }
  __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_v_ri, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3120, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3120, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L23_bool_binop_done;
  }
  __pyx_L24_next_or:;
  __pyx_t_4 = (__pyx_v_li == Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L23_bool_binop_done;
  }
  __pyx_t_5 = (__pyx_v_ri == Py_None);
  __pyx_t_4 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L23_bool_binop_done:;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3121
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if (li == 0 and ri == 0) or (li is None and ri is None):
 *         return _take_kernel_0axis(             # <<<<<<<<<<<<<<
 *             a.reduced_view(), indices, rdim, index_range, out)
 *     else:
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));

    /* "cupy/core/core.pyx":3122
 *     if (li == 0 and ri == 0) or (li is None and ri is None):
 *         return _take_kernel_0axis(
 *             a.reduced_view(), indices, rdim, index_range, out)             # <<<<<<<<<<<<<<
 *     else:
 *         return _take_kernel(
 */
    __pyx_t_10 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->reduced_view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_rdim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__take_kernel_0axis);
    __pyx_t_8 = __pyx_v_4cupy_4core_4core__take_kernel_0axis; __pyx_t_1 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_t_10, __pyx_v_indices, __pyx_t_2, __pyx_v_index_range, ((PyObject *)__pyx_v_out)};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3121, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_t_10, __pyx_v_indices, __pyx_t_2, __pyx_v_index_range, ((PyObject *)__pyx_v_out)};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3121, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3121, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_9, __pyx_t_10);
      __Pyx_INCREF(__pyx_v_indices);
      __Pyx_GIVEREF(__pyx_v_indices);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_9, __pyx_v_indices);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_9, __pyx_t_2);
      __Pyx_INCREF(__pyx_v_index_range);
      __Pyx_GIVEREF(__pyx_v_index_range);
      PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_9, __pyx_v_index_range);
      __Pyx_INCREF(((PyObject *)__pyx_v_out));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
      PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_9, ((PyObject *)__pyx_v_out));
      __pyx_t_10 = 0;
      __pyx_t_2 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3121, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3121
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if (li == 0 and ri == 0) or (li is None and ri is None):
 *         return _take_kernel_0axis(             # <<<<<<<<<<<<<<
 *             a.reduced_view(), indices, rdim, index_range, out)
 *     else:
 */
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3121, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3120
 *     indices = indices.reshape(
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if (li == 0 and ri == 0) or (li is None and ri is None):             # <<<<<<<<<<<<<<
 *         return _take_kernel_0axis(
 *             a.reduced_view(), indices, rdim, index_range, out)
 */
  }

  /* "cupy/core/core.pyx":3124
 *             a.reduced_view(), indices, rdim, index_range, out)
 *     else:
 *         return _take_kernel(             # <<<<<<<<<<<<<<
 *             a.reduced_view(), indices, cdim, rdim, adim, index_range, out)
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));

    /* "cupy/core/core.pyx":3125
 *     else:
 *         return _take_kernel(
 *             a.reduced_view(), indices, cdim, rdim, adim, index_range, out)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_8 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->reduced_view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3125, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_rdim); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3125, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_adim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3125, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__take_kernel);
    __pyx_t_10 = __pyx_v_4cupy_4core_4core__take_kernel; __pyx_t_1 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[8] = {__pyx_t_1, __pyx_t_8, __pyx_v_indices, __pyx_v_cdim, __pyx_t_12, __pyx_t_2, __pyx_v_index_range, ((PyObject *)__pyx_v_out)};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3124, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[8] = {__pyx_t_1, __pyx_t_8, __pyx_v_indices, __pyx_v_cdim, __pyx_t_12, __pyx_t_2, __pyx_v_index_range, ((PyObject *)__pyx_v_out)};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3124, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_13 = PyTuple_New(7+__pyx_t_9); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3124, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_9, __pyx_t_8);
      __Pyx_INCREF(__pyx_v_indices);
      __Pyx_GIVEREF(__pyx_v_indices);
      PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_9, __pyx_v_indices);
      __Pyx_INCREF(__pyx_v_cdim);
      __Pyx_GIVEREF(__pyx_v_cdim);
      PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_9, __pyx_v_cdim);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_13, 3+__pyx_t_9, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_13, 4+__pyx_t_9, __pyx_t_2);
      __Pyx_INCREF(__pyx_v_index_range);
      __Pyx_GIVEREF(__pyx_v_index_range);
      PyTuple_SET_ITEM(__pyx_t_13, 5+__pyx_t_9, __pyx_v_index_range);
      __Pyx_INCREF(((PyObject *)__pyx_v_out));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
      PyTuple_SET_ITEM(__pyx_t_13, 6+__pyx_t_9, ((PyObject *)__pyx_v_out));
      __pyx_t_8 = 0;
      __pyx_t_12 = 0;
      __pyx_t_2 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3124, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":3124
 *             a.reduced_view(), indices, rdim, index_range, out)
 *     else:
 *         return _take_kernel(             # <<<<<<<<<<<<<<
 *             a.reduced_view(), indices, cdim, rdim, adim, index_range, out)
 * 
 */
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3124, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":3068
 * 
 * 
 * cpdef ndarray _take(ndarray a, indices, li=None, ri=None, ndarray out=None):             # <<<<<<<<<<<<<<
 *     # When li == ri, this function behaves similarly to np.take
 *     if a.ndim == 0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("cupy.core.core._take", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_lshape);
  __Pyx_XDECREF(__pyx_v_rshape);
  __Pyx_XDECREF(__pyx_v_index_range);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_cdim);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_indices);
  __Pyx_XDECREF(__pyx_v_li);
  __Pyx_XDECREF(__pyx_v_ri);
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_85_take(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_84_take[] = "_take(ndarray a, indices, li=None, ri=None, ndarray out=None) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_85_take(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_indices = 0;
  PyObject *__pyx_v_li = 0;
  PyObject *__pyx_v_ri = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_take (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_indices,&__pyx_n_s_li,&__pyx_n_s_ri,&__pyx_n_s_out,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = (PyObject *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
    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_a)) != 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_indices)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_take", 0, 2, 5, 1); __PYX_ERR(0, 3068, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_li);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ri);
          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_out);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_take") < 0)) __PYX_ERR(0, 3068, __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);
        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_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_indices = values[1];
    __pyx_v_li = values[2];
    __pyx_v_ri = values[3];
    __pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_take", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3068, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._take", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3068, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 3068, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_84_take(__pyx_self, __pyx_v_a, __pyx_v_indices, __pyx_v_li, __pyx_v_ri, __pyx_v_out);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_84_take(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_indices, PyObject *__pyx_v_li, PyObject *__pyx_v_ri, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__take __pyx_t_2;
  __Pyx_RefNannySetupContext("_take", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.li = __pyx_v_li;
  __pyx_t_2.ri = __pyx_v_ri;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__take(__pyx_v_a, __pyx_v_indices, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3068, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._take", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3128
 * 
 * 
 * cpdef _scatter_op_single(ndarray a, ndarray indices, v,             # <<<<<<<<<<<<<<
 *                          Py_ssize_t li=0, Py_ssize_t ri=0, op=''):
 *     # When op == 'update', this function behaves similarly to
 */

static PyObject *__pyx_pw_4cupy_4core_4core_87_scatter_op_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__scatter_op_single(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_indices, PyObject *__pyx_v_v, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__scatter_op_single *__pyx_optional_args) {
  Py_ssize_t __pyx_v_li = ((Py_ssize_t)0);
  Py_ssize_t __pyx_v_ri = ((Py_ssize_t)0);
  PyObject *__pyx_v_op = ((PyObject *)__pyx_kp_s__6);
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_adim;
  Py_ssize_t __pyx_v_cdim;
  Py_ssize_t __pyx_v_rdim;
  PyObject *__pyx_v_a_shape = 0;
  PyObject *__pyx_v_indices_shape = 0;
  PyObject *__pyx_v_lshape = 0;
  PyObject *__pyx_v_rshape = 0;
  PyObject *__pyx_v_v_shape = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_array __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  std::vector<Py_ssize_t>  __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  __Pyx_RefNannySetupContext("_scatter_op_single", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_li = __pyx_optional_args->li;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_ri = __pyx_optional_args->ri;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_op = __pyx_optional_args->op;
        }
      }
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_indices);
  __Pyx_INCREF(__pyx_v_v);

  /* "cupy/core/core.pyx":3143
 *     cdef tuple a_shape, indices_shape, lshape, rshape, v_shape
 * 
 *     ndim = a._shape.size()             # <<<<<<<<<<<<<<
 * 
 *     if ndim == 0:
 */
  __pyx_v_ndim = __pyx_v_a->_shape.size();

  /* "cupy/core/core.pyx":3145
 *     ndim = a._shape.size()
 * 
 *     if ndim == 0:             # <<<<<<<<<<<<<<
 *         raise ValueError("requires a.ndim >= 1")
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):
 */
  __pyx_t_1 = ((__pyx_v_ndim == 0) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cupy/core/core.pyx":3146
 * 
 *     if ndim == 0:
 *         raise ValueError("requires a.ndim >= 1")             # <<<<<<<<<<<<<<
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):
 *         raise ValueError('Axis overrun')
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__126, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3146, __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(0, 3146, __pyx_L1_error)

    /* "cupy/core/core.pyx":3145
 *     ndim = a._shape.size()
 * 
 *     if ndim == 0:             # <<<<<<<<<<<<<<
 *         raise ValueError("requires a.ndim >= 1")
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):
 */
  }

  /* "cupy/core/core.pyx":3147
 *     if ndim == 0:
 *         raise ValueError("requires a.ndim >= 1")
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):             # <<<<<<<<<<<<<<
 *         raise ValueError('Axis overrun')
 * 
 */
  __pyx_t_3 = ((-__pyx_v_ndim) <= __pyx_v_li);
  if (__pyx_t_3) {
    __pyx_t_3 = (__pyx_v_li < __pyx_v_ndim);
  }
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_4 = ((-__pyx_v_ndim) <= __pyx_v_ri);
  if (__pyx_t_4) {
    __pyx_t_4 = (__pyx_v_ri < __pyx_v_ndim);
  }
  __pyx_t_3 = (__pyx_t_4 != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L5_bool_binop_done:;
  __pyx_t_3 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "cupy/core/core.pyx":3148
 *         raise ValueError("requires a.ndim >= 1")
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):
 *         raise ValueError('Axis overrun')             # <<<<<<<<<<<<<<
 * 
 *     if not isinstance(v, ndarray):
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__127, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3148, __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(0, 3148, __pyx_L1_error)

    /* "cupy/core/core.pyx":3147
 *     if ndim == 0:
 *         raise ValueError("requires a.ndim >= 1")
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):             # <<<<<<<<<<<<<<
 *         raise ValueError('Axis overrun')
 * 
 */
  }

  /* "cupy/core/core.pyx":3150
 *         raise ValueError('Axis overrun')
 * 
 *     if not isinstance(v, ndarray):             # <<<<<<<<<<<<<<
 *         v = array(v, dtype=a.dtype)
 *     else:
 */
  __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_v, __pyx_ptype_4cupy_4core_4core_ndarray); 
  __pyx_t_1 = ((!(__pyx_t_3 != 0)) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3151
 * 
 *     if not isinstance(v, ndarray):
 *         v = array(v, dtype=a.dtype)             # <<<<<<<<<<<<<<
 *     else:
 *         v = v.astype(a.dtype, copy=False)
 */
    __pyx_t_2 = __pyx_v_a->dtype;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6.__pyx_n = 1;
    __pyx_t_6.dtype = __pyx_t_2;
    __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_v_v, 0, &__pyx_t_6)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3151, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3150
 *         raise ValueError('Axis overrun')
 * 
 *     if not isinstance(v, ndarray):             # <<<<<<<<<<<<<<
 *         v = array(v, dtype=a.dtype)
 *     else:
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":3153
 *         v = array(v, dtype=a.dtype)
 *     else:
 *         v = v.astype(a.dtype, copy=False)             # <<<<<<<<<<<<<<
 * 
 *     a_shape = a.shape
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_v, __pyx_n_s_astype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_a->dtype);
    __Pyx_GIVEREF(__pyx_v_a->dtype);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_a->dtype);
    __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 3153, __pyx_L1_error)
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_8);
    __pyx_t_8 = 0;
  }
  __pyx_L7:;

  /* "cupy/core/core.pyx":3155
 *         v = v.astype(a.dtype, copy=False)
 * 
 *     a_shape = a.shape             # <<<<<<<<<<<<<<
 *     li %= ndim
 *     ri %= ndim
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (!(likely(PyTuple_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_8)->tp_name), 0))) __PYX_ERR(0, 3155, __pyx_L1_error)
  __pyx_v_a_shape = ((PyObject*)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3156
 * 
 *     a_shape = a.shape
 *     li %= ndim             # <<<<<<<<<<<<<<
 *     ri %= ndim
 * 
 */
  if (unlikely(__pyx_v_ndim == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 3156, __pyx_L1_error)
  }
  __pyx_v_li = __Pyx_mod_Py_ssize_t(__pyx_v_li, __pyx_v_ndim);

  /* "cupy/core/core.pyx":3157
 *     a_shape = a.shape
 *     li %= ndim
 *     ri %= ndim             # <<<<<<<<<<<<<<
 * 
 *     lshape = a_shape[:li]
 */
  if (unlikely(__pyx_v_ndim == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 3157, __pyx_L1_error)
  }
  __pyx_v_ri = __Pyx_mod_Py_ssize_t(__pyx_v_ri, __pyx_v_ndim);

  /* "cupy/core/core.pyx":3159
 *     ri %= ndim
 * 
 *     lshape = a_shape[:li]             # <<<<<<<<<<<<<<
 *     rshape = a_shape[ri + 1:]
 *     adim = internal.prod(a_shape[li:ri + 1])
 */
  if (unlikely(__pyx_v_a_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 3159, __pyx_L1_error)
  }
  __pyx_t_8 = __Pyx_PyTuple_GetSlice(__pyx_v_a_shape, 0, __pyx_v_li); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v_lshape = ((PyObject*)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3160
 * 
 *     lshape = a_shape[:li]
 *     rshape = a_shape[ri + 1:]             # <<<<<<<<<<<<<<
 *     adim = internal.prod(a_shape[li:ri + 1])
 * 
 */
  if (unlikely(__pyx_v_a_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 3160, __pyx_L1_error)
  }
  __pyx_t_8 = __Pyx_PyTuple_GetSlice(__pyx_v_a_shape, (__pyx_v_ri + 1), PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v_rshape = ((PyObject*)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3161
 *     lshape = a_shape[:li]
 *     rshape = a_shape[ri + 1:]
 *     adim = internal.prod(a_shape[li:ri + 1])             # <<<<<<<<<<<<<<
 * 
 *     indices_shape = indices.shape
 */
  if (unlikely(__pyx_v_a_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 3161, __pyx_L1_error)
  }
  __pyx_t_8 = __Pyx_PyTuple_GetSlice(__pyx_v_a_shape, __pyx_v_li, (__pyx_v_ri + 1)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __pyx_f_4cupy_4core_8internal_prod(__pyx_t_8, 0, NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3161, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_adim = __pyx_t_9;

  /* "cupy/core/core.pyx":3163
 *     adim = internal.prod(a_shape[li:ri + 1])
 * 
 *     indices_shape = indices.shape             # <<<<<<<<<<<<<<
 *     v_shape = lshape + indices_shape + rshape
 *     v = broadcast_to(v, v_shape)
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_indices), __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (!(likely(PyTuple_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_8)->tp_name), 0))) __PYX_ERR(0, 3163, __pyx_L1_error)
  __pyx_v_indices_shape = ((PyObject*)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3164
 * 
 *     indices_shape = indices.shape
 *     v_shape = lshape + indices_shape + rshape             # <<<<<<<<<<<<<<
 *     v = broadcast_to(v, v_shape)
 * 
 */
  __pyx_t_8 = PyNumber_Add(__pyx_v_lshape, __pyx_v_indices_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = PyNumber_Add(__pyx_t_8, __pyx_v_rshape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_v_shape = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":3165
 *     indices_shape = indices.shape
 *     v_shape = lshape + indices_shape + rshape
 *     v = broadcast_to(v, v_shape)             # <<<<<<<<<<<<<<
 * 
 *     cdim = indices.size
 */
  if (!(likely(((__pyx_v_v) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_v, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3165, __pyx_L1_error)
  __pyx_t_7 = ((PyObject *)__pyx_f_4cupy_4core_4core_broadcast_to(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_v), __pyx_v_v_shape, 0)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":3167
 *     v = broadcast_to(v, v_shape)
 * 
 *     cdim = indices.size             # <<<<<<<<<<<<<<
 *     rdim = internal.prod(rshape)
 *     indices = indices._reshape(
 */
  __pyx_t_9 = __pyx_v_indices->size;
  __pyx_v_cdim = __pyx_t_9;

  /* "cupy/core/core.pyx":3168
 * 
 *     cdim = indices.size
 *     rdim = internal.prod(rshape)             # <<<<<<<<<<<<<<
 *     indices = indices._reshape(
 *         (1,) * len(lshape) + indices_shape + (1,) * len(rshape))
 */
  __pyx_t_9 = __pyx_f_4cupy_4core_8internal_prod(__pyx_v_rshape, 0, NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3168, __pyx_L1_error)
  __pyx_v_rdim = __pyx_t_9;

  /* "cupy/core/core.pyx":3170
 *     rdim = internal.prod(rshape)
 *     indices = indices._reshape(
 *         (1,) * len(lshape) + indices_shape + (1,) * len(rshape))             # <<<<<<<<<<<<<<
 *     indices = broadcast_to(indices, v_shape)
 * 
 */
  __pyx_t_9 = PyTuple_GET_SIZE(__pyx_v_lshape); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3170, __pyx_L1_error)
  __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyNumber_Multiply(__pyx_tuple__128, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyNumber_Add(__pyx_t_8, __pyx_v_indices_shape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_9 = PyTuple_GET_SIZE(__pyx_v_rshape); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3170, __pyx_L1_error)
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = PyNumber_Multiply(__pyx_tuple__129, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyNumber_Add(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_10 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3170, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3169
 *     cdim = indices.size
 *     rdim = internal.prod(rshape)
 *     indices = indices._reshape(             # <<<<<<<<<<<<<<
 *         (1,) * len(lshape) + indices_shape + (1,) * len(rshape))
 *     indices = broadcast_to(indices, v_shape)
 */
  __pyx_t_8 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_indices->__pyx_vtab)->_reshape(__pyx_v_indices, __pyx_t_10, 0)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF_SET(__pyx_v_indices, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8));
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3171
 *     indices = indices._reshape(
 *         (1,) * len(lshape) + indices_shape + (1,) * len(rshape))
 *     indices = broadcast_to(indices, v_shape)             # <<<<<<<<<<<<<<
 * 
 *     if op == 'update':
 */
  __pyx_t_8 = ((PyObject *)__pyx_f_4cupy_4core_4core_broadcast_to(__pyx_v_indices, __pyx_v_v_shape, 0)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF_SET(__pyx_v_indices, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8));
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3173
 *     indices = broadcast_to(indices, v_shape)
 * 
 *     if op == 'update':             # <<<<<<<<<<<<<<
 *         _scatter_update_kernel(
 *             v, indices, cdim, rdim, adim, a.reduced_view())
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_update, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3173, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3175
 *     if op == 'update':
 *         _scatter_update_kernel(
 *             v, indices, cdim, rdim, adim, a.reduced_view())             # <<<<<<<<<<<<<<
 *     elif op == 'add':
 *         # There is constraints on types because atomicAdd() in CUDA 7.5
 */
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_cdim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3175, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_rdim); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3175, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_adim); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3175, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_11 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->reduced_view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3175, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__scatter_update_kernel);
    __pyx_t_12 = __pyx_v_4cupy_4core_4core__scatter_update_kernel; __pyx_t_13 = NULL;
    __pyx_t_14 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_13)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
        __pyx_t_14 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[7] = {__pyx_t_13, __pyx_v_v, ((PyObject *)__pyx_v_indices), __pyx_t_2, __pyx_t_7, __pyx_t_5, __pyx_t_11};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_14, 6+__pyx_t_14); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3174, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[7] = {__pyx_t_13, __pyx_v_v, ((PyObject *)__pyx_v_indices), __pyx_t_2, __pyx_t_7, __pyx_t_5, __pyx_t_11};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_14, 6+__pyx_t_14); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3174, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_15 = PyTuple_New(6+__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      if (__pyx_t_13) {
        __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_13); __pyx_t_13 = NULL;
      }
      __Pyx_INCREF(__pyx_v_v);
      __Pyx_GIVEREF(__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_14, __pyx_v_v);
      __Pyx_INCREF(((PyObject *)__pyx_v_indices));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_indices));
      PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_14, ((PyObject *)__pyx_v_indices));
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_14, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_15, 3+__pyx_t_14, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_15, 4+__pyx_t_14, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_15, 5+__pyx_t_14, __pyx_t_11);
      __pyx_t_2 = 0;
      __pyx_t_7 = 0;
      __pyx_t_5 = 0;
      __pyx_t_11 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_15, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3173
 *     indices = broadcast_to(indices, v_shape)
 * 
 *     if op == 'update':             # <<<<<<<<<<<<<<
 *         _scatter_update_kernel(
 *             v, indices, cdim, rdim, adim, a.reduced_view())
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":3176
 *         _scatter_update_kernel(
 *             v, indices, cdim, rdim, adim, a.reduced_view())
 *     elif op == 'add':             # <<<<<<<<<<<<<<
 *         # There is constraints on types because atomicAdd() in CUDA 7.5
 *         # only supports int32, uint32, uint64, and float32.
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_add, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3176, __pyx_L1_error)
  if (likely(__pyx_t_1)) {

    /* "cupy/core/core.pyx":3179
 *         # There is constraints on types because atomicAdd() in CUDA 7.5
 *         # only supports int32, uint32, uint64, and float32.
 *         if not issubclass(v.dtype.type,             # <<<<<<<<<<<<<<
 *                           (numpy.int32, numpy.float32,
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_v, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3179, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_type); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3179, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3180
 *         # only supports int32, uint32, uint64, and float32.
 *         if not issubclass(v.dtype.type,
 *                           (numpy.int32, numpy.float32,             # <<<<<<<<<<<<<<
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):
 *             raise TypeError(
 */
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3180, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_int32); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3180, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3180, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_float32); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3180, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3181
 *         if not issubclass(v.dtype.type,
 *                           (numpy.int32, numpy.float32,
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'scatter_add only supports int32, float32, uint32, uint64 as '
 */
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3181, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_uint32); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3181, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3181, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_uint64); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3181, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3181, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_ulonglong); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3181, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3180
 *         # only supports int32, uint32, uint64, and float32.
 *         if not issubclass(v.dtype.type,
 *                           (numpy.int32, numpy.float32,             # <<<<<<<<<<<<<<
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):
 *             raise TypeError(
 */
    __pyx_t_8 = PyTuple_New(5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3180, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_t_2);
    __pyx_t_15 = 0;
    __pyx_t_11 = 0;
    __pyx_t_5 = 0;
    __pyx_t_7 = 0;
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3179
 *         # There is constraints on types because atomicAdd() in CUDA 7.5
 *         # only supports int32, uint32, uint64, and float32.
 *         if not issubclass(v.dtype.type,             # <<<<<<<<<<<<<<
 *                           (numpy.int32, numpy.float32,
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):
 */
    __pyx_t_1 = PyObject_IsSubclass(__pyx_t_12, __pyx_t_8); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 3179, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_3 = ((!(__pyx_t_1 != 0)) != 0);
    if (unlikely(__pyx_t_3)) {

      /* "cupy/core/core.pyx":3182
 *                           (numpy.int32, numpy.float32,
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'scatter_add only supports int32, float32, uint32, uint64 as '
 *                 'data type')
 */
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__130, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3182, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(0, 3182, __pyx_L1_error)

      /* "cupy/core/core.pyx":3179
 *         # There is constraints on types because atomicAdd() in CUDA 7.5
 *         # only supports int32, uint32, uint64, and float32.
 *         if not issubclass(v.dtype.type,             # <<<<<<<<<<<<<<
 *                           (numpy.int32, numpy.float32,
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):
 */
    }

    /* "cupy/core/core.pyx":3186
 *                 'data type')
 *         _scatter_add_kernel(
 *             v, indices, cdim, rdim, adim, a.reduced_view())             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError('provided op is not supported')
 */
    __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_cdim); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3186, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_rdim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3186, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_adim); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3186, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->reduced_view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3186, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__scatter_add_kernel);
    __pyx_t_11 = __pyx_v_4cupy_4core_4core__scatter_add_kernel; __pyx_t_15 = NULL;
    __pyx_t_14 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_15)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_15);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
        __pyx_t_14 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[7] = {__pyx_t_15, __pyx_v_v, ((PyObject *)__pyx_v_indices), __pyx_t_12, __pyx_t_2, __pyx_t_7, __pyx_t_5};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_14, 6+__pyx_t_14); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3185, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[7] = {__pyx_t_15, __pyx_v_v, ((PyObject *)__pyx_v_indices), __pyx_t_12, __pyx_t_2, __pyx_t_7, __pyx_t_5};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_14, 6+__pyx_t_14); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3185, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_13 = PyTuple_New(6+__pyx_t_14); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (__pyx_t_15) {
        __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_15); __pyx_t_15 = NULL;
      }
      __Pyx_INCREF(__pyx_v_v);
      __Pyx_GIVEREF(__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_14, __pyx_v_v);
      __Pyx_INCREF(((PyObject *)__pyx_v_indices));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_indices));
      PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_14, ((PyObject *)__pyx_v_indices));
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_14, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_13, 3+__pyx_t_14, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_13, 4+__pyx_t_14, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_13, 5+__pyx_t_14, __pyx_t_5);
      __pyx_t_12 = 0;
      __pyx_t_2 = 0;
      __pyx_t_7 = 0;
      __pyx_t_5 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_13, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3176
 *         _scatter_update_kernel(
 *             v, indices, cdim, rdim, adim, a.reduced_view())
 *     elif op == 'add':             # <<<<<<<<<<<<<<
 *         # There is constraints on types because atomicAdd() in CUDA 7.5
 *         # only supports int32, uint32, uint64, and float32.
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":3188
 *             v, indices, cdim, rdim, adim, a.reduced_view())
 *     else:
 *         raise ValueError('provided op is not supported')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__131, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3188, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_Raise(__pyx_t_8, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __PYX_ERR(0, 3188, __pyx_L1_error)
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":3128
 * 
 * 
 * cpdef _scatter_op_single(ndarray a, ndarray indices, v,             # <<<<<<<<<<<<<<
 *                          Py_ssize_t li=0, Py_ssize_t ri=0, op=''):
 *     # When op == 'update', this function behaves similarly to
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("cupy.core.core._scatter_op_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_a_shape);
  __Pyx_XDECREF(__pyx_v_indices_shape);
  __Pyx_XDECREF(__pyx_v_lshape);
  __Pyx_XDECREF(__pyx_v_rshape);
  __Pyx_XDECREF(__pyx_v_v_shape);
  __Pyx_XDECREF((PyObject *)__pyx_v_indices);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_87_scatter_op_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_86_scatter_op_single[] = "_scatter_op_single(ndarray a, ndarray indices, v, Py_ssize_t li=0, Py_ssize_t ri=0, op='')";
static PyObject *__pyx_pw_4cupy_4core_4core_87_scatter_op_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_indices = 0;
  PyObject *__pyx_v_v = 0;
  Py_ssize_t __pyx_v_li;
  Py_ssize_t __pyx_v_ri;
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_scatter_op_single (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_indices,&__pyx_n_s_v,&__pyx_n_s_li,&__pyx_n_s_ri,&__pyx_n_s_op,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[5] = ((PyObject *)__pyx_kp_s__6);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_a)) != 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_indices)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op_single", 0, 3, 6, 1); __PYX_ERR(0, 3128, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_v)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op_single", 0, 3, 6, 2); __PYX_ERR(0, 3128, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_li);
          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_ri);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_op);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_scatter_op_single") < 0)) __PYX_ERR(0, 3128, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_indices = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_v = values[2];
    if (values[3]) {
      __pyx_v_li = __Pyx_PyIndex_AsSsize_t(values[3]); if (unlikely((__pyx_v_li == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3129, __pyx_L3_error)
    } else {
      __pyx_v_li = ((Py_ssize_t)0);
    }
    if (values[4]) {
      __pyx_v_ri = __Pyx_PyIndex_AsSsize_t(values[4]); if (unlikely((__pyx_v_ri == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3129, __pyx_L3_error)
    } else {
      __pyx_v_ri = ((Py_ssize_t)0);
    }
    __pyx_v_op = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_scatter_op_single", 0, 3, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3128, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._scatter_op_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3128, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_indices), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "indices", 0))) __PYX_ERR(0, 3128, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_86_scatter_op_single(__pyx_self, __pyx_v_a, __pyx_v_indices, __pyx_v_v, __pyx_v_li, __pyx_v_ri, __pyx_v_op);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_86_scatter_op_single(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_indices, PyObject *__pyx_v_v, Py_ssize_t __pyx_v_li, Py_ssize_t __pyx_v_ri, PyObject *__pyx_v_op) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__scatter_op_single __pyx_t_2;
  __Pyx_RefNannySetupContext("_scatter_op_single", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.li = __pyx_v_li;
  __pyx_t_2.ri = __pyx_v_ri;
  __pyx_t_2.op = __pyx_v_op;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__scatter_op_single(__pyx_v_a, __pyx_v_indices, __pyx_v_v, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._scatter_op_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3191
 * 
 * 
 * cpdef _scatter_op_mask_single(ndarray a, ndarray mask, v, Py_ssize_t axis, op):             # <<<<<<<<<<<<<<
 *     cdef ndarray mask_scanned, src
 *     cdef tuple masked_shape
 */

static PyObject *__pyx_pw_4cupy_4core_4core_89_scatter_op_mask_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__scatter_op_mask_single(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, PyObject *__pyx_v_v, Py_ssize_t __pyx_v_axis, PyObject *__pyx_v_op, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask_scanned = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_src = 0;
  PyObject *__pyx_v_masked_shape = 0;
  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)(PyObject *);
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  struct __pyx_opt_args_4cupy_4core_4core_array __pyx_t_10;
  int __pyx_t_11;
  __Pyx_RefNannySetupContext("_scatter_op_mask_single", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_mask);

  /* "cupy/core/core.pyx":3195
 *     cdef tuple masked_shape
 * 
 *     mask, mask_scanned, masked_shape = _prepare_mask_indexing_single(             # <<<<<<<<<<<<<<
 *         a, mask, axis)
 *     if internal.prod(masked_shape) == 0:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__prepare_mask_indexing_single(__pyx_v_a, __pyx_v_mask, __pyx_v_axis, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 3195, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 2; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 3) < 0) __PYX_ERR(0, 3195, __pyx_L1_error)
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 3195, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3195, __pyx_L1_error)
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3195, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 3195, __pyx_L1_error)
  __Pyx_DECREF_SET(__pyx_v_mask, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_v_mask_scanned = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_masked_shape = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3197
 *     mask, mask_scanned, masked_shape = _prepare_mask_indexing_single(
 *         a, mask, axis)
 *     if internal.prod(masked_shape) == 0:             # <<<<<<<<<<<<<<
 *         return
 * 
 */
  __pyx_t_7 = __pyx_f_4cupy_4core_8internal_prod(__pyx_v_masked_shape, 0, NULL); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3197, __pyx_L1_error)
  __pyx_t_8 = ((__pyx_t_7 == 0) != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":3198
 *         a, mask, axis)
 *     if internal.prod(masked_shape) == 0:
 *         return             # <<<<<<<<<<<<<<
 * 
 *     if not isinstance(v, ndarray):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3197
 *     mask, mask_scanned, masked_shape = _prepare_mask_indexing_single(
 *         a, mask, axis)
 *     if internal.prod(masked_shape) == 0:             # <<<<<<<<<<<<<<
 *         return
 * 
 */
  }

  /* "cupy/core/core.pyx":3200
 *         return
 * 
 *     if not isinstance(v, ndarray):             # <<<<<<<<<<<<<<
 *         src = array(v, dtype=a.dtype)
 *     else:
 */
  __pyx_t_8 = __Pyx_TypeCheck(__pyx_v_v, __pyx_ptype_4cupy_4core_4core_ndarray); 
  __pyx_t_9 = ((!(__pyx_t_8 != 0)) != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3201
 * 
 *     if not isinstance(v, ndarray):
 *         src = array(v, dtype=a.dtype)             # <<<<<<<<<<<<<<
 *     else:
 *         src = v
 */
    __pyx_t_1 = __pyx_v_a->dtype;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_10.__pyx_n = 1;
    __pyx_t_10.dtype = __pyx_t_1;
    __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_v_v, 0, &__pyx_t_10)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_src = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3200
 *         return
 * 
 *     if not isinstance(v, ndarray):             # <<<<<<<<<<<<<<
 *         src = array(v, dtype=a.dtype)
 *     else:
 */
    goto __pyx_L6;
  }

  /* "cupy/core/core.pyx":3203
 *         src = array(v, dtype=a.dtype)
 *     else:
 *         src = v             # <<<<<<<<<<<<<<
 *         src = src.astype(a.dtype, copy=False)
 *     # broadcast src to shape determined by the mask
 */
  /*else*/ {
    if (!(likely(((__pyx_v_v) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_v, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3203, __pyx_L1_error)
    __pyx_t_4 = __pyx_v_v;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_v_src = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3204
 *     else:
 *         src = v
 *         src = src.astype(a.dtype, copy=False)             # <<<<<<<<<<<<<<
 *     # broadcast src to shape determined by the mask
 *     src = broadcast_to(src, masked_shape)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_src), __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3204, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3204, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_a->dtype);
    __Pyx_GIVEREF(__pyx_v_a->dtype);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_a->dtype);
    __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3204, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 3204, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3204, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3204, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_src, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
    __pyx_t_2 = 0;
  }
  __pyx_L6:;

  /* "cupy/core/core.pyx":3206
 *         src = src.astype(a.dtype, copy=False)
 *     # broadcast src to shape determined by the mask
 *     src = broadcast_to(src, masked_shape)             # <<<<<<<<<<<<<<
 * 
 *     if op == 'update':
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core_broadcast_to(__pyx_v_src, __pyx_v_masked_shape, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_src, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3208
 *     src = broadcast_to(src, masked_shape)
 * 
 *     if op == 'update':             # <<<<<<<<<<<<<<
 *         _scatter_update_mask_kernel(src, mask, mask_scanned, a)
 *     elif op == 'add':
 */
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_update, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3208, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3209
 * 
 *     if op == 'update':
 *         _scatter_update_mask_kernel(src, mask, mask_scanned, a)             # <<<<<<<<<<<<<<
 *     elif op == 'add':
 *         _scatter_add_mask_kernel(src, mask, mask_scanned, a)
 */
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__scatter_update_mask_kernel);
    __pyx_t_3 = __pyx_v_4cupy_4core_4core__scatter_update_mask_kernel; __pyx_t_1 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[5] = {__pyx_t_1, ((PyObject *)__pyx_v_src), ((PyObject *)__pyx_v_mask), ((PyObject *)__pyx_v_mask_scanned), ((PyObject *)__pyx_v_a)};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3209, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[5] = {__pyx_t_1, ((PyObject *)__pyx_v_src), ((PyObject *)__pyx_v_mask), ((PyObject *)__pyx_v_mask_scanned), ((PyObject *)__pyx_v_a)};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3209, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(4+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3209, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_src));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_src));
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_11, ((PyObject *)__pyx_v_src));
      __Pyx_INCREF(((PyObject *)__pyx_v_mask));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mask));
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_11, ((PyObject *)__pyx_v_mask));
      __Pyx_INCREF(((PyObject *)__pyx_v_mask_scanned));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mask_scanned));
      PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_11, ((PyObject *)__pyx_v_mask_scanned));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
      PyTuple_SET_ITEM(__pyx_t_4, 3+__pyx_t_11, ((PyObject *)__pyx_v_a));
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3209, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3208
 *     src = broadcast_to(src, masked_shape)
 * 
 *     if op == 'update':             # <<<<<<<<<<<<<<
 *         _scatter_update_mask_kernel(src, mask, mask_scanned, a)
 *     elif op == 'add':
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":3210
 *     if op == 'update':
 *         _scatter_update_mask_kernel(src, mask, mask_scanned, a)
 *     elif op == 'add':             # <<<<<<<<<<<<<<
 *         _scatter_add_mask_kernel(src, mask, mask_scanned, a)
 *     else:
 */
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_add, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3210, __pyx_L1_error)
  if (likely(__pyx_t_9)) {

    /* "cupy/core/core.pyx":3211
 *         _scatter_update_mask_kernel(src, mask, mask_scanned, a)
 *     elif op == 'add':
 *         _scatter_add_mask_kernel(src, mask, mask_scanned, a)             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError('provided op is not supported')
 */
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__scatter_add_mask_kernel);
    __pyx_t_3 = __pyx_v_4cupy_4core_4core__scatter_add_mask_kernel; __pyx_t_4 = NULL;
    __pyx_t_11 = 0;
    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_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[5] = {__pyx_t_4, ((PyObject *)__pyx_v_src), ((PyObject *)__pyx_v_mask), ((PyObject *)__pyx_v_mask_scanned), ((PyObject *)__pyx_v_a)};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3211, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[5] = {__pyx_t_4, ((PyObject *)__pyx_v_src), ((PyObject *)__pyx_v_mask), ((PyObject *)__pyx_v_mask_scanned), ((PyObject *)__pyx_v_a)};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3211, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(4+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3211, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_src));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_src));
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_11, ((PyObject *)__pyx_v_src));
      __Pyx_INCREF(((PyObject *)__pyx_v_mask));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mask));
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_11, ((PyObject *)__pyx_v_mask));
      __Pyx_INCREF(((PyObject *)__pyx_v_mask_scanned));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mask_scanned));
      PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_11, ((PyObject *)__pyx_v_mask_scanned));
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
      PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_11, ((PyObject *)__pyx_v_a));
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3211, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3210
 *     if op == 'update':
 *         _scatter_update_mask_kernel(src, mask, mask_scanned, a)
 *     elif op == 'add':             # <<<<<<<<<<<<<<
 *         _scatter_add_mask_kernel(src, mask, mask_scanned, a)
 *     else:
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":3213
 *         _scatter_add_mask_kernel(src, mask, mask_scanned, a)
 *     else:
 *         raise ValueError('provided op is not supported')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__132, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3213, __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(0, 3213, __pyx_L1_error)
  }
  __pyx_L7:;

  /* "cupy/core/core.pyx":3191
 * 
 * 
 * cpdef _scatter_op_mask_single(ndarray a, ndarray mask, v, Py_ssize_t axis, op):             # <<<<<<<<<<<<<<
 *     cdef ndarray mask_scanned, src
 *     cdef tuple masked_shape
 */

  /* 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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core._scatter_op_mask_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mask_scanned);
  __Pyx_XDECREF((PyObject *)__pyx_v_src);
  __Pyx_XDECREF(__pyx_v_masked_shape);
  __Pyx_XDECREF((PyObject *)__pyx_v_mask);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_89_scatter_op_mask_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_88_scatter_op_mask_single[] = "_scatter_op_mask_single(ndarray a, ndarray mask, v, Py_ssize_t axis, op)";
static PyObject *__pyx_pw_4cupy_4core_4core_89_scatter_op_mask_single(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask = 0;
  PyObject *__pyx_v_v = 0;
  Py_ssize_t __pyx_v_axis;
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_scatter_op_mask_single (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_mask,&__pyx_n_s_v,&__pyx_n_s_axis,&__pyx_n_s_op,0};
    PyObject* values[5] = {0,0,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  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_a)) != 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_mask)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op_mask_single", 1, 5, 5, 1); __PYX_ERR(0, 3191, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_v)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op_mask_single", 1, 5, 5, 2); __PYX_ERR(0, 3191, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op_mask_single", 1, 5, 5, 3); __PYX_ERR(0, 3191, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_op)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op_mask_single", 1, 5, 5, 4); __PYX_ERR(0, 3191, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_scatter_op_mask_single") < 0)) __PYX_ERR(0, 3191, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_mask = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_v = values[2];
    __pyx_v_axis = __Pyx_PyIndex_AsSsize_t(values[3]); if (unlikely((__pyx_v_axis == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3191, __pyx_L3_error)
    __pyx_v_op = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_scatter_op_mask_single", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3191, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._scatter_op_mask_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3191, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mask), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "mask", 0))) __PYX_ERR(0, 3191, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_88_scatter_op_mask_single(__pyx_self, __pyx_v_a, __pyx_v_mask, __pyx_v_v, __pyx_v_axis, __pyx_v_op);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_88_scatter_op_mask_single(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mask, PyObject *__pyx_v_v, Py_ssize_t __pyx_v_axis, PyObject *__pyx_v_op) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_scatter_op_mask_single", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__scatter_op_mask_single(__pyx_v_a, __pyx_v_mask, __pyx_v_v, __pyx_v_axis, __pyx_v_op, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._scatter_op_mask_single", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3216
 * 
 * 
 * cpdef _scatter_op(ndarray a, slices, value, op):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, li, ri
 *     cdef ndarray v, x, y, a_interm, reduced_idx
 */

static PyObject *__pyx_pw_4cupy_4core_4core_91_scatter_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__scatter_op(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices, PyObject *__pyx_v_value, PyObject *__pyx_v_op, CYTHON_UNUSED int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_li;
  Py_ssize_t __pyx_v_ri;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a_interm = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_reduced_idx = 0;
  PyObject *__pyx_v_slice_list = 0;
  PyObject *__pyx_v_adv_mask = 0;
  PyObject *__pyx_v_adv_slices = 0;
  PyObject *__pyx_v_advanced = NULL;
  PyObject *__pyx_v_mask_exists = NULL;
  Py_ssize_t __pyx_v_mask_i;
  PyObject *__pyx_v_axis = 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)(PyObject *);
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  struct __pyx_opt_args_4cupy_4core_4core__scatter_op_single __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  size_t __pyx_t_13;
  int __pyx_t_14;
  __Pyx_RefNannySetupContext("_scatter_op", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_a);

  /* "cupy/core/core.pyx":3221
 *     cdef list slice_list, adv_mask, adv_slices
 * 
 *     slice_list, advanced, mask_exists = _prepare_slice_list(             # <<<<<<<<<<<<<<
 *         slices, a._shape.size())
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__prepare_slice_list(__pyx_v_slices, __pyx_v_a->_shape.size(), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 3221, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3221, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3221, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3221, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3221, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 2; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 3) < 0) __PYX_ERR(0, 3221, __pyx_L1_error)
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 3221, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 3221, __pyx_L1_error)
  __pyx_v_slice_list = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_advanced = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_mask_exists = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3224
 *         slices, a._shape.size())
 * 
 *     if mask_exists:             # <<<<<<<<<<<<<<
 *         mask_i = _get_mask_index(slice_list)
 *         _scatter_op_mask_single(a, slice_list[mask_i], value, mask_i, op)
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_mask_exists); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 3224, __pyx_L1_error)
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":3225
 * 
 *     if mask_exists:
 *         mask_i = _get_mask_index(slice_list)             # <<<<<<<<<<<<<<
 *         _scatter_op_mask_single(a, slice_list[mask_i], value, mask_i, op)
 *         return
 */
    __pyx_t_8 = __pyx_f_4cupy_4core_4core__get_mask_index(__pyx_v_slice_list); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3225, __pyx_L1_error)
    __pyx_v_mask_i = __pyx_t_8;

    /* "cupy/core/core.pyx":3226
 *     if mask_exists:
 *         mask_i = _get_mask_index(slice_list)
 *         _scatter_op_mask_single(a, slice_list[mask_i], value, mask_i, op)             # <<<<<<<<<<<<<<
 *         return
 * 
 */
    if (unlikely(__pyx_v_slice_list == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 3226, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_slice_list, __pyx_v_mask_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3226, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3226, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__scatter_op_mask_single(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1), __pyx_v_value, __pyx_v_mask_i, __pyx_v_op, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3226, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3227
 *         mask_i = _get_mask_index(slice_list)
 *         _scatter_op_mask_single(a, slice_list[mask_i], value, mask_i, op)
 *         return             # <<<<<<<<<<<<<<
 * 
 *     if advanced:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3224
 *         slices, a._shape.size())
 * 
 *     if mask_exists:             # <<<<<<<<<<<<<<
 *         mask_i = _get_mask_index(slice_list)
 *         _scatter_op_mask_single(a, slice_list[mask_i], value, mask_i, op)
 */
  }

  /* "cupy/core/core.pyx":3229
 *         return
 * 
 *     if advanced:             # <<<<<<<<<<<<<<
 *         a, adv_slices, adv_mask = _prepare_advanced_indexing(a, slice_list)
 *         if sum(adv_mask) == 1:
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_advanced); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 3229, __pyx_L1_error)
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":3230
 * 
 *     if advanced:
 *         a, adv_slices, adv_mask = _prepare_advanced_indexing(a, slice_list)             # <<<<<<<<<<<<<<
 *         if sum(adv_mask) == 1:
 *             axis = adv_mask.index(True)
 */
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__prepare_advanced_indexing(__pyx_v_a, __pyx_v_slice_list); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3230, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (likely(__pyx_t_4 != Py_None)) {
      PyObject* sequence = __pyx_t_4;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 3230, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); 
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3230, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3230, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3230, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 3230, __pyx_L1_error)
    }
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3230, __pyx_L1_error)
    if (!(likely(PyList_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 3230, __pyx_L1_error)
    if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 3230, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_v_adv_slices = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_v_adv_mask = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3231
 *     if advanced:
 *         a, adv_slices, adv_mask = _prepare_advanced_indexing(a, slice_list)
 *         if sum(adv_mask) == 1:             # <<<<<<<<<<<<<<
 *             axis = adv_mask.index(True)
 *             _scatter_op_single(a, adv_slices[axis], value, axis, axis, op)
 */
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_sum, __pyx_v_adv_mask); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3231, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_4, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3231, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 3231, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":3232
 *         a, adv_slices, adv_mask = _prepare_advanced_indexing(a, slice_list)
 *         if sum(adv_mask) == 1:
 *             axis = adv_mask.index(True)             # <<<<<<<<<<<<<<
 *             _scatter_op_single(a, adv_slices[axis], value, axis, axis, op)
 *             return
 */
      __pyx_t_2 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyList_Type_index, __pyx_v_adv_mask, Py_True); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3232, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_axis = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":3233
 *         if sum(adv_mask) == 1:
 *             axis = adv_mask.index(True)
 *             _scatter_op_single(a, adv_slices[axis], value, axis, axis, op)             # <<<<<<<<<<<<<<
 *             return
 * 
 */
      if (unlikely(__pyx_v_adv_slices == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 3233, __pyx_L1_error)
      }
      __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_adv_slices, __pyx_v_axis); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3233, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3233, __pyx_L1_error)
      __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_v_axis); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3233, __pyx_L1_error)
      __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_axis); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3233, __pyx_L1_error)
      __pyx_t_10.__pyx_n = 3;
      __pyx_t_10.li = __pyx_t_8;
      __pyx_t_10.ri = __pyx_t_9;
      __pyx_t_10.op = __pyx_v_op;
      __pyx_t_4 = __pyx_f_4cupy_4core_4core__scatter_op_single(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2), __pyx_v_value, 0, &__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3233, __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;

      /* "cupy/core/core.pyx":3234
 *             axis = adv_mask.index(True)
 *             _scatter_op_single(a, adv_slices[axis], value, axis, axis, op)
 *             return             # <<<<<<<<<<<<<<
 * 
 *         # scatter_op with multiple integer arrays
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;

      /* "cupy/core/core.pyx":3231
 *     if advanced:
 *         a, adv_slices, adv_mask = _prepare_advanced_indexing(a, slice_list)
 *         if sum(adv_mask) == 1:             # <<<<<<<<<<<<<<
 *             axis = adv_mask.index(True)
 *             _scatter_op_single(a, adv_slices[axis], value, axis, axis, op)
 */
    }

    /* "cupy/core/core.pyx":3238
 *         # scatter_op with multiple integer arrays
 *         a_interm, reduced_idx, li, ri =\
 *             _prepare_multiple_array_indexing(a, adv_slices)             # <<<<<<<<<<<<<<
 *         _scatter_op_single(a_interm, reduced_idx, value, li, ri, op)
 *         return
 */
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__prepare_multiple_array_indexing(__pyx_v_a, __pyx_v_adv_slices, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3238, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 4)) {
        if (size > 4) __Pyx_RaiseTooManyValuesError(4);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 3237, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 3); 
      } else {
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_1 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_5 = PyList_GET_ITEM(sequence, 3); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      #else
      {
        Py_ssize_t i;
        PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_1,&__pyx_t_5};
        for (i=0; i < 4; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 3237, __pyx_L1_error)
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
      }
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_1,&__pyx_t_5};
      __pyx_t_11 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3237, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = Py_TYPE(__pyx_t_11)->tp_iternext;
      for (index=0; index < 4; index++) {
        PyObject* item = __pyx_t_6(__pyx_t_11); if (unlikely(!item)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(item);
        *(temps[index]) = item;
      }
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_11), 4) < 0) __PYX_ERR(0, 3237, __pyx_L1_error)
      __pyx_t_6 = NULL;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L9_unpacking_done;
      __pyx_L8_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_6 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 3237, __pyx_L1_error)
      __pyx_L9_unpacking_done:;
    }

    /* "cupy/core/core.pyx":3237
 * 
 *         # scatter_op with multiple integer arrays
 *         a_interm, reduced_idx, li, ri =\             # <<<<<<<<<<<<<<
 *             _prepare_multiple_array_indexing(a, adv_slices)
 *         _scatter_op_single(a_interm, reduced_idx, value, li, ri, op)
 */
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3237, __pyx_L1_error)
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3237, __pyx_L1_error)
    __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3237, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3237, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_a_interm = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_v_reduced_idx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_v_li = __pyx_t_9;
    __pyx_v_ri = __pyx_t_8;

    /* "cupy/core/core.pyx":3239
 *         a_interm, reduced_idx, li, ri =\
 *             _prepare_multiple_array_indexing(a, adv_slices)
 *         _scatter_op_single(a_interm, reduced_idx, value, li, ri, op)             # <<<<<<<<<<<<<<
 *         return
 * 
 */
    __pyx_t_10.__pyx_n = 3;
    __pyx_t_10.li = __pyx_v_li;
    __pyx_t_10.ri = __pyx_v_ri;
    __pyx_t_10.op = __pyx_v_op;
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__scatter_op_single(__pyx_v_a_interm, __pyx_v_reduced_idx, __pyx_v_value, 0, &__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3239, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3240
 *             _prepare_multiple_array_indexing(a, adv_slices)
 *         _scatter_op_single(a_interm, reduced_idx, value, li, ri, op)
 *         return             # <<<<<<<<<<<<<<
 * 
 *     y = _simple_getitem(a, slice_list)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3229
 *         return
 * 
 *     if advanced:             # <<<<<<<<<<<<<<
 *         a, adv_slices, adv_mask = _prepare_advanced_indexing(a, slice_list)
 *         if sum(adv_mask) == 1:
 */
  }

  /* "cupy/core/core.pyx":3242
 *         return
 * 
 *     y = _simple_getitem(a, slice_list)             # <<<<<<<<<<<<<<
 *     if op == 'update':
 *         if not isinstance(value, ndarray):
 */
  __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core__simple_getitem(__pyx_v_a, __pyx_v_slice_list)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3243
 * 
 *     y = _simple_getitem(a, slice_list)
 *     if op == 'update':             # <<<<<<<<<<<<<<
 *         if not isinstance(value, ndarray):
 *             y.fill(value)
 */
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_update, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 3243, __pyx_L1_error)
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":3244
 *     y = _simple_getitem(a, slice_list)
 *     if op == 'update':
 *         if not isinstance(value, ndarray):             # <<<<<<<<<<<<<<
 *             y.fill(value)
 *             return
 */
    __pyx_t_7 = __Pyx_TypeCheck(__pyx_v_value, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_12 = ((!(__pyx_t_7 != 0)) != 0);
    if (__pyx_t_12) {

      /* "cupy/core/core.pyx":3245
 *     if op == 'update':
 *         if not isinstance(value, ndarray):
 *             y.fill(value)             # <<<<<<<<<<<<<<
 *             return
 *         x = value
 */
      __pyx_t_4 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_y->__pyx_vtab)->fill(__pyx_v_y, __pyx_v_value, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3245, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":3246
 *         if not isinstance(value, ndarray):
 *             y.fill(value)
 *             return             # <<<<<<<<<<<<<<
 *         x = value
 *         if (internal.vector_equal(y._shape, x._shape) and
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;

      /* "cupy/core/core.pyx":3244
 *     y = _simple_getitem(a, slice_list)
 *     if op == 'update':
 *         if not isinstance(value, ndarray):             # <<<<<<<<<<<<<<
 *             y.fill(value)
 *             return
 */
    }

    /* "cupy/core/core.pyx":3247
 *             y.fill(value)
 *             return
 *         x = value             # <<<<<<<<<<<<<<
 *         if (internal.vector_equal(y._shape, x._shape) and
 *                 internal.vector_equal(y._strides, x._strides)):
 */
    if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3247, __pyx_L1_error)
    __pyx_t_4 = __pyx_v_value;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3248
 *             return
 *         x = value
 *         if (internal.vector_equal(y._shape, x._shape) and             # <<<<<<<<<<<<<<
 *                 internal.vector_equal(y._strides, x._strides)):
 *             if y.data.ptr == x.data.ptr:
 */
    __pyx_t_7 = (__pyx_f_4cupy_4core_8internal_vector_equal(__pyx_v_y->_shape, __pyx_v_x->_shape, 0) != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_12 = __pyx_t_7;
      goto __pyx_L13_bool_binop_done;
    }

    /* "cupy/core/core.pyx":3249
 *         x = value
 *         if (internal.vector_equal(y._shape, x._shape) and
 *                 internal.vector_equal(y._strides, x._strides)):             # <<<<<<<<<<<<<<
 *             if y.data.ptr == x.data.ptr:
 *                 return  # Skip since x and y are the same array
 */
    __pyx_t_7 = (__pyx_f_4cupy_4core_8internal_vector_equal(__pyx_v_y->_strides, __pyx_v_x->_strides, 0) != 0);
    __pyx_t_12 = __pyx_t_7;
    __pyx_L13_bool_binop_done:;

    /* "cupy/core/core.pyx":3248
 *             return
 *         x = value
 *         if (internal.vector_equal(y._shape, x._shape) and             # <<<<<<<<<<<<<<
 *                 internal.vector_equal(y._strides, x._strides)):
 *             if y.data.ptr == x.data.ptr:
 */
    if (__pyx_t_12) {

      /* "cupy/core/core.pyx":3250
 *         if (internal.vector_equal(y._shape, x._shape) and
 *                 internal.vector_equal(y._strides, x._strides)):
 *             if y.data.ptr == x.data.ptr:             # <<<<<<<<<<<<<<
 *                 return  # Skip since x and y are the same array
 *             elif y._c_contiguous and x.dtype == y.dtype:
 */
      __pyx_t_12 = ((__pyx_v_y->data->ptr == __pyx_v_x->data->ptr) != 0);
      if (__pyx_t_12) {

        /* "cupy/core/core.pyx":3251
 *                 internal.vector_equal(y._strides, x._strides)):
 *             if y.data.ptr == x.data.ptr:
 *                 return  # Skip since x and y are the same array             # <<<<<<<<<<<<<<
 *             elif y._c_contiguous and x.dtype == y.dtype:
 *                 y.data.copy_from_device_async(x.data, x.nbytes)
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L0;

        /* "cupy/core/core.pyx":3250
 *         if (internal.vector_equal(y._shape, x._shape) and
 *                 internal.vector_equal(y._strides, x._strides)):
 *             if y.data.ptr == x.data.ptr:             # <<<<<<<<<<<<<<
 *                 return  # Skip since x and y are the same array
 *             elif y._c_contiguous and x.dtype == y.dtype:
 */
      }

      /* "cupy/core/core.pyx":3252
 *             if y.data.ptr == x.data.ptr:
 *                 return  # Skip since x and y are the same array
 *             elif y._c_contiguous and x.dtype == y.dtype:             # <<<<<<<<<<<<<<
 *                 y.data.copy_from_device_async(x.data, x.nbytes)
 *                 return
 */
      __pyx_t_7 = (__pyx_v_y->_c_contiguous != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_12 = __pyx_t_7;
        goto __pyx_L16_bool_binop_done;
      }
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_x->dtype, __pyx_v_y->dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3252, __pyx_L1_error)
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 3252, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_12 = __pyx_t_7;
      __pyx_L16_bool_binop_done:;
      if (__pyx_t_12) {

        /* "cupy/core/core.pyx":3253
 *                 return  # Skip since x and y are the same array
 *             elif y._c_contiguous and x.dtype == y.dtype:
 *                 y.data.copy_from_device_async(x.data, x.nbytes)             # <<<<<<<<<<<<<<
 *                 return
 *         elementwise_copy(x, y)
 */
        __pyx_t_4 = ((PyObject *)__pyx_v_x->data);
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3253, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_13 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_13 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3253, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_y->data->__pyx_vtab)->copy_from_device_async(__pyx_v_y->data, ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_4), __pyx_t_13, 0, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3253, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "cupy/core/core.pyx":3254
 *             elif y._c_contiguous and x.dtype == y.dtype:
 *                 y.data.copy_from_device_async(x.data, x.nbytes)
 *                 return             # <<<<<<<<<<<<<<
 *         elementwise_copy(x, y)
 *         return
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L0;

        /* "cupy/core/core.pyx":3252
 *             if y.data.ptr == x.data.ptr:
 *                 return  # Skip since x and y are the same array
 *             elif y._c_contiguous and x.dtype == y.dtype:             # <<<<<<<<<<<<<<
 *                 y.data.copy_from_device_async(x.data, x.nbytes)
 *                 return
 */
      }

      /* "cupy/core/core.pyx":3248
 *             return
 *         x = value
 *         if (internal.vector_equal(y._shape, x._shape) and             # <<<<<<<<<<<<<<
 *                 internal.vector_equal(y._strides, x._strides)):
 *             if y.data.ptr == x.data.ptr:
 */
    }

    /* "cupy/core/core.pyx":3255
 *                 y.data.copy_from_device_async(x.data, x.nbytes)
 *                 return
 *         elementwise_copy(x, y)             # <<<<<<<<<<<<<<
 *         return
 *     if op == 'add':
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3255, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = NULL;
    __pyx_t_14 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_14 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y)};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3255, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y)};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3255, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3255, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_x));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_x));
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_14, ((PyObject *)__pyx_v_x));
      __Pyx_INCREF(((PyObject *)__pyx_v_y));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_y));
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_14, ((PyObject *)__pyx_v_y));
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3255, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3256
 *                 return
 *         elementwise_copy(x, y)
 *         return             # <<<<<<<<<<<<<<
 *     if op == 'add':
 *         add(y, value, y)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3243
 * 
 *     y = _simple_getitem(a, slice_list)
 *     if op == 'update':             # <<<<<<<<<<<<<<
 *         if not isinstance(value, ndarray):
 *             y.fill(value)
 */
  }

  /* "cupy/core/core.pyx":3257
 *         elementwise_copy(x, y)
 *         return
 *     if op == 'add':             # <<<<<<<<<<<<<<
 *         add(y, value, y)
 *         return
 */
  __pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_add, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 3257, __pyx_L1_error)
  if (__pyx_t_12) {

    /* "cupy/core/core.pyx":3258
 *         return
 *     if op == 'add':
 *         add(y, value, y)             # <<<<<<<<<<<<<<
 *         return
 *     raise ValueError('this op is not supported')
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_add); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3258, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = NULL;
    __pyx_t_14 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_14 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_y), __pyx_v_value, ((PyObject *)__pyx_v_y)};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_14, 3+__pyx_t_14); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3258, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_3, ((PyObject *)__pyx_v_y), __pyx_v_value, ((PyObject *)__pyx_v_y)};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_14, 3+__pyx_t_14); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3258, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(3+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3258, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_y));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_y));
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_14, ((PyObject *)__pyx_v_y));
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_14, __pyx_v_value);
      __Pyx_INCREF(((PyObject *)__pyx_v_y));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_y));
      PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_14, ((PyObject *)__pyx_v_y));
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3258, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3259
 *     if op == 'add':
 *         add(y, value, y)
 *         return             # <<<<<<<<<<<<<<
 *     raise ValueError('this op is not supported')
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3257
 *         elementwise_copy(x, y)
 *         return
 *     if op == 'add':             # <<<<<<<<<<<<<<
 *         add(y, value, y)
 *         return
 */
  }

  /* "cupy/core/core.pyx":3260
 *         add(y, value, y)
 *         return
 *     raise ValueError('this op is not supported')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__133, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3260, __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(0, 3260, __pyx_L1_error)

  /* "cupy/core/core.pyx":3216
 * 
 * 
 * cpdef _scatter_op(ndarray a, slices, value, op):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, li, ri
 *     cdef ndarray v, x, y, a_interm, reduced_idx
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core._scatter_op", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_y);
  __Pyx_XDECREF((PyObject *)__pyx_v_a_interm);
  __Pyx_XDECREF((PyObject *)__pyx_v_reduced_idx);
  __Pyx_XDECREF(__pyx_v_slice_list);
  __Pyx_XDECREF(__pyx_v_adv_mask);
  __Pyx_XDECREF(__pyx_v_adv_slices);
  __Pyx_XDECREF(__pyx_v_advanced);
  __Pyx_XDECREF(__pyx_v_mask_exists);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_91_scatter_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_90_scatter_op[] = "_scatter_op(ndarray a, slices, value, op)";
static PyObject *__pyx_pw_4cupy_4core_4core_91_scatter_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_slices = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_scatter_op (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_slices,&__pyx_n_s_value,&__pyx_n_s_op,0};
    PyObject* values[4] = {0,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  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_a)) != 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_slices)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op", 1, 4, 4, 1); __PYX_ERR(0, 3216, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op", 1, 4, 4, 2); __PYX_ERR(0, 3216, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_op)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_scatter_op", 1, 4, 4, 3); __PYX_ERR(0, 3216, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_scatter_op") < 0)) __PYX_ERR(0, 3216, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_slices = values[1];
    __pyx_v_value = values[2];
    __pyx_v_op = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_scatter_op", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3216, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._scatter_op", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3216, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_90_scatter_op(__pyx_self, __pyx_v_a, __pyx_v_slices, __pyx_v_value, __pyx_v_op);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_90_scatter_op(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices, PyObject *__pyx_v_value, PyObject *__pyx_v_op) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_scatter_op", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__scatter_op(__pyx_v_a, __pyx_v_slices, __pyx_v_value, __pyx_v_op, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3216, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._scatter_op", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3263
 * 
 * 
 * cpdef ndarray _diagonal(ndarray a, Py_ssize_t offset=0, Py_ssize_t axis1=0,             # <<<<<<<<<<<<<<
 *                         Py_ssize_t axis2=1):
 *     cdef Py_ssize_t ndim = a.ndim
 */

static PyObject *__pyx_pw_4cupy_4core_4core_93_diagonal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__diagonal(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__diagonal *__pyx_optional_args) {
  Py_ssize_t __pyx_v_offset = ((Py_ssize_t)0);
  Py_ssize_t __pyx_v_axis1 = ((Py_ssize_t)0);
  Py_ssize_t __pyx_v_axis2 = ((Py_ssize_t)1);
  Py_ssize_t __pyx_v_ndim;
  Py_ssize_t __pyx_v_min_axis;
  Py_ssize_t __pyx_v_max_axis;
  PyObject *__pyx_v_tr = NULL;
  PyObject *__pyx_v_diag_size = NULL;
  PyObject *__pyx_v_ret_shape = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __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;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  Py_ssize_t __pyx_t_13;
  long __pyx_t_14;
  std::vector<Py_ssize_t>  __pyx_t_15;
  std::vector<Py_ssize_t>  __pyx_t_16;
  __Pyx_RefNannySetupContext("_diagonal", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_offset = __pyx_optional_args->offset;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_axis1 = __pyx_optional_args->axis1;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_axis2 = __pyx_optional_args->axis2;
        }
      }
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_a);

  /* "cupy/core/core.pyx":3265
 * cpdef ndarray _diagonal(ndarray a, Py_ssize_t offset=0, Py_ssize_t axis1=0,
 *                         Py_ssize_t axis2=1):
 *     cdef Py_ssize_t ndim = a.ndim             # <<<<<<<<<<<<<<
 *     if not (-ndim <= axis1 < ndim and -ndim <= axis2 < ndim):
 *         raise ValueError('axis1(={0}) and axis2(={1}) must be within range '
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3265, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3265, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_2;

  /* "cupy/core/core.pyx":3266
 *                         Py_ssize_t axis2=1):
 *     cdef Py_ssize_t ndim = a.ndim
 *     if not (-ndim <= axis1 < ndim and -ndim <= axis2 < ndim):             # <<<<<<<<<<<<<<
 *         raise ValueError('axis1(={0}) and axis2(={1}) must be within range '
 *                          '(ndim={2})'.format(axis1, axis2, ndim))
 */
  __pyx_t_4 = ((-__pyx_v_ndim) <= __pyx_v_axis1);
  if (__pyx_t_4) {
    __pyx_t_4 = (__pyx_v_axis1 < __pyx_v_ndim);
  }
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = ((-__pyx_v_ndim) <= __pyx_v_axis2);
  if (__pyx_t_5) {
    __pyx_t_5 = (__pyx_v_axis2 < __pyx_v_ndim);
  }
  __pyx_t_4 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  __pyx_t_4 = ((!__pyx_t_3) != 0);
  if (unlikely(__pyx_t_4)) {

    /* "cupy/core/core.pyx":3268
 *     if not (-ndim <= axis1 < ndim and -ndim <= axis2 < ndim):
 *         raise ValueError('axis1(={0}) and axis2(={1}) must be within range '
 *                          '(ndim={2})'.format(axis1, axis2, ndim))             # <<<<<<<<<<<<<<
 * 
 *     axis1 %= ndim
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_axis1_0_and_axis2_1_must_be_with, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_axis1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_axis2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_t_7, __pyx_t_8, __pyx_t_9};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3268, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_t_7, __pyx_t_8, __pyx_t_9};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3268, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3268, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_t_9);
      __pyx_t_7 = 0;
      __pyx_t_8 = 0;
      __pyx_t_9 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3268, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":3267
 *     cdef Py_ssize_t ndim = a.ndim
 *     if not (-ndim <= axis1 < ndim and -ndim <= axis2 < ndim):
 *         raise ValueError('axis1(={0}) and axis2(={1}) must be within range '             # <<<<<<<<<<<<<<
 *                          '(ndim={2})'.format(axis1, axis2, ndim))
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3267, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(0, 3267, __pyx_L1_error)

    /* "cupy/core/core.pyx":3266
 *                         Py_ssize_t axis2=1):
 *     cdef Py_ssize_t ndim = a.ndim
 *     if not (-ndim <= axis1 < ndim and -ndim <= axis2 < ndim):             # <<<<<<<<<<<<<<
 *         raise ValueError('axis1(={0}) and axis2(={1}) must be within range '
 *                          '(ndim={2})'.format(axis1, axis2, ndim))
 */
  }

  /* "cupy/core/core.pyx":3270
 *                          '(ndim={2})'.format(axis1, axis2, ndim))
 * 
 *     axis1 %= ndim             # <<<<<<<<<<<<<<
 *     axis2 %= ndim
 *     if axis1 < axis2:
 */
  if (unlikely(__pyx_v_ndim == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 3270, __pyx_L1_error)
  }
  __pyx_v_axis1 = __Pyx_mod_Py_ssize_t(__pyx_v_axis1, __pyx_v_ndim);

  /* "cupy/core/core.pyx":3271
 * 
 *     axis1 %= ndim
 *     axis2 %= ndim             # <<<<<<<<<<<<<<
 *     if axis1 < axis2:
 *         min_axis, max_axis = axis1, axis2
 */
  if (unlikely(__pyx_v_ndim == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 3271, __pyx_L1_error)
  }
  __pyx_v_axis2 = __Pyx_mod_Py_ssize_t(__pyx_v_axis2, __pyx_v_ndim);

  /* "cupy/core/core.pyx":3272
 *     axis1 %= ndim
 *     axis2 %= ndim
 *     if axis1 < axis2:             # <<<<<<<<<<<<<<
 *         min_axis, max_axis = axis1, axis2
 *     else:
 */
  __pyx_t_4 = ((__pyx_v_axis1 < __pyx_v_axis2) != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":3273
 *     axis2 %= ndim
 *     if axis1 < axis2:
 *         min_axis, max_axis = axis1, axis2             # <<<<<<<<<<<<<<
 *     else:
 *         min_axis, max_axis = axis2, axis1
 */
    __pyx_t_2 = __pyx_v_axis1;
    __pyx_t_13 = __pyx_v_axis2;
    __pyx_v_min_axis = __pyx_t_2;
    __pyx_v_max_axis = __pyx_t_13;

    /* "cupy/core/core.pyx":3272
 *     axis1 %= ndim
 *     axis2 %= ndim
 *     if axis1 < axis2:             # <<<<<<<<<<<<<<
 *         min_axis, max_axis = axis1, axis2
 *     else:
 */
    goto __pyx_L6;
  }

  /* "cupy/core/core.pyx":3275
 *         min_axis, max_axis = axis1, axis2
 *     else:
 *         min_axis, max_axis = axis2, axis1             # <<<<<<<<<<<<<<
 * 
 *     tr = list(range(ndim))
 */
  /*else*/ {
    __pyx_t_13 = __pyx_v_axis2;
    __pyx_t_2 = __pyx_v_axis1;
    __pyx_v_min_axis = __pyx_t_13;
    __pyx_v_max_axis = __pyx_t_2;
  }
  __pyx_L6:;

  /* "cupy/core/core.pyx":3277
 *         min_axis, max_axis = axis2, axis1
 * 
 *     tr = list(range(ndim))             # <<<<<<<<<<<<<<
 *     del tr[max_axis]
 *     del tr[min_axis]
 */
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_tr = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3278
 * 
 *     tr = list(range(ndim))
 *     del tr[max_axis]             # <<<<<<<<<<<<<<
 *     del tr[min_axis]
 *     if offset >= 0:
 */
  if (unlikely(__Pyx_DelItemInt(__pyx_v_tr, __pyx_v_max_axis, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 3278, __pyx_L1_error)

  /* "cupy/core/core.pyx":3279
 *     tr = list(range(ndim))
 *     del tr[max_axis]
 *     del tr[min_axis]             # <<<<<<<<<<<<<<
 *     if offset >= 0:
 *         a = a.transpose(tr + [axis1, axis2])
 */
  if (unlikely(__Pyx_DelItemInt(__pyx_v_tr, __pyx_v_min_axis, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 3279, __pyx_L1_error)

  /* "cupy/core/core.pyx":3280
 *     del tr[max_axis]
 *     del tr[min_axis]
 *     if offset >= 0:             # <<<<<<<<<<<<<<
 *         a = a.transpose(tr + [axis1, axis2])
 *     else:
 */
  __pyx_t_4 = ((__pyx_v_offset >= 0) != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":3281
 *     del tr[min_axis]
 *     if offset >= 0:
 *         a = a.transpose(tr + [axis1, axis2])             # <<<<<<<<<<<<<<
 *     else:
 *         a = a.transpose(tr + [axis2, axis1])
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_axis1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_axis2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_12);
    PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_9);
    PyList_SET_ITEM(__pyx_t_8, 1, __pyx_t_9);
    __pyx_t_12 = 0;
    __pyx_t_9 = 0;
    __pyx_t_9 = PyNumber_Add(__pyx_v_tr, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3281, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_9};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3281, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_9};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3281, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3281, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3281, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3281, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6));
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":3280
 *     del tr[max_axis]
 *     del tr[min_axis]
 *     if offset >= 0:             # <<<<<<<<<<<<<<
 *         a = a.transpose(tr + [axis1, axis2])
 *     else:
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":3283
 *         a = a.transpose(tr + [axis1, axis2])
 *     else:
 *         a = a.transpose(tr + [axis2, axis1])             # <<<<<<<<<<<<<<
 *         offset = -offset
 * 
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_axis2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_axis1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_12);
    PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_9);
    PyList_SET_ITEM(__pyx_t_8, 1, __pyx_t_9);
    __pyx_t_12 = 0;
    __pyx_t_9 = 0;
    __pyx_t_9 = PyNumber_Add(__pyx_v_tr, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3283, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_9};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3283, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_9};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3283, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3283, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3283, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3283, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6));
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":3284
 *     else:
 *         a = a.transpose(tr + [axis2, axis1])
 *         offset = -offset             # <<<<<<<<<<<<<<
 * 
 *     diag_size = max(0, min(a.shape[-2], a.shape[-1] - offset))
 */
    __pyx_v_offset = (-__pyx_v_offset);
  }
  __pyx_L7:;

  /* "cupy/core/core.pyx":3286
 *         offset = -offset
 * 
 *     diag_size = max(0, min(a.shape[-2], a.shape[-1] - offset))             # <<<<<<<<<<<<<<
 *     ret_shape = a.shape[:-2] + (diag_size,)
 *     if diag_size == 0:
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_6, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_12 = PyNumber_Subtract(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_6, -2L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_9 = PyObject_RichCompare(__pyx_t_12, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3286, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__pyx_t_4) {
    __Pyx_INCREF(__pyx_t_12);
    __pyx_t_6 = __pyx_t_12;
  } else {
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_6 = __pyx_t_1;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_INCREF(__pyx_t_6);
  __pyx_t_12 = __pyx_t_6;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_14 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = PyObject_RichCompare(__pyx_t_12, __pyx_t_1, Py_GT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__pyx_t_4) {
    __Pyx_INCREF(__pyx_t_12);
    __pyx_t_6 = __pyx_t_12;
  } else {
    __pyx_t_9 = __Pyx_PyInt_From_long(__pyx_t_14); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3286, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_6 = __pyx_t_9;
    __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = __pyx_t_6;
  __Pyx_INCREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_diag_size = __pyx_t_12;
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":3287
 * 
 *     diag_size = max(0, min(a.shape[-2], a.shape[-1] - offset))
 *     ret_shape = a.shape[:-2] + (diag_size,)             # <<<<<<<<<<<<<<
 *     if diag_size == 0:
 *         return ndarray(ret_shape, dtype=a.dtype)
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_t_12, 0, -2L, NULL, NULL, &__pyx_slice__134, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_INCREF(__pyx_v_diag_size);
  __Pyx_GIVEREF(__pyx_v_diag_size);
  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_diag_size);
  __pyx_t_9 = PyNumber_Add(__pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_v_ret_shape = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":3288
 *     diag_size = max(0, min(a.shape[-2], a.shape[-1] - offset))
 *     ret_shape = a.shape[:-2] + (diag_size,)
 *     if diag_size == 0:             # <<<<<<<<<<<<<<
 *         return ndarray(ret_shape, dtype=a.dtype)
 * 
 */
  __pyx_t_9 = __Pyx_PyInt_EqObjC(__pyx_v_diag_size, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 3288, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":3289
 *     ret_shape = a.shape[:-2] + (diag_size,)
 *     if diag_size == 0:
 *         return ndarray(ret_shape, dtype=a.dtype)             # <<<<<<<<<<<<<<
 * 
 *     a = a[..., :diag_size, offset:offset + diag_size]
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3289, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_v_ret_shape);
    __Pyx_GIVEREF(__pyx_v_ret_shape);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_ret_shape);
    __pyx_t_12 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3289, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) __PYX_ERR(0, 3289, __pyx_L1_error)
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3289, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3288
 *     diag_size = max(0, min(a.shape[-2], a.shape[-1] - offset))
 *     ret_shape = a.shape[:-2] + (diag_size,)
 *     if diag_size == 0:             # <<<<<<<<<<<<<<
 *         return ndarray(ret_shape, dtype=a.dtype)
 * 
 */
  }

  /* "cupy/core/core.pyx":3291
 *         return ndarray(ret_shape, dtype=a.dtype)
 * 
 *     a = a[..., :diag_size, offset:offset + diag_size]             # <<<<<<<<<<<<<<
 * 
 *     ret = a.view()
 */
  __pyx_t_6 = PySlice_New(Py_None, __pyx_v_diag_size, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = PyNumber_Add(__pyx_t_9, __pyx_v_diag_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PySlice_New(__pyx_t_12, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(Py_Ellipsis);
  __Pyx_GIVEREF(Py_Ellipsis);
  PyTuple_SET_ITEM(__pyx_t_1, 0, Py_Ellipsis);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_9);
  __pyx_t_6 = 0;
  __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3291, __pyx_L1_error)
  __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_9));
  __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":3293
 *     a = a[..., :diag_size, offset:offset + diag_size]
 * 
 *     ret = a.view()             # <<<<<<<<<<<<<<
 *     ret._set_shape_and_strides(
 *         a.shape[:-2] + (diag_size,),
 */
  __pyx_t_9 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":3295
 *     ret = a.view()
 *     ret._set_shape_and_strides(
 *         a.shape[:-2] + (diag_size,),             # <<<<<<<<<<<<<<
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))
 *     return ret
 */
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_9, 0, -2L, NULL, NULL, &__pyx_slice__135, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_v_diag_size);
  __Pyx_GIVEREF(__pyx_v_diag_size);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_diag_size);
  __pyx_t_6 = PyNumber_Add(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_15 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3295, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3296
 *     ret._set_shape_and_strides(
 *         a.shape[:-2] + (diag_size,),
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = __Pyx_PyObject_GetSlice(__pyx_t_6, 0, -2L, NULL, NULL, &__pyx_slice__136, 0, 1, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_6, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_12 = __Pyx_GetItemInt(__pyx_t_6, -2L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Add(__pyx_t_1, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Add(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_16 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3296, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3294
 * 
 *     ret = a.view()
 *     ret._set_shape_and_strides(             # <<<<<<<<<<<<<<
 *         a.shape[:-2] + (diag_size,),
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))
 */
  __pyx_t_6 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ret->__pyx_vtab)->_set_shape_and_strides(__pyx_v_ret, __pyx_t_15, __pyx_t_16, 0, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3297
 *         a.shape[:-2] + (diag_size,),
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3263
 * 
 * 
 * cpdef ndarray _diagonal(ndarray a, Py_ssize_t offset=0, Py_ssize_t axis1=0,             # <<<<<<<<<<<<<<
 *                         Py_ssize_t axis2=1):
 *     cdef Py_ssize_t ndim = a.ndim
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core._diagonal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_tr);
  __Pyx_XDECREF(__pyx_v_diag_size);
  __Pyx_XDECREF(__pyx_v_ret_shape);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_93_diagonal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_92_diagonal[] = "_diagonal(ndarray a, Py_ssize_t offset=0, Py_ssize_t axis1=0, Py_ssize_t axis2=1) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_93_diagonal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  Py_ssize_t __pyx_v_offset;
  Py_ssize_t __pyx_v_axis1;
  Py_ssize_t __pyx_v_axis2;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_diagonal (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_offset,&__pyx_n_s_axis1,&__pyx_n_s_axis2,0};
    PyObject* values[4] = {0,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  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_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offset);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis1);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis2);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_diagonal") < 0)) __PYX_ERR(0, 3263, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    if (values[1]) {
      __pyx_v_offset = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_offset == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3263, __pyx_L3_error)
    } else {
      __pyx_v_offset = ((Py_ssize_t)0);
    }
    if (values[2]) {
      __pyx_v_axis1 = __Pyx_PyIndex_AsSsize_t(values[2]); if (unlikely((__pyx_v_axis1 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3263, __pyx_L3_error)
    } else {
      __pyx_v_axis1 = ((Py_ssize_t)0);
    }
    if (values[3]) {
      __pyx_v_axis2 = __Pyx_PyIndex_AsSsize_t(values[3]); if (unlikely((__pyx_v_axis2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3264, __pyx_L3_error)
    } else {
      __pyx_v_axis2 = ((Py_ssize_t)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_diagonal", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3263, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._diagonal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3263, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_92_diagonal(__pyx_self, __pyx_v_a, __pyx_v_offset, __pyx_v_axis1, __pyx_v_axis2);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_92_diagonal(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, Py_ssize_t __pyx_v_offset, Py_ssize_t __pyx_v_axis1, Py_ssize_t __pyx_v_axis2) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__diagonal __pyx_t_2;
  __Pyx_RefNannySetupContext("_diagonal", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.offset = __pyx_v_offset;
  __pyx_t_2.axis1 = __pyx_v_axis1;
  __pyx_t_2.axis2 = __pyx_v_axis2;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__diagonal(__pyx_v_a, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._diagonal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3300
 * 
 * 
 * cpdef _prepare_multiple_array_indexing(ndarray a, list slices):             # <<<<<<<<<<<<<<
 *     # slices consist of either slice(None) or ndarray
 *     cdef Py_ssize_t i, p, li, ri, max_index
 */

static PyObject *__pyx_pw_4cupy_4core_4core_95_prepare_multiple_array_indexing(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__prepare_multiple_array_indexing(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices, CYTHON_UNUSED int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_li;
  Py_ssize_t __pyx_v_ri;
  Py_ssize_t __pyx_v_max_index;
  struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v_br = NULL;
  int __pyx_v_do_transpose;
  PyObject *__pyx_v_prev_arr_i = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_transp_a = NULL;
  PyObject *__pyx_v_transp_b = NULL;
  PyObject *__pyx_v_slices_a = NULL;
  PyObject *__pyx_v_slices_b = NULL;
  PyObject *__pyx_v_a_interm_shape = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a_interm = NULL;
  PyObject *__pyx_v_strides = NULL;
  PyObject *__pyx_v_flattened_indexes = NULL;
  PyObject *__pyx_v_stride = NULL;
  PyObject *__pyx_v_a_interm_shape_i = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_concat_shape = NULL;
  PyObject *__pyx_v_reduced_idx = NULL;
  PyObject *__pyx_v_index = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *(*__pyx_t_14)(PyObject *);
  PyObject *__pyx_t_15 = NULL;
  __Pyx_RefNannySetupContext("_prepare_multiple_array_indexing", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF(__pyx_v_slices);

  /* "cupy/core/core.pyx":3306
 *     cdef tuple a_shape
 * 
 *     br = broadcast(*slices)             # <<<<<<<<<<<<<<
 *     slices = list(br.values)
 * 
 */
  __pyx_t_1 = PySequence_Tuple(__pyx_v_slices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_br = ((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3307
 * 
 *     br = broadcast(*slices)
 *     slices = list(br.values)             # <<<<<<<<<<<<<<
 * 
 *     # check if transpose is necessasry
 */
  __pyx_t_2 = PySequence_List(__pyx_v_br->values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_slices, ((PyObject*)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3312
 *     # li:  index of the leftmost array in slices
 *     # ri:  index of the rightmost array in slices
 *     do_transpose = False             # <<<<<<<<<<<<<<
 *     prev_arr_i = None
 *     li = 0
 */
  __pyx_v_do_transpose = 0;

  /* "cupy/core/core.pyx":3313
 *     # ri:  index of the rightmost array in slices
 *     do_transpose = False
 *     prev_arr_i = None             # <<<<<<<<<<<<<<
 *     li = 0
 *     ri = 0
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_prev_arr_i = Py_None;

  /* "cupy/core/core.pyx":3314
 *     do_transpose = False
 *     prev_arr_i = None
 *     li = 0             # <<<<<<<<<<<<<<
 *     ri = 0
 *     for i, s in enumerate(slices):
 */
  __pyx_v_li = 0;

  /* "cupy/core/core.pyx":3315
 *     prev_arr_i = None
 *     li = 0
 *     ri = 0             # <<<<<<<<<<<<<<
 *     for i, s in enumerate(slices):
 *         if isinstance(s, ndarray):
 */
  __pyx_v_ri = 0;

  /* "cupy/core/core.pyx":3316
 *     li = 0
 *     ri = 0
 *     for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *         if isinstance(s, ndarray):
 *             if prev_arr_i is None:
 */
  __pyx_t_3 = 0;
  __pyx_t_2 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= 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_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 3316, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3316, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_v_i = __pyx_t_3;
    __pyx_t_3 = (__pyx_t_3 + 1);

    /* "cupy/core/core.pyx":3317
 *     ri = 0
 *     for i, s in enumerate(slices):
 *         if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *             if prev_arr_i is None:
 *                 prev_arr_i = i
 */
    __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":3318
 *     for i, s in enumerate(slices):
 *         if isinstance(s, ndarray):
 *             if prev_arr_i is None:             # <<<<<<<<<<<<<<
 *                 prev_arr_i = i
 *                 li = i
 */
      __pyx_t_6 = (__pyx_v_prev_arr_i == Py_None);
      __pyx_t_5 = (__pyx_t_6 != 0);
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":3319
 *         if isinstance(s, ndarray):
 *             if prev_arr_i is None:
 *                 prev_arr_i = i             # <<<<<<<<<<<<<<
 *                 li = i
 *             elif prev_arr_i is not None and i - prev_arr_i > 1:
 */
        __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3319, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF_SET(__pyx_v_prev_arr_i, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "cupy/core/core.pyx":3320
 *             if prev_arr_i is None:
 *                 prev_arr_i = i
 *                 li = i             # <<<<<<<<<<<<<<
 *             elif prev_arr_i is not None and i - prev_arr_i > 1:
 *                 do_transpose = True
 */
        __pyx_v_li = __pyx_v_i;

        /* "cupy/core/core.pyx":3318
 *     for i, s in enumerate(slices):
 *         if isinstance(s, ndarray):
 *             if prev_arr_i is None:             # <<<<<<<<<<<<<<
 *                 prev_arr_i = i
 *                 li = i
 */
        goto __pyx_L6;
      }

      /* "cupy/core/core.pyx":3321
 *                 prev_arr_i = i
 *                 li = i
 *             elif prev_arr_i is not None and i - prev_arr_i > 1:             # <<<<<<<<<<<<<<
 *                 do_transpose = True
 *             else:
 */
      __pyx_t_6 = (__pyx_v_prev_arr_i != Py_None);
      __pyx_t_7 = (__pyx_t_6 != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_5 = __pyx_t_7;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = PyNumber_Subtract(__pyx_t_1, __pyx_v_prev_arr_i); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_8, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3321, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 3321, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = __pyx_t_7;
      __pyx_L7_bool_binop_done:;
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":3322
 *                 li = i
 *             elif prev_arr_i is not None and i - prev_arr_i > 1:
 *                 do_transpose = True             # <<<<<<<<<<<<<<
 *             else:
 *                 prev_arr_i = i
 */
        __pyx_v_do_transpose = 1;

        /* "cupy/core/core.pyx":3321
 *                 prev_arr_i = i
 *                 li = i
 *             elif prev_arr_i is not None and i - prev_arr_i > 1:             # <<<<<<<<<<<<<<
 *                 do_transpose = True
 *             else:
 */
        goto __pyx_L6;
      }

      /* "cupy/core/core.pyx":3324
 *                 do_transpose = True
 *             else:
 *                 prev_arr_i = i             # <<<<<<<<<<<<<<
 *                 ri = i
 * 
 */
      /*else*/ {
        __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3324, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF_SET(__pyx_v_prev_arr_i, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "cupy/core/core.pyx":3325
 *             else:
 *                 prev_arr_i = i
 *                 ri = i             # <<<<<<<<<<<<<<
 * 
 *     if do_transpose:
 */
        __pyx_v_ri = __pyx_v_i;
      }
      __pyx_L6:;

      /* "cupy/core/core.pyx":3317
 *     ri = 0
 *     for i, s in enumerate(slices):
 *         if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *             if prev_arr_i is None:
 *                 prev_arr_i = i
 */
    }

    /* "cupy/core/core.pyx":3316
 *     li = 0
 *     ri = 0
 *     for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *         if isinstance(s, ndarray):
 *             if prev_arr_i is None:
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3327
 *                 ri = i
 * 
 *     if do_transpose:             # <<<<<<<<<<<<<<
 *         transp_a = []
 *         transp_b = []
 */
  __pyx_t_5 = (__pyx_v_do_transpose != 0);
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":3328
 * 
 *     if do_transpose:
 *         transp_a = []             # <<<<<<<<<<<<<<
 *         transp_b = []
 *         slices_a = []
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3328, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_transp_a = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3329
 *     if do_transpose:
 *         transp_a = []
 *         transp_b = []             # <<<<<<<<<<<<<<
 *         slices_a = []
 *         slices_b = []
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3329, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_transp_b = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3330
 *         transp_a = []
 *         transp_b = []
 *         slices_a = []             # <<<<<<<<<<<<<<
 *         slices_b = []
 * 
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3330, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_slices_a = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3331
 *         transp_b = []
 *         slices_a = []
 *         slices_b = []             # <<<<<<<<<<<<<<
 * 
 *         for i, s in enumerate(slices):
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3331, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_slices_b = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3333
 *         slices_b = []
 * 
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if isinstance(s, ndarray):
 *                 transp_a.append(i)
 */
    __pyx_t_3 = 0;
    __pyx_t_2 = __pyx_v_slices; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= 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_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 3333, __pyx_L1_error)
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3333, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_v_i = __pyx_t_3;
      __pyx_t_3 = (__pyx_t_3 + 1);

      /* "cupy/core/core.pyx":3334
 * 
 *         for i, s in enumerate(slices):
 *             if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *                 transp_a.append(i)
 *                 slices_a.append(s)
 */
      __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
      __pyx_t_7 = (__pyx_t_5 != 0);
      if (__pyx_t_7) {

        /* "cupy/core/core.pyx":3335
 *         for i, s in enumerate(slices):
 *             if isinstance(s, ndarray):
 *                 transp_a.append(i)             # <<<<<<<<<<<<<<
 *                 slices_a.append(s)
 *             else:
 */
        __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3335, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_transp_a, __pyx_t_1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 3335, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/core/core.pyx":3336
 *             if isinstance(s, ndarray):
 *                 transp_a.append(i)
 *                 slices_a.append(s)             # <<<<<<<<<<<<<<
 *             else:
 *                 transp_b.append(i)
 */
        __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_slices_a, __pyx_v_s); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 3336, __pyx_L1_error)

        /* "cupy/core/core.pyx":3334
 * 
 *         for i, s in enumerate(slices):
 *             if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *                 transp_a.append(i)
 *                 slices_a.append(s)
 */
        goto __pyx_L12;
      }

      /* "cupy/core/core.pyx":3338
 *                 slices_a.append(s)
 *             else:
 *                 transp_b.append(i)             # <<<<<<<<<<<<<<
 *                 slices_b.append(s)
 *         a = a.transpose(*(transp_a + transp_b))
 */
      /*else*/ {
        __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3338, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_transp_b, __pyx_t_1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 3338, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/core/core.pyx":3339
 *             else:
 *                 transp_b.append(i)
 *                 slices_b.append(s)             # <<<<<<<<<<<<<<
 *         a = a.transpose(*(transp_a + transp_b))
 *         slices = slices_a + slices_b
 */
        __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_slices_b, __pyx_v_s); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 3339, __pyx_L1_error)
      }
      __pyx_L12:;

      /* "cupy/core/core.pyx":3333
 *         slices_b = []
 * 
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if isinstance(s, ndarray):
 *                 transp_a.append(i)
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3340
 *                 transp_b.append(i)
 *                 slices_b.append(s)
 *         a = a.transpose(*(transp_a + transp_b))             # <<<<<<<<<<<<<<
 *         slices = slices_a + slices_b
 *         li = 0
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3340, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Add(__pyx_v_transp_a, __pyx_v_transp_b); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3340, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3340, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3340, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3340, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3341
 *                 slices_b.append(s)
 *         a = a.transpose(*(transp_a + transp_b))
 *         slices = slices_a + slices_b             # <<<<<<<<<<<<<<
 *         li = 0
 *         ri = len(transp_a) - 1
 */
    __pyx_t_1 = PyNumber_Add(__pyx_v_slices_a, __pyx_v_slices_b); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3341, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_slices, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3342
 *         a = a.transpose(*(transp_a + transp_b))
 *         slices = slices_a + slices_b
 *         li = 0             # <<<<<<<<<<<<<<
 *         ri = len(transp_a) - 1
 * 
 */
    __pyx_v_li = 0;

    /* "cupy/core/core.pyx":3343
 *         slices = slices_a + slices_b
 *         li = 0
 *         ri = len(transp_a) - 1             # <<<<<<<<<<<<<<
 * 
 *     a_interm_shape = a.shape
 */
    __pyx_t_3 = PyList_GET_SIZE(__pyx_v_transp_a); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3343, __pyx_L1_error)
    __pyx_v_ri = (__pyx_t_3 - 1);

    /* "cupy/core/core.pyx":3327
 *                 ri = i
 * 
 *     if do_transpose:             # <<<<<<<<<<<<<<
 *         transp_a = []
 *         transp_b = []
 */
  }

  /* "cupy/core/core.pyx":3345
 *         ri = len(transp_a) - 1
 * 
 *     a_interm_shape = a.shape             # <<<<<<<<<<<<<<
 *     a_interm = a
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_a_interm_shape = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3346
 * 
 *     a_interm_shape = a.shape
 *     a_interm = a             # <<<<<<<<<<<<<<
 * 
 *     # build the strides
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_a));
  __pyx_v_a_interm = __pyx_v_a;

  /* "cupy/core/core.pyx":3349
 * 
 *     # build the strides
 *     strides = [1]             # <<<<<<<<<<<<<<
 *     for s in a.shape[ri:li:-1]:
 *         strides.insert(0, s * strides[0])
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_1);
  __pyx_v_strides = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3350
 *     # build the strides
 *     strides = [1]
 *     for s in a.shape[ri:li:-1]:             # <<<<<<<<<<<<<<
 *         strides.insert(0, s * strides[0])
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_ri); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_li); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = PySlice_New(__pyx_t_8, __pyx_t_2, __pyx_int_neg_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_10 = __pyx_t_2; __Pyx_INCREF(__pyx_t_10); __pyx_t_3 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3350, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3350, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_10))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_10)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 3350, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_10, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3350, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 3350, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_10, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3350, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_11(__pyx_t_10);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3350, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":3351
 *     strides = [1]
 *     for s in a.shape[ri:li:-1]:
 *         strides.insert(0, s * strides[0])             # <<<<<<<<<<<<<<
 * 
 *     flattened_indexes = []
 */
    __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_strides, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3351, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Multiply(__pyx_v_s, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3351, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_9 = PyList_Insert(__pyx_v_strides, 0, __pyx_t_1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 3351, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3350
 *     # build the strides
 *     strides = [1]
 *     for s in a.shape[ri:li:-1]:             # <<<<<<<<<<<<<<
 *         strides.insert(0, s * strides[0])
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":3353
 *         strides.insert(0, s * strides[0])
 * 
 *     flattened_indexes = []             # <<<<<<<<<<<<<<
 *     for stride, s, a_interm_shape_i in zip(
 *             strides, slices[li:ri + 1], a_interm_shape[li:ri + 1]):
 */
  __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_v_flattened_indexes = __pyx_t_10;
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":3355
 *     flattened_indexes = []
 *     for stride, s, a_interm_shape_i in zip(
 *             strides, slices[li:ri + 1], a_interm_shape[li:ri + 1]):             # <<<<<<<<<<<<<<
 *         max_index = stride * (a_interm_shape_i - 1)
 *         # cast to appropriate dtype if the linearized index can
 */
  __pyx_t_10 = __Pyx_PyList_GetSlice(__pyx_v_slices, __pyx_v_li, (__pyx_v_ri + 1)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_a_interm_shape, __pyx_v_li, (__pyx_v_ri + 1), NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":3354
 * 
 *     flattened_indexes = []
 *     for stride, s, a_interm_shape_i in zip(             # <<<<<<<<<<<<<<
 *             strides, slices[li:ri + 1], a_interm_shape[li:ri + 1]):
 *         max_index = stride * (a_interm_shape_i - 1)
 */
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_strides);
  __Pyx_GIVEREF(__pyx_v_strides);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_strides);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1);
  __pyx_t_10 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3354, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_11 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3354, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_11)) {
      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_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 3354, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3354, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_3 >= 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_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 3354, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3354, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_11(__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, 3354, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 3354, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_12 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_10 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_12 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_12);
      #else
      __pyx_t_10 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3354, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3354, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_12 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3354, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_13 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3354, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext;
      index = 0; __pyx_t_10 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_10)) goto __pyx_L17_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_10);
      index = 1; __pyx_t_8 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_8)) goto __pyx_L17_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_8);
      index = 2; __pyx_t_12 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_12)) goto __pyx_L17_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_12);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 3) < 0) __PYX_ERR(0, 3354, __pyx_L1_error)
      __pyx_t_14 = NULL;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      goto __pyx_L18_unpacking_done;
      __pyx_L17_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_14 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 3354, __pyx_L1_error)
      __pyx_L18_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_stride, __pyx_t_10);
    __pyx_t_10 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_8);
    __pyx_t_8 = 0;
    __Pyx_XDECREF_SET(__pyx_v_a_interm_shape_i, __pyx_t_12);
    __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":3356
 *     for stride, s, a_interm_shape_i in zip(
 *             strides, slices[li:ri + 1], a_interm_shape[li:ri + 1]):
 *         max_index = stride * (a_interm_shape_i - 1)             # <<<<<<<<<<<<<<
 *         # cast to appropriate dtype if the linearized index can
 *         # exceed the range of the original dtype.
 */
    __pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_v_a_interm_shape_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_12 = PyNumber_Multiply(__pyx_v_stride, __pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_12); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3356, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_v_max_index = __pyx_t_4;

    /* "cupy/core/core.pyx":3359
 *         # cast to appropriate dtype if the linearized index can
 *         # exceed the range of the original dtype.
 *         dtype = None             # <<<<<<<<<<<<<<
 *         if max_index >= 2**31 and issubclass(
 *                 s.dtype.type, (numpy.int8, numpy.int16, numpy.int32)):
 */
    __Pyx_INCREF(Py_None);
    __Pyx_XDECREF_SET(__pyx_v_dtype, Py_None);

    /* "cupy/core/core.pyx":3360
 *         # exceed the range of the original dtype.
 *         dtype = None
 *         if max_index >= 2**31 and issubclass(             # <<<<<<<<<<<<<<
 *                 s.dtype.type, (numpy.int8, numpy.int16, numpy.int32)):
 *             dtype = numpy.int64
 */
    __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_max_index); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_12, __pyx_int_2147483648, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3360, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 3360, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_5) {
    } else {
      __pyx_t_7 = __pyx_t_5;
      goto __pyx_L20_bool_binop_done;
    }

    /* "cupy/core/core.pyx":3361
 *         dtype = None
 *         if max_index >= 2**31 and issubclass(
 *                 s.dtype.type, (numpy.int8, numpy.int16, numpy.int32)):             # <<<<<<<<<<<<<<
 *             dtype = numpy.int64
 *         elif max_index >= 2**15 and issubclass(
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_type); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int16); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int32); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_13);
    __pyx_t_8 = 0;
    __pyx_t_10 = 0;
    __pyx_t_13 = 0;

    /* "cupy/core/core.pyx":3360
 *         # exceed the range of the original dtype.
 *         dtype = None
 *         if max_index >= 2**31 and issubclass(             # <<<<<<<<<<<<<<
 *                 s.dtype.type, (numpy.int8, numpy.int16, numpy.int32)):
 *             dtype = numpy.int64
 */
    __pyx_t_5 = PyObject_IsSubclass(__pyx_t_12, __pyx_t_1); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 3360, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = (__pyx_t_5 != 0);
    __pyx_t_7 = __pyx_t_6;
    __pyx_L20_bool_binop_done:;
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":3362
 *         if max_index >= 2**31 and issubclass(
 *                 s.dtype.type, (numpy.int8, numpy.int16, numpy.int32)):
 *             dtype = numpy.int64             # <<<<<<<<<<<<<<
 *         elif max_index >= 2**15 and issubclass(
 *                 s.dtype.type, (numpy.int8, numpy.int16)):
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3362, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int64); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3362, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "cupy/core/core.pyx":3360
 *         # exceed the range of the original dtype.
 *         dtype = None
 *         if max_index >= 2**31 and issubclass(             # <<<<<<<<<<<<<<
 *                 s.dtype.type, (numpy.int8, numpy.int16, numpy.int32)):
 *             dtype = numpy.int64
 */
      goto __pyx_L19;
    }

    /* "cupy/core/core.pyx":3363
 *                 s.dtype.type, (numpy.int8, numpy.int16, numpy.int32)):
 *             dtype = numpy.int64
 *         elif max_index >= 2**15 and issubclass(             # <<<<<<<<<<<<<<
 *                 s.dtype.type, (numpy.int8, numpy.int16)):
 *             dtype = numpy.int32
 */
    __pyx_t_6 = ((__pyx_v_max_index >= 0x8000) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L22_bool_binop_done;
    }

    /* "cupy/core/core.pyx":3364
 *             dtype = numpy.int64
 *         elif max_index >= 2**15 and issubclass(
 *                 s.dtype.type, (numpy.int8, numpy.int16)):             # <<<<<<<<<<<<<<
 *             dtype = numpy.int32
 *         elif max_index >= 2**7 and issubclass(s.dtype.type, numpy.int8):
 */
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_int8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_int16); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_10);
    __pyx_t_13 = 0;
    __pyx_t_10 = 0;

    /* "cupy/core/core.pyx":3363
 *                 s.dtype.type, (numpy.int8, numpy.int16, numpy.int32)):
 *             dtype = numpy.int64
 *         elif max_index >= 2**15 and issubclass(             # <<<<<<<<<<<<<<
 *                 s.dtype.type, (numpy.int8, numpy.int16)):
 *             dtype = numpy.int32
 */
    __pyx_t_6 = PyObject_IsSubclass(__pyx_t_1, __pyx_t_12); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 3363, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_5 = (__pyx_t_6 != 0);
    __pyx_t_7 = __pyx_t_5;
    __pyx_L22_bool_binop_done:;
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":3365
 *         elif max_index >= 2**15 and issubclass(
 *                 s.dtype.type, (numpy.int8, numpy.int16)):
 *             dtype = numpy.int32             # <<<<<<<<<<<<<<
 *         elif max_index >= 2**7 and issubclass(s.dtype.type, numpy.int8):
 *             dtype = numpy.int16
 */
      __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3365, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_int32); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3365, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":3363
 *                 s.dtype.type, (numpy.int8, numpy.int16, numpy.int32)):
 *             dtype = numpy.int64
 *         elif max_index >= 2**15 and issubclass(             # <<<<<<<<<<<<<<
 *                 s.dtype.type, (numpy.int8, numpy.int16)):
 *             dtype = numpy.int32
 */
      goto __pyx_L19;
    }

    /* "cupy/core/core.pyx":3366
 *                 s.dtype.type, (numpy.int8, numpy.int16)):
 *             dtype = numpy.int32
 *         elif max_index >= 2**7 and issubclass(s.dtype.type, numpy.int8):             # <<<<<<<<<<<<<<
 *             dtype = numpy.int16
 * 
 */
    __pyx_t_5 = ((__pyx_v_max_index >= 0x80) != 0);
    if (__pyx_t_5) {
    } else {
      __pyx_t_7 = __pyx_t_5;
      goto __pyx_L24_bool_binop_done;
    }
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_type); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = PyObject_IsSubclass(__pyx_t_12, __pyx_t_10); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 3366, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_6 = (__pyx_t_5 != 0);
    __pyx_t_7 = __pyx_t_6;
    __pyx_L24_bool_binop_done:;
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":3367
 *             dtype = numpy.int32
 *         elif max_index >= 2**7 and issubclass(s.dtype.type, numpy.int8):
 *             dtype = numpy.int16             # <<<<<<<<<<<<<<
 * 
 *         if max_index >= 2**32 and issubclass(
 */
      __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3367, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_int16); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3367, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "cupy/core/core.pyx":3366
 *                 s.dtype.type, (numpy.int8, numpy.int16)):
 *             dtype = numpy.int32
 *         elif max_index >= 2**7 and issubclass(s.dtype.type, numpy.int8):             # <<<<<<<<<<<<<<
 *             dtype = numpy.int16
 * 
 */
    }
    __pyx_L19:;

    /* "cupy/core/core.pyx":3369
 *             dtype = numpy.int16
 * 
 *         if max_index >= 2**32 and issubclass(             # <<<<<<<<<<<<<<
 *                 s.dtype.type, (numpy.uint8, numpy.uint16, numpy.uint32)):
 *             dtype = numpy.uint64
 */
    __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_max_index); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3369, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_10 = PyObject_RichCompare(__pyx_t_12, __pyx_int_4294967296, Py_GE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3369, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 3369, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L27_bool_binop_done;
    }

    /* "cupy/core/core.pyx":3370
 * 
 *         if max_index >= 2**32 and issubclass(
 *                 s.dtype.type, (numpy.uint8, numpy.uint16, numpy.uint32)):             # <<<<<<<<<<<<<<
 *             dtype = numpy.uint64
 *         elif max_index >= 2**16 and issubclass(
 */
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3370, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_type); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3370, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3370, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_uint8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3370, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3370, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_uint16); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3370, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3370, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_uint32); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3370, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3370, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_13);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_8);
    __pyx_t_1 = 0;
    __pyx_t_13 = 0;
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3369
 *             dtype = numpy.int16
 * 
 *         if max_index >= 2**32 and issubclass(             # <<<<<<<<<<<<<<
 *                 s.dtype.type, (numpy.uint8, numpy.uint16, numpy.uint32)):
 *             dtype = numpy.uint64
 */
    __pyx_t_6 = PyObject_IsSubclass(__pyx_t_12, __pyx_t_10); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 3369, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_5 = (__pyx_t_6 != 0);
    __pyx_t_7 = __pyx_t_5;
    __pyx_L27_bool_binop_done:;
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":3371
 *         if max_index >= 2**32 and issubclass(
 *                 s.dtype.type, (numpy.uint8, numpy.uint16, numpy.uint32)):
 *             dtype = numpy.uint64             # <<<<<<<<<<<<<<
 *         elif max_index >= 2**16 and issubclass(
 *                 s.dtype.type, (numpy.uint8, numpy.uint16)):
 */
      __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_uint64); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "cupy/core/core.pyx":3369
 *             dtype = numpy.int16
 * 
 *         if max_index >= 2**32 and issubclass(             # <<<<<<<<<<<<<<
 *                 s.dtype.type, (numpy.uint8, numpy.uint16, numpy.uint32)):
 *             dtype = numpy.uint64
 */
      goto __pyx_L26;
    }

    /* "cupy/core/core.pyx":3372
 *                 s.dtype.type, (numpy.uint8, numpy.uint16, numpy.uint32)):
 *             dtype = numpy.uint64
 *         elif max_index >= 2**16 and issubclass(             # <<<<<<<<<<<<<<
 *                 s.dtype.type, (numpy.uint8, numpy.uint16)):
 *             dtype = numpy.uint32
 */
    __pyx_t_5 = ((__pyx_v_max_index >= 0x10000) != 0);
    if (__pyx_t_5) {
    } else {
      __pyx_t_7 = __pyx_t_5;
      goto __pyx_L29_bool_binop_done;
    }

    /* "cupy/core/core.pyx":3373
 *             dtype = numpy.uint64
 *         elif max_index >= 2**16 and issubclass(
 *                 s.dtype.type, (numpy.uint8, numpy.uint16)):             # <<<<<<<<<<<<<<
 *             dtype = numpy.uint32
 *         elif max_index >= 2**8 and issubclass(s.dtype.type, numpy.uint8):
 */
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_type); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_uint8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_uint16); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_13);
    __pyx_t_8 = 0;
    __pyx_t_13 = 0;

    /* "cupy/core/core.pyx":3372
 *                 s.dtype.type, (numpy.uint8, numpy.uint16, numpy.uint32)):
 *             dtype = numpy.uint64
 *         elif max_index >= 2**16 and issubclass(             # <<<<<<<<<<<<<<
 *                 s.dtype.type, (numpy.uint8, numpy.uint16)):
 *             dtype = numpy.uint32
 */
    __pyx_t_5 = PyObject_IsSubclass(__pyx_t_10, __pyx_t_12); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 3372, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_6 = (__pyx_t_5 != 0);
    __pyx_t_7 = __pyx_t_6;
    __pyx_L29_bool_binop_done:;
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":3374
 *         elif max_index >= 2**16 and issubclass(
 *                 s.dtype.type, (numpy.uint8, numpy.uint16)):
 *             dtype = numpy.uint32             # <<<<<<<<<<<<<<
 *         elif max_index >= 2**8 and issubclass(s.dtype.type, numpy.uint8):
 *             dtype = numpy.uint16
 */
      __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3374, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_uint32); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3374, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_10);
      __pyx_t_10 = 0;

      /* "cupy/core/core.pyx":3372
 *                 s.dtype.type, (numpy.uint8, numpy.uint16, numpy.uint32)):
 *             dtype = numpy.uint64
 *         elif max_index >= 2**16 and issubclass(             # <<<<<<<<<<<<<<
 *                 s.dtype.type, (numpy.uint8, numpy.uint16)):
 *             dtype = numpy.uint32
 */
      goto __pyx_L26;
    }

    /* "cupy/core/core.pyx":3375
 *                 s.dtype.type, (numpy.uint8, numpy.uint16)):
 *             dtype = numpy.uint32
 *         elif max_index >= 2**8 and issubclass(s.dtype.type, numpy.uint8):             # <<<<<<<<<<<<<<
 *             dtype = numpy.uint16
 * 
 */
    __pyx_t_6 = ((__pyx_v_max_index >= 0x100) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L31_bool_binop_done;
    }
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_dtype); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3375, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_type); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3375, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3375, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_uint8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3375, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_6 = PyObject_IsSubclass(__pyx_t_12, __pyx_t_13); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 3375, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_5 = (__pyx_t_6 != 0);
    __pyx_t_7 = __pyx_t_5;
    __pyx_L31_bool_binop_done:;
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":3376
 *             dtype = numpy.uint32
 *         elif max_index >= 2**8 and issubclass(s.dtype.type, numpy.uint8):
 *             dtype = numpy.uint16             # <<<<<<<<<<<<<<
 * 
 *         if dtype is not None:
 */
      __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3376, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_uint16); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3376, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "cupy/core/core.pyx":3375
 *                 s.dtype.type, (numpy.uint8, numpy.uint16)):
 *             dtype = numpy.uint32
 *         elif max_index >= 2**8 and issubclass(s.dtype.type, numpy.uint8):             # <<<<<<<<<<<<<<
 *             dtype = numpy.uint16
 * 
 */
    }
    __pyx_L26:;

    /* "cupy/core/core.pyx":3378
 *             dtype = numpy.uint16
 * 
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             s = s.astype(dtype)
 *         # wrap all out-of-bound indices
 */
    __pyx_t_7 = (__pyx_v_dtype != Py_None);
    __pyx_t_5 = (__pyx_t_7 != 0);
    if (__pyx_t_5) {

      /* "cupy/core/core.pyx":3379
 * 
 *         if dtype is not None:
 *             s = s.astype(dtype)             # <<<<<<<<<<<<<<
 *         # wrap all out-of-bound indices
 *         flattened_indexes.append(stride * (s % a_interm_shape_i))
 */
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_astype); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3379, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_v_dtype); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3379, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_13)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_dtype};
          __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3379, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_12);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_dtype};
          __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3379, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_12);
        } else
        #endif
        {
          __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3379, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_dtype);
          __Pyx_GIVEREF(__pyx_v_dtype);
          PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_dtype);
          __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_8, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3379, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "cupy/core/core.pyx":3378
 *             dtype = numpy.uint16
 * 
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             s = s.astype(dtype)
 *         # wrap all out-of-bound indices
 */
    }

    /* "cupy/core/core.pyx":3381
 *             s = s.astype(dtype)
 *         # wrap all out-of-bound indices
 *         flattened_indexes.append(stride * (s % a_interm_shape_i))             # <<<<<<<<<<<<<<
 * 
 *     # do stack: flattened_indexes = stack(flattened_indexes, axis=0)
 */
    __pyx_t_12 = PyNumber_Remainder(__pyx_v_s, __pyx_v_a_interm_shape_i); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3381, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_13 = PyNumber_Multiply(__pyx_v_stride, __pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3381, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_9 = __Pyx_PyObject_Append(__pyx_v_flattened_indexes, __pyx_t_13); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 3381, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

    /* "cupy/core/core.pyx":3354
 * 
 *     flattened_indexes = []
 *     for stride, s, a_interm_shape_i in zip(             # <<<<<<<<<<<<<<
 *             strides, slices[li:ri + 1], a_interm_shape[li:ri + 1]):
 *         max_index = stride * (a_interm_shape_i - 1)
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3384
 * 
 *     # do stack: flattened_indexes = stack(flattened_indexes, axis=0)
 *     concat_shape = (len(flattened_indexes),) + br.shape             # <<<<<<<<<<<<<<
 *     flattened_indexes = _concatenate(
 *         [index._reshape((1,) + index.shape) for index in flattened_indexes],
 */
  __pyx_t_3 = PyObject_Length(__pyx_v_flattened_indexes); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3384, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(__pyx_t_13, __pyx_v_br->shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_v_concat_shape = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":3386
 *     concat_shape = (len(flattened_indexes),) + br.shape
 *     flattened_indexes = _concatenate(
 *         [index._reshape((1,) + index.shape) for index in flattened_indexes],             # <<<<<<<<<<<<<<
 *         axis=0, shape=concat_shape, dtype=flattened_indexes[0].dtype)
 * 
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_13 = __pyx_v_flattened_indexes; __Pyx_INCREF(__pyx_t_13); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_13)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_12 = PyList_GET_ITEM(__pyx_t_13, __pyx_t_3); __Pyx_INCREF(__pyx_t_12); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 3386, __pyx_L1_error)
    #else
    __pyx_t_12 = PySequence_ITEM(__pyx_t_13, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3386, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_reshape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3386, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_shape); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3386, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_1 = PyNumber_Add(__pyx_tuple__137, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3386, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3386, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_12);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_1};
        __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3386, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_1};
        __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3386, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      {
        __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3386, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_15, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3386, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_12))) __PYX_ERR(0, 3386, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":3387
 *     flattened_indexes = _concatenate(
 *         [index._reshape((1,) + index.shape) for index in flattened_indexes],
 *         axis=0, shape=concat_shape, dtype=flattened_indexes[0].dtype)             # <<<<<<<<<<<<<<
 * 
 *     reduced_idx = _sum_auto_dtype(flattened_indexes, axis=0)
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_concat_shape))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_concat_shape)->tp_name), 0))) __PYX_ERR(0, 3387, __pyx_L1_error)
  __pyx_t_13 = __Pyx_GetItemInt(__pyx_v_flattened_indexes, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_dtype); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":3385
 *     # do stack: flattened_indexes = stack(flattened_indexes, axis=0)
 *     concat_shape = (len(flattened_indexes),) + br.shape
 *     flattened_indexes = _concatenate(             # <<<<<<<<<<<<<<
 *         [index._reshape((1,) + index.shape) for index in flattened_indexes],
 *         axis=0, shape=concat_shape, dtype=flattened_indexes[0].dtype)
 */
  __pyx_t_13 = ((PyObject *)__pyx_f_4cupy_4core_4core__concatenate(((PyObject*)__pyx_t_2), 0, ((PyObject*)__pyx_v_concat_shape), __pyx_t_12, 0)); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF_SET(__pyx_v_flattened_indexes, __pyx_t_13);
  __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":3389
 *         axis=0, shape=concat_shape, dtype=flattened_indexes[0].dtype)
 * 
 *     reduced_idx = _sum_auto_dtype(flattened_indexes, axis=0)             # <<<<<<<<<<<<<<
 * 
 *     return a_interm, reduced_idx, li, ri
 */
  __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_sum_auto_dtype); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_INCREF(__pyx_v_flattened_indexes);
  __Pyx_GIVEREF(__pyx_v_flattened_indexes);
  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_flattened_indexes);
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_int_0) < 0) __PYX_ERR(0, 3389, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_12, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_reduced_idx = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3391
 *     reduced_idx = _sum_auto_dtype(flattened_indexes, axis=0)
 * 
 *     return a_interm, reduced_idx, li, ri             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_li); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_ri); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_12 = PyTuple_New(4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_INCREF(((PyObject *)__pyx_v_a_interm));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_a_interm));
  PyTuple_SET_ITEM(__pyx_t_12, 0, ((PyObject *)__pyx_v_a_interm));
  __Pyx_INCREF(__pyx_v_reduced_idx);
  __Pyx_GIVEREF(__pyx_v_reduced_idx);
  PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_v_reduced_idx);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_12, 3, __pyx_t_2);
  __pyx_t_8 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_12;
  __pyx_t_12 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3300
 * 
 * 
 * cpdef _prepare_multiple_array_indexing(ndarray a, list slices):             # <<<<<<<<<<<<<<
 *     # slices consist of either slice(None) or ndarray
 *     cdef Py_ssize_t i, p, li, ri, max_index
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("cupy.core.core._prepare_multiple_array_indexing", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_br);
  __Pyx_XDECREF(__pyx_v_prev_arr_i);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_transp_a);
  __Pyx_XDECREF(__pyx_v_transp_b);
  __Pyx_XDECREF(__pyx_v_slices_a);
  __Pyx_XDECREF(__pyx_v_slices_b);
  __Pyx_XDECREF(__pyx_v_a_interm_shape);
  __Pyx_XDECREF((PyObject *)__pyx_v_a_interm);
  __Pyx_XDECREF(__pyx_v_strides);
  __Pyx_XDECREF(__pyx_v_flattened_indexes);
  __Pyx_XDECREF(__pyx_v_stride);
  __Pyx_XDECREF(__pyx_v_a_interm_shape_i);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_concat_shape);
  __Pyx_XDECREF(__pyx_v_reduced_idx);
  __Pyx_XDECREF(__pyx_v_index);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_slices);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_95_prepare_multiple_array_indexing(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_94_prepare_multiple_array_indexing[] = "_prepare_multiple_array_indexing(ndarray a, list slices)";
static PyObject *__pyx_pw_4cupy_4core_4core_95_prepare_multiple_array_indexing(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_slices = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_prepare_multiple_array_indexing (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_slices,0};
    PyObject* values[2] = {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  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_a)) != 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_slices)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_prepare_multiple_array_indexing", 1, 2, 2, 1); __PYX_ERR(0, 3300, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_prepare_multiple_array_indexing") < 0)) __PYX_ERR(0, 3300, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_slices = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_prepare_multiple_array_indexing", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3300, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._prepare_multiple_array_indexing", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3300, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slices), (&PyList_Type), 1, "slices", 1))) __PYX_ERR(0, 3300, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_94_prepare_multiple_array_indexing(__pyx_self, __pyx_v_a, __pyx_v_slices);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_94_prepare_multiple_array_indexing(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_prepare_multiple_array_indexing", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__prepare_multiple_array_indexing(__pyx_v_a, __pyx_v_slices, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._prepare_multiple_array_indexing", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3394
 * 
 * 
 * cpdef ndarray _getitem_multiple(ndarray a, list slices):             # <<<<<<<<<<<<<<
 *     cdef ndarray a_interm, reduced_idx, ret, ret_flat
 *     cdef tuple a_interm_shape, kern_input_shape, out_shape
 */

static PyObject *__pyx_pw_4cupy_4core_4core_97_getitem_multiple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__getitem_multiple(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a_interm = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_reduced_idx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret_flat = 0;
  PyObject *__pyx_v_a_interm_shape = 0;
  PyObject *__pyx_v_out_shape = 0;
  int __pyx_v_li;
  int __pyx_v_ri;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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)(PyObject *);
  int __pyx_t_8;
  int __pyx_t_9;
  struct __pyx_opt_args_4cupy_4core_4core__take __pyx_t_10;
  std::vector<Py_ssize_t>  __pyx_t_11;
  __Pyx_RefNannySetupContext("_getitem_multiple", 0);

  /* "cupy/core/core.pyx":3399
 *     cdef int li, ri
 * 
 *     a_interm, reduced_idx, li, ri = _prepare_multiple_array_indexing(a, slices)             # <<<<<<<<<<<<<<
 * 
 *     a_interm_shape = a_interm.shape
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__prepare_multiple_array_indexing(__pyx_v_a, __pyx_v_slices, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 3399, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 3399, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 3399, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 3399, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3399, __pyx_L1_error)
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3399, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3399, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3399, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_a_interm = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_reduced_idx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_li = __pyx_t_8;
  __pyx_v_ri = __pyx_t_9;

  /* "cupy/core/core.pyx":3401
 *     a_interm, reduced_idx, li, ri = _prepare_multiple_array_indexing(a, slices)
 * 
 *     a_interm_shape = a_interm.shape             # <<<<<<<<<<<<<<
 *     out_shape = a_interm_shape[:li] + \
 *         reduced_idx.shape + a_interm_shape[ri + 1:]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a_interm), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 3401, __pyx_L1_error)
  __pyx_v_a_interm_shape = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3402
 * 
 *     a_interm_shape = a_interm.shape
 *     out_shape = a_interm_shape[:li] + \             # <<<<<<<<<<<<<<
 *         reduced_idx.shape + a_interm_shape[ri + 1:]
 *     ret_flat = _take(a_interm, reduced_idx.ravel(), li=li, ri=ri)
 */
  if (unlikely(__pyx_v_a_interm_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 3402, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyTuple_GetSlice(__pyx_v_a_interm_shape, 0, __pyx_v_li); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":3403
 *     a_interm_shape = a_interm.shape
 *     out_shape = a_interm_shape[:li] + \
 *         reduced_idx.shape + a_interm_shape[ri + 1:]             # <<<<<<<<<<<<<<
 *     ret_flat = _take(a_interm, reduced_idx.ravel(), li=li, ri=ri)
 *     ret = ret_flat._reshape(out_shape)
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_reduced_idx), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":3402
 * 
 *     a_interm_shape = a_interm.shape
 *     out_shape = a_interm_shape[:li] + \             # <<<<<<<<<<<<<<
 *         reduced_idx.shape + a_interm_shape[ri + 1:]
 *     ret_flat = _take(a_interm, reduced_idx.ravel(), li=li, ri=ri)
 */
  __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3403
 *     a_interm_shape = a_interm.shape
 *     out_shape = a_interm_shape[:li] + \
 *         reduced_idx.shape + a_interm_shape[ri + 1:]             # <<<<<<<<<<<<<<
 *     ret_flat = _take(a_interm, reduced_idx.ravel(), li=li, ri=ri)
 *     ret = ret_flat._reshape(out_shape)
 */
  if (unlikely(__pyx_v_a_interm_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 3403, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyTuple_GetSlice(__pyx_v_a_interm_shape, (__pyx_v_ri + 1), PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 3403, __pyx_L1_error)
  __pyx_v_out_shape = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3404
 *     out_shape = a_interm_shape[:li] + \
 *         reduced_idx.shape + a_interm_shape[ri + 1:]
 *     ret_flat = _take(a_interm, reduced_idx.ravel(), li=li, ri=ri)             # <<<<<<<<<<<<<<
 *     ret = ret_flat._reshape(out_shape)
 *     return ret
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_reduced_idx->__pyx_vtab)->ravel(__pyx_v_reduced_idx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_li); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_ri); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10.__pyx_n = 2;
  __pyx_t_10.li = __pyx_t_5;
  __pyx_t_10.ri = __pyx_t_4;
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core__take(__pyx_v_a_interm, __pyx_t_1, 0, &__pyx_t_10)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_ret_flat = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3405
 *         reduced_idx.shape + a_interm_shape[ri + 1:]
 *     ret_flat = _take(a_interm, reduced_idx.ravel(), li=li, ri=ri)
 *     ret = ret_flat._reshape(out_shape)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
  __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_out_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3405, __pyx_L1_error)
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ret_flat->__pyx_vtab)->_reshape(__pyx_v_ret_flat, __pyx_t_11, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3405, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3406
 *     ret_flat = _take(a_interm, reduced_idx.ravel(), li=li, ri=ri)
 *     ret = ret_flat._reshape(out_shape)
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3394
 * 
 * 
 * cpdef ndarray _getitem_multiple(ndarray a, list slices):             # <<<<<<<<<<<<<<
 *     cdef ndarray a_interm, reduced_idx, ret, ret_flat
 *     cdef tuple a_interm_shape, kern_input_shape, out_shape
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core._getitem_multiple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a_interm);
  __Pyx_XDECREF((PyObject *)__pyx_v_reduced_idx);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret_flat);
  __Pyx_XDECREF(__pyx_v_a_interm_shape);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_97_getitem_multiple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_96_getitem_multiple[] = "_getitem_multiple(ndarray a, list slices) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_97_getitem_multiple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_slices = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_getitem_multiple (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_slices,0};
    PyObject* values[2] = {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  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_a)) != 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_slices)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_getitem_multiple", 1, 2, 2, 1); __PYX_ERR(0, 3394, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_getitem_multiple") < 0)) __PYX_ERR(0, 3394, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_slices = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_getitem_multiple", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3394, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._getitem_multiple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3394, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slices), (&PyList_Type), 1, "slices", 1))) __PYX_ERR(0, 3394, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_96_getitem_multiple(__pyx_self, __pyx_v_a, __pyx_v_slices);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_96_getitem_multiple(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_slices) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_getitem_multiple", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__getitem_multiple(__pyx_v_a, __pyx_v_slices, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._getitem_multiple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3413
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray dot(ndarray a, ndarray b, ndarray out=None):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t a_ndim, b_ndim, a_axis, b_axis, n, m, k
 *     cdef bint input_a_is_vec, input_b_is_vec
 */

static PyObject *__pyx_pw_4cupy_4core_4core_99dot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_dot(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_dot *__pyx_optional_args) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
  Py_ssize_t __pyx_v_a_ndim;
  Py_ssize_t __pyx_v_b_ndim;
  Py_ssize_t __pyx_v_a_axis;
  Py_ssize_t __pyx_v_b_axis;
  Py_ssize_t __pyx_v_n;
  Py_ssize_t __pyx_v_m;
  Py_ssize_t __pyx_v_k;
  int __pyx_v_input_a_is_vec;
  int __pyx_v_input_b_is_vec;
  std::vector<Py_ssize_t>  __pyx_v_ret_shape;
  std::vector<Py_ssize_t>  __pyx_v_shape;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  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;
  struct __pyx_opt_args_4cupy_4core_4core_rollaxis __pyx_t_9;
  __Pyx_RefNannySetupContext("dot", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_out = __pyx_optional_args->out;
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF((PyObject *)__pyx_v_b);

  /* "cupy/core/core.pyx":3419
 *     cdef vector.vector[Py_ssize_t] shape
 * 
 *     a_ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *     b_ndim = b._shape.size()
 * 
 */
  __pyx_v_a_ndim = __pyx_v_a->_shape.size();

  /* "cupy/core/core.pyx":3420
 * 
 *     a_ndim = a._shape.size()
 *     b_ndim = b._shape.size()             # <<<<<<<<<<<<<<
 * 
 *     if out is not None and numpy.result_type(a.dtype, b.dtype) != out.dtype:
 */
  __pyx_v_b_ndim = __pyx_v_b->_shape.size();

  /* "cupy/core/core.pyx":3422
 *     b_ndim = b._shape.size()
 * 
 *     if out is not None and numpy.result_type(a.dtype, b.dtype) != out.dtype:             # <<<<<<<<<<<<<<
 *         raise ValueError('Not supported dtype combination.')
 * 
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_out) != Py_None);
  __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_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_result_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_v_a->dtype, __pyx_v_b->dtype};
    __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(0, 3422, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_a->dtype, __pyx_v_b->dtype};
    __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(0, 3422, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3422, __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_INCREF(__pyx_v_a->dtype);
    __Pyx_GIVEREF(__pyx_v_a->dtype);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_a->dtype);
    __Pyx_INCREF(__pyx_v_b->dtype);
    __Pyx_GIVEREF(__pyx_v_b->dtype);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_b->dtype);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3422, __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;
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_4, __pyx_v_out->dtype, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3422, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3422, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_1)) {

    /* "cupy/core/core.pyx":3423
 * 
 *     if out is not None and numpy.result_type(a.dtype, b.dtype) != out.dtype:
 *         raise ValueError('Not supported dtype combination.')             # <<<<<<<<<<<<<<
 * 
 *     if a_ndim == 0 or b_ndim == 0:
 */
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__138, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3423, __pyx_L1_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(0, 3423, __pyx_L1_error)

    /* "cupy/core/core.pyx":3422
 *     b_ndim = b._shape.size()
 * 
 *     if out is not None and numpy.result_type(a.dtype, b.dtype) != out.dtype:             # <<<<<<<<<<<<<<
 *         raise ValueError('Not supported dtype combination.')
 * 
 */
  }

  /* "cupy/core/core.pyx":3425
 *         raise ValueError('Not supported dtype combination.')
 * 
 *     if a_ndim == 0 or b_ndim == 0:             # <<<<<<<<<<<<<<
 *         return multiply(a, b, out=out)
 * 
 */
  __pyx_t_3 = ((__pyx_v_a_ndim == 0) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_3 = ((__pyx_v_b_ndim == 0) != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3426
 * 
 *     if a_ndim == 0 or b_ndim == 0:
 *         return multiply(a, b, out=out)             # <<<<<<<<<<<<<<
 * 
 *     input_a_is_vec = a_ndim == 1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_multiply); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3426, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3426, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_a));
    __Pyx_INCREF(((PyObject *)__pyx_v_b));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_b));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_b));
    __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3426, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_out, ((PyObject *)__pyx_v_out)) < 0) __PYX_ERR(0, 3426, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3426, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3426, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3425
 *         raise ValueError('Not supported dtype combination.')
 * 
 *     if a_ndim == 0 or b_ndim == 0:             # <<<<<<<<<<<<<<
 *         return multiply(a, b, out=out)
 * 
 */
  }

  /* "cupy/core/core.pyx":3428
 *         return multiply(a, b, out=out)
 * 
 *     input_a_is_vec = a_ndim == 1             # <<<<<<<<<<<<<<
 *     input_b_is_vec = b_ndim == 1
 *     if input_a_is_vec:
 */
  __pyx_v_input_a_is_vec = (__pyx_v_a_ndim == 1);

  /* "cupy/core/core.pyx":3429
 * 
 *     input_a_is_vec = a_ndim == 1
 *     input_b_is_vec = b_ndim == 1             # <<<<<<<<<<<<<<
 *     if input_a_is_vec:
 *         shape.clear()
 */
  __pyx_v_input_b_is_vec = (__pyx_v_b_ndim == 1);

  /* "cupy/core/core.pyx":3430
 *     input_a_is_vec = a_ndim == 1
 *     input_b_is_vec = b_ndim == 1
 *     if input_a_is_vec:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(1)
 */
  __pyx_t_1 = (__pyx_v_input_a_is_vec != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3431
 *     input_b_is_vec = b_ndim == 1
 *     if input_a_is_vec:
 *         shape.clear()             # <<<<<<<<<<<<<<
 *         shape.push_back(1)
 *         shape.push_back(a.size)
 */
    __pyx_v_shape.clear();

    /* "cupy/core/core.pyx":3432
 *     if input_a_is_vec:
 *         shape.clear()
 *         shape.push_back(1)             # <<<<<<<<<<<<<<
 *         shape.push_back(a.size)
 *         a = a._reshape(shape)
 */
    try {
      __pyx_v_shape.push_back(1);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3432, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3433
 *         shape.clear()
 *         shape.push_back(1)
 *         shape.push_back(a.size)             # <<<<<<<<<<<<<<
 *         a = a._reshape(shape)
 *         a_ndim = 2
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_a->size);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3433, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3434
 *         shape.push_back(1)
 *         shape.push_back(a.size)
 *         a = a._reshape(shape)             # <<<<<<<<<<<<<<
 *         a_ndim = 2
 *     if input_b_is_vec:
 */
    __pyx_t_5 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->_reshape(__pyx_v_a, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3434, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3435
 *         shape.push_back(a.size)
 *         a = a._reshape(shape)
 *         a_ndim = 2             # <<<<<<<<<<<<<<
 *     if input_b_is_vec:
 *         shape.clear()
 */
    __pyx_v_a_ndim = 2;

    /* "cupy/core/core.pyx":3430
 *     input_a_is_vec = a_ndim == 1
 *     input_b_is_vec = b_ndim == 1
 *     if input_a_is_vec:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(1)
 */
  }

  /* "cupy/core/core.pyx":3436
 *         a = a._reshape(shape)
 *         a_ndim = 2
 *     if input_b_is_vec:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(b.size)
 */
  __pyx_t_1 = (__pyx_v_input_b_is_vec != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3437
 *         a_ndim = 2
 *     if input_b_is_vec:
 *         shape.clear()             # <<<<<<<<<<<<<<
 *         shape.push_back(b.size)
 *         shape.push_back(1)
 */
    __pyx_v_shape.clear();

    /* "cupy/core/core.pyx":3438
 *     if input_b_is_vec:
 *         shape.clear()
 *         shape.push_back(b.size)             # <<<<<<<<<<<<<<
 *         shape.push_back(1)
 *         b = b._reshape(shape)
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_b->size);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3438, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3439
 *         shape.clear()
 *         shape.push_back(b.size)
 *         shape.push_back(1)             # <<<<<<<<<<<<<<
 *         b = b._reshape(shape)
 *         b_ndim = 2
 */
    try {
      __pyx_v_shape.push_back(1);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3439, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3440
 *         shape.push_back(b.size)
 *         shape.push_back(1)
 *         b = b._reshape(shape)             # <<<<<<<<<<<<<<
 *         b_ndim = 2
 * 
 */
    __pyx_t_5 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->_reshape(__pyx_v_b, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3440, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3441
 *         shape.push_back(1)
 *         b = b._reshape(shape)
 *         b_ndim = 2             # <<<<<<<<<<<<<<
 * 
 *     a_axis = a_ndim - 1
 */
    __pyx_v_b_ndim = 2;

    /* "cupy/core/core.pyx":3436
 *         a = a._reshape(shape)
 *         a_ndim = 2
 *     if input_b_is_vec:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(b.size)
 */
  }

  /* "cupy/core/core.pyx":3443
 *         b_ndim = 2
 * 
 *     a_axis = a_ndim - 1             # <<<<<<<<<<<<<<
 *     b_axis = b_ndim - 2
 * 
 */
  __pyx_v_a_axis = (__pyx_v_a_ndim - 1);

  /* "cupy/core/core.pyx":3444
 * 
 *     a_axis = a_ndim - 1
 *     b_axis = b_ndim - 2             # <<<<<<<<<<<<<<
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:
 */
  __pyx_v_b_axis = (__pyx_v_b_ndim - 2);

  /* "cupy/core/core.pyx":3446
 *     b_axis = b_ndim - 2
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:             # <<<<<<<<<<<<<<
 *         raise ValueError('Axis dimension mismatch')
 * 
 */
  __pyx_t_1 = (((__pyx_v_a->_shape[__pyx_v_a_axis]) != (__pyx_v_b->_shape[__pyx_v_b_axis])) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cupy/core/core.pyx":3447
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:
 *         raise ValueError('Axis dimension mismatch')             # <<<<<<<<<<<<<<
 * 
 *     if a_axis:
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__139, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3447, __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(0, 3447, __pyx_L1_error)

    /* "cupy/core/core.pyx":3446
 *     b_axis = b_ndim - 2
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:             # <<<<<<<<<<<<<<
 *         raise ValueError('Axis dimension mismatch')
 * 
 */
  }

  /* "cupy/core/core.pyx":3449
 *         raise ValueError('Axis dimension mismatch')
 * 
 *     if a_axis:             # <<<<<<<<<<<<<<
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:
 */
  __pyx_t_1 = (__pyx_v_a_axis != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3450
 * 
 *     if a_axis:
 *         a = rollaxis(a, a_axis, 0)             # <<<<<<<<<<<<<<
 *     if b_axis:
 *         b = rollaxis(b, b_axis, 0)
 */
    __pyx_t_9.__pyx_n = 1;
    __pyx_t_9.start = 0;
    __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_rollaxis(__pyx_v_a, __pyx_v_a_axis, 0, &__pyx_t_9)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3450, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3449
 *         raise ValueError('Axis dimension mismatch')
 * 
 *     if a_axis:             # <<<<<<<<<<<<<<
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:
 */
  }

  /* "cupy/core/core.pyx":3451
 *     if a_axis:
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:             # <<<<<<<<<<<<<<
 *         b = rollaxis(b, b_axis, 0)
 * 
 */
  __pyx_t_1 = (__pyx_v_b_axis != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3452
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:
 *         b = rollaxis(b, b_axis, 0)             # <<<<<<<<<<<<<<
 * 
 *     k = a._shape[0]
 */
    __pyx_t_9.__pyx_n = 1;
    __pyx_t_9.start = 0;
    __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_rollaxis(__pyx_v_b, __pyx_v_b_axis, 0, &__pyx_t_9)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3452, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":3451
 *     if a_axis:
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:             # <<<<<<<<<<<<<<
 *         b = rollaxis(b, b_axis, 0)
 * 
 */
  }

  /* "cupy/core/core.pyx":3454
 *         b = rollaxis(b, b_axis, 0)
 * 
 *     k = a._shape[0]             # <<<<<<<<<<<<<<
 *     if k != 0:
 *         m = b.size // k
 */
  __pyx_v_k = (__pyx_v_a->_shape[0]);

  /* "cupy/core/core.pyx":3455
 * 
 *     k = a._shape[0]
 *     if k != 0:             # <<<<<<<<<<<<<<
 *         m = b.size // k
 *         n = a.size // k
 */
  __pyx_t_1 = ((__pyx_v_k != 0) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3456
 *     k = a._shape[0]
 *     if k != 0:
 *         m = b.size // k             # <<<<<<<<<<<<<<
 *         n = a.size // k
 *     else:
 */
    if (unlikely(__pyx_v_k == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(0, 3456, __pyx_L1_error)
    }
    else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_k == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_b->size))) {
      PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
      __PYX_ERR(0, 3456, __pyx_L1_error)
    }
    __pyx_v_m = __Pyx_div_Py_ssize_t(__pyx_v_b->size, __pyx_v_k);

    /* "cupy/core/core.pyx":3457
 *     if k != 0:
 *         m = b.size // k
 *         n = a.size // k             # <<<<<<<<<<<<<<
 *     else:
 *         # When k==0, the function must return a matrix filled with zero
 */
    if (unlikely(__pyx_v_k == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(0, 3457, __pyx_L1_error)
    }
    else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_k == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_a->size))) {
      PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
      __PYX_ERR(0, 3457, __pyx_L1_error)
    }
    __pyx_v_n = __Pyx_div_Py_ssize_t(__pyx_v_a->size, __pyx_v_k);

    /* "cupy/core/core.pyx":3455
 * 
 *     k = a._shape[0]
 *     if k != 0:             # <<<<<<<<<<<<<<
 *         m = b.size // k
 *         n = a.size // k
 */
    goto __pyx_L14;
  }

  /* "cupy/core/core.pyx":3461
 *         # When k==0, the function must return a matrix filled with zero
 *         # like NumPy.
 *         m = 0             # <<<<<<<<<<<<<<
 *         n = 0
 * 
 */
  /*else*/ {
    __pyx_v_m = 0;

    /* "cupy/core/core.pyx":3462
 *         # like NumPy.
 *         m = 0
 *         n = 0             # <<<<<<<<<<<<<<
 * 
 *     if not input_a_is_vec:
 */
    __pyx_v_n = 0;
  }
  __pyx_L14:;

  /* "cupy/core/core.pyx":3464
 *         n = 0
 * 
 *     if not input_a_is_vec:             # <<<<<<<<<<<<<<
 *         ret_shape.insert(ret_shape.end(), a._shape.begin() + 1, a._shape.end())
 *     if not input_b_is_vec:
 */
  __pyx_t_1 = ((!(__pyx_v_input_a_is_vec != 0)) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3465
 * 
 *     if not input_a_is_vec:
 *         ret_shape.insert(ret_shape.end(), a._shape.begin() + 1, a._shape.end())             # <<<<<<<<<<<<<<
 *     if not input_b_is_vec:
 *         ret_shape.insert(ret_shape.end(), b._shape.begin() + 1, b._shape.end())
 */
    try {
      __pyx_v_ret_shape.insert(__pyx_v_ret_shape.end(), (__pyx_v_a->_shape.begin() + 1), __pyx_v_a->_shape.end());
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3465, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3464
 *         n = 0
 * 
 *     if not input_a_is_vec:             # <<<<<<<<<<<<<<
 *         ret_shape.insert(ret_shape.end(), a._shape.begin() + 1, a._shape.end())
 *     if not input_b_is_vec:
 */
  }

  /* "cupy/core/core.pyx":3466
 *     if not input_a_is_vec:
 *         ret_shape.insert(ret_shape.end(), a._shape.begin() + 1, a._shape.end())
 *     if not input_b_is_vec:             # <<<<<<<<<<<<<<
 *         ret_shape.insert(ret_shape.end(), b._shape.begin() + 1, b._shape.end())
 *     if out is not None:
 */
  __pyx_t_1 = ((!(__pyx_v_input_b_is_vec != 0)) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3467
 *         ret_shape.insert(ret_shape.end(), a._shape.begin() + 1, a._shape.end())
 *     if not input_b_is_vec:
 *         ret_shape.insert(ret_shape.end(), b._shape.begin() + 1, b._shape.end())             # <<<<<<<<<<<<<<
 *     if out is not None:
 *         if k != 0 and out.size != n * m:
 */
    try {
      __pyx_v_ret_shape.insert(__pyx_v_ret_shape.end(), (__pyx_v_b->_shape.begin() + 1), __pyx_v_b->_shape.end());
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3467, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3466
 *     if not input_a_is_vec:
 *         ret_shape.insert(ret_shape.end(), a._shape.begin() + 1, a._shape.end())
 *     if not input_b_is_vec:             # <<<<<<<<<<<<<<
 *         ret_shape.insert(ret_shape.end(), b._shape.begin() + 1, b._shape.end())
 *     if out is not None:
 */
  }

  /* "cupy/core/core.pyx":3468
 *     if not input_b_is_vec:
 *         ret_shape.insert(ret_shape.end(), b._shape.begin() + 1, b._shape.end())
 *     if out is not None:             # <<<<<<<<<<<<<<
 *         if k != 0 and out.size != n * m:
 *             raise ValueError('Output array has an invalid size')
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_out) != Py_None);
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3469
 *         ret_shape.insert(ret_shape.end(), b._shape.begin() + 1, b._shape.end())
 *     if out is not None:
 *         if k != 0 and out.size != n * m:             # <<<<<<<<<<<<<<
 *             raise ValueError('Output array has an invalid size')
 *         if not out._c_contiguous:
 */
    __pyx_t_1 = ((__pyx_v_k != 0) != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_3 = __pyx_t_1;
      goto __pyx_L19_bool_binop_done;
    }
    __pyx_t_1 = ((__pyx_v_out->size != (__pyx_v_n * __pyx_v_m)) != 0);
    __pyx_t_3 = __pyx_t_1;
    __pyx_L19_bool_binop_done:;
    if (unlikely(__pyx_t_3)) {

      /* "cupy/core/core.pyx":3470
 *     if out is not None:
 *         if k != 0 and out.size != n * m:
 *             raise ValueError('Output array has an invalid size')             # <<<<<<<<<<<<<<
 *         if not out._c_contiguous:
 *             raise ValueError('Output array must be C-contiguous')
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__140, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3470, __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(0, 3470, __pyx_L1_error)

      /* "cupy/core/core.pyx":3469
 *         ret_shape.insert(ret_shape.end(), b._shape.begin() + 1, b._shape.end())
 *     if out is not None:
 *         if k != 0 and out.size != n * m:             # <<<<<<<<<<<<<<
 *             raise ValueError('Output array has an invalid size')
 *         if not out._c_contiguous:
 */
    }

    /* "cupy/core/core.pyx":3471
 *         if k != 0 and out.size != n * m:
 *             raise ValueError('Output array has an invalid size')
 *         if not out._c_contiguous:             # <<<<<<<<<<<<<<
 *             raise ValueError('Output array must be C-contiguous')
 * 
 */
    __pyx_t_3 = ((!(__pyx_v_out->_c_contiguous != 0)) != 0);
    if (unlikely(__pyx_t_3)) {

      /* "cupy/core/core.pyx":3472
 *             raise ValueError('Output array has an invalid size')
 *         if not out._c_contiguous:
 *             raise ValueError('Output array must be C-contiguous')             # <<<<<<<<<<<<<<
 * 
 *     return tensordot_core(a, b, out, n, m, k, ret_shape)
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__141, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3472, __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(0, 3472, __pyx_L1_error)

      /* "cupy/core/core.pyx":3471
 *         if k != 0 and out.size != n * m:
 *             raise ValueError('Output array has an invalid size')
 *         if not out._c_contiguous:             # <<<<<<<<<<<<<<
 *             raise ValueError('Output array must be C-contiguous')
 * 
 */
    }

    /* "cupy/core/core.pyx":3468
 *     if not input_b_is_vec:
 *         ret_shape.insert(ret_shape.end(), b._shape.begin() + 1, b._shape.end())
 *     if out is not None:             # <<<<<<<<<<<<<<
 *         if k != 0 and out.size != n * m:
 *             raise ValueError('Output array has an invalid size')
 */
  }

  /* "cupy/core/core.pyx":3474
 *             raise ValueError('Output array must be C-contiguous')
 * 
 *     return tensordot_core(a, b, out, n, m, k, ret_shape)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_tensordot_core(__pyx_v_a, __pyx_v_b, __pyx_v_out, __pyx_v_n, __pyx_v_m, __pyx_v_k, __pyx_v_ret_shape, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3474, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3413
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray dot(ndarray a, ndarray b, ndarray out=None):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t a_ndim, b_ndim, a_axis, b_axis, n, m, k
 *     cdef bint input_a_is_vec, input_b_is_vec
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.core.core.dot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_b);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_99dot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_98dot[] = "dot(ndarray a, ndarray b, ndarray out=None) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_99dot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dot (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_b,&__pyx_n_s_out,0};
    PyObject* values[3] = {0,0,0};
    values[2] = (PyObject *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
    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_a)) != 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_b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("dot", 0, 2, 3, 1); __PYX_ERR(0, 3413, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "dot") < 0)) __PYX_ERR(0, 3413, __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_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_b = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("dot", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3413, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.dot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3413, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(0, 3413, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 3413, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_98dot(__pyx_self, __pyx_v_a, __pyx_v_b, __pyx_v_out);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_98dot(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_dot __pyx_t_2;
  __Pyx_RefNannySetupContext("dot", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_dot(__pyx_v_a, __pyx_v_b, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.dot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3477
 * 
 * 
 * cpdef ndarray _get_all_addresses(size_t start_adr,             # <<<<<<<<<<<<<<
 *                                  vector.vector[size_t] & shape,
 *                                  vector.vector[size_t] & strides):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_101_get_all_addresses(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__get_all_addresses(size_t __pyx_v_start_adr, std::vector<size_t>  &__pyx_v_shape, std::vector<size_t>  &__pyx_v_strides, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_idx = NULL;
  PyObject *__pyx_v_sh_ = NULL;
  PyObject *__pyx_v_st_ = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("_get_all_addresses", 0);

  /* "cupy/core/core.pyx":3480
 *                                  vector.vector[size_t] & shape,
 *                                  vector.vector[size_t] & strides):
 *     idx = numpy.array([start_adr])             # <<<<<<<<<<<<<<
 *     for sh_, st_ in zip(shape, strides):
 *         idx = (idx[:, None] + (numpy.arange(sh_) * st_)[None, :]).ravel()
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_start_adr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __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);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3480, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3480, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3480, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3480, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3480, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_idx = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3481
 *                                  vector.vector[size_t] & strides):
 *     idx = numpy.array([start_adr])
 *     for sh_, st_ in zip(shape, strides):             # <<<<<<<<<<<<<<
 *         idx = (idx[:, None] + (numpy.arange(sh_) * st_)[None, :]).ravel()
 *     idx = idx.astype(numpy.uintp)
 */
  __pyx_t_1 = __pyx_convert_vector_to_py_size_t(__pyx_v_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3481, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __pyx_convert_vector_to_py_size_t(__pyx_v_strides); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3481, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3481, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3481, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_5 = __pyx_t_3; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3481, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3481, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 3481, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3481, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 3481, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3481, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_7(__pyx_t_5);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3481, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      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(0, 3481, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3481, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3481, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3481, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_8(__pyx_t_2); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_4 = __pyx_t_8(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_2), 2) < 0) __PYX_ERR(0, 3481, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 3481, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_sh_, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_st_, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3482
 *     idx = numpy.array([start_adr])
 *     for sh_, st_ in zip(shape, strides):
 *         idx = (idx[:, None] + (numpy.arange(sh_) * st_)[None, :]).ravel()             # <<<<<<<<<<<<<<
 *     idx = idx.astype(numpy.uintp)
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_idx, __pyx_tuple__143); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_arange); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_2) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_sh_); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3482, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_sh_};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3482, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_sh_};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3482, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3482, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __pyx_t_2 = NULL;
        __Pyx_INCREF(__pyx_v_sh_);
        __Pyx_GIVEREF(__pyx_v_sh_);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_sh_);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3482, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyNumber_Multiply(__pyx_t_1, __pyx_v_st_); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_9, __pyx_tuple__145); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_ravel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_9) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3482, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3482, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_idx, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3481
 *                                  vector.vector[size_t] & strides):
 *     idx = numpy.array([start_adr])
 *     for sh_, st_ in zip(shape, strides):             # <<<<<<<<<<<<<<
 *         idx = (idx[:, None] + (numpy.arange(sh_) * st_)[None, :]).ravel()
 *     idx = idx.astype(numpy.uintp)
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3483
 *     for sh_, st_ in zip(shape, strides):
 *         idx = (idx[:, None] + (numpy.arange(sh_) * st_)[None, :]).ravel()
 *     idx = idx.astype(numpy.uintp)             # <<<<<<<<<<<<<<
 * 
 *     ret = ndarray((idx.size,), dtype=numpy.uintp)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_idx, __pyx_n_s_astype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3483, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3483, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uintp); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3483, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3483, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_9};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3483, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_9};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3483, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3483, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3483, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_idx, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3485
 *     idx = idx.astype(numpy.uintp)
 * 
 *     ret = ndarray((idx.size,), dtype=numpy.uintp)             # <<<<<<<<<<<<<<
 *     ret.set(idx)
 *     return ret
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_idx, __pyx_n_s_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uintp); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_9) < 0) __PYX_ERR(0, 3485, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":3486
 * 
 *     ret = ndarray((idx.size,), dtype=numpy.uintp)
 *     ret.set(idx)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
  __pyx_t_9 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ret->__pyx_vtab)->set(__pyx_v_ret, __pyx_v_idx, 0, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":3487
 *     ret = ndarray((idx.size,), dtype=numpy.uintp)
 *     ret.set(idx)
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3477
 * 
 * 
 * cpdef ndarray _get_all_addresses(size_t start_adr,             # <<<<<<<<<<<<<<
 *                                  vector.vector[size_t] & shape,
 *                                  vector.vector[size_t] & strides):
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.core.core._get_all_addresses", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_idx);
  __Pyx_XDECREF(__pyx_v_sh_);
  __Pyx_XDECREF(__pyx_v_st_);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_101_get_all_addresses(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_100_get_all_addresses[] = "_get_all_addresses(size_t start_adr, vector[size_t] shape, vector[size_t] strides) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_101_get_all_addresses(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  size_t __pyx_v_start_adr;
  std::vector<size_t>  __pyx_v_shape;
  std::vector<size_t>  __pyx_v_strides;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_all_addresses (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_start_adr,&__pyx_n_s_shape,&__pyx_n_s_strides,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_start_adr)) != 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_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_all_addresses", 1, 3, 3, 1); __PYX_ERR(0, 3477, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_strides)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_all_addresses", 1, 3, 3, 2); __PYX_ERR(0, 3477, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_all_addresses") < 0)) __PYX_ERR(0, 3477, __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_start_adr = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_start_adr == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3477, __pyx_L3_error)
    __pyx_v_shape = __pyx_convert_vector_from_py_size_t(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3478, __pyx_L3_error)
    __pyx_v_strides = __pyx_convert_vector_from_py_size_t(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3479, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_all_addresses", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3477, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_all_addresses", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_100_get_all_addresses(__pyx_self, __pyx_v_start_adr, __pyx_v_shape, __pyx_v_strides);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_100_get_all_addresses(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_start_adr, std::vector<size_t>  __pyx_v_shape, std::vector<size_t>  __pyx_v_strides) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_all_addresses", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__get_all_addresses(__pyx_v_start_adr, __pyx_v_shape, __pyx_v_strides, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_all_addresses", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3490
 * 
 * 
 * cdef ndarray _mat_ptrs(ndarray a):             # <<<<<<<<<<<<<<
 *     """Creates an array of pointers to matrices
 *     Args:
 */

static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__mat_ptrs(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  std::vector<size_t>  __pyx_t_5;
  std::vector<size_t>  __pyx_t_6;
  __Pyx_RefNannySetupContext("_mat_ptrs", 0);

  /* "cupy/core/core.pyx":3505
 *     cdef Py_ssize_t stride, ptr, pointer, i
 *     cdef ndarray ret
 *     if a.ndim <= 2:             # <<<<<<<<<<<<<<
 *         ret = ndarray((1,), dtype=numpy.uintp)
 *         ret.fill(a.data.ptr)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_2, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3505, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3505, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3506
 *     cdef ndarray ret
 *     if a.ndim <= 2:
 *         ret = ndarray((1,), dtype=numpy.uintp)             # <<<<<<<<<<<<<<
 *         ret.fill(a.data.ptr)
 *         return ret
 */
    __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3506, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3506, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uintp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3506, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 3506, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_tuple__147, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3506, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3507
 *     if a.ndim <= 2:
 *         ret = ndarray((1,), dtype=numpy.uintp)
 *         ret.fill(a.data.ptr)             # <<<<<<<<<<<<<<
 *         return ret
 *     else:
 */
    __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3507, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ret->__pyx_vtab)->fill(__pyx_v_ret, __pyx_t_4, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3507, __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;

    /* "cupy/core/core.pyx":3508
 *         ret = ndarray((1,), dtype=numpy.uintp)
 *         ret.fill(a.data.ptr)
 *         return ret             # <<<<<<<<<<<<<<
 *     else:
 *         return _get_all_addresses(a.data.ptr, a.shape[:-2], a.strides[:-2])
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_ret));
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3505
 *     cdef Py_ssize_t stride, ptr, pointer, i
 *     cdef ndarray ret
 *     if a.ndim <= 2:             # <<<<<<<<<<<<<<
 *         ret = ndarray((1,), dtype=numpy.uintp)
 *         ret.fill(a.data.ptr)
 */
  }

  /* "cupy/core/core.pyx":3510
 *         return ret
 *     else:
 *         return _get_all_addresses(a.data.ptr, a.shape[:-2], a.strides[:-2])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3510, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, -2L, NULL, NULL, &__pyx_slice__148, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3510, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = __pyx_convert_vector_from_py_size_t(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3510, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3510, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_4, 0, -2L, NULL, NULL, &__pyx_slice__149, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3510, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_convert_vector_from_py_size_t(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3510, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__get_all_addresses(__pyx_v_a->data->ptr, __pyx_t_5, __pyx_t_6, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3510, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":3490
 * 
 * 
 * cdef ndarray _mat_ptrs(ndarray a):             # <<<<<<<<<<<<<<
 *     """Creates an array of pointers to matrices
 *     Args:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core._mat_ptrs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3513
 * 
 * 
 * cpdef int _get_stride_for_strided_batched_gemm(ndarray a):             # <<<<<<<<<<<<<<
 *     if a.ndim > 2:
 *         return a.strides[-3] / a.itemsize
 */

static PyObject *__pyx_pw_4cupy_4core_4core_103_get_stride_for_strided_batched_gemm(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
static int __pyx_f_4cupy_4core_4core__get_stride_for_strided_batched_gemm(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("_get_stride_for_strided_batched_gemm", 0);

  /* "cupy/core/core.pyx":3514
 * 
 * cpdef int _get_stride_for_strided_batched_gemm(ndarray a):
 *     if a.ndim > 2:             # <<<<<<<<<<<<<<
 *         return a.strides[-3] / a.itemsize
 *     else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_2, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3515
 * cpdef int _get_stride_for_strided_batched_gemm(ndarray a):
 *     if a.ndim > 2:
 *         return a.strides[-3] / a.itemsize             # <<<<<<<<<<<<<<
 *     else:
 *         return a.shape[-2] * a.shape[-1]
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, -3L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3515, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3514
 * 
 * cpdef int _get_stride_for_strided_batched_gemm(ndarray a):
 *     if a.ndim > 2:             # <<<<<<<<<<<<<<
 *         return a.strides[-3] / a.itemsize
 *     else:
 */
  }

  /* "cupy/core/core.pyx":3517
 *         return a.strides[-3] / a.itemsize
 *     else:
 *         return a.shape[-2] * a.shape[-1]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_4, -2L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 3517, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":3513
 * 
 * 
 * cpdef int _get_stride_for_strided_batched_gemm(ndarray a):             # <<<<<<<<<<<<<<
 *     if a.ndim > 2:
 *         return a.strides[-3] / a.itemsize
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("cupy.core.core._get_stride_for_strided_batched_gemm", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_103_get_stride_for_strided_batched_gemm(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
static char __pyx_doc_4cupy_4core_4core_102_get_stride_for_strided_batched_gemm[] = "_get_stride_for_strided_batched_gemm(ndarray a) -> int";
static PyObject *__pyx_pw_4cupy_4core_4core_103_get_stride_for_strided_batched_gemm(PyObject *__pyx_self, PyObject *__pyx_v_a) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_stride_for_strided_batched_gemm (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3513, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_102_get_stride_for_strided_batched_gemm(__pyx_self, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_a));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_102_get_stride_for_strided_batched_gemm(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_stride_for_strided_batched_gemm", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_4cupy_4core_4core__get_stride_for_strided_batched_gemm(__pyx_v_a, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3513, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._get_stride_for_strided_batched_gemm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3520
 * 
 * 
 * cpdef ndarray matmul(ndarray a, ndarray b, ndarray out=None):             # <<<<<<<<<<<<<<
 *     """ Returns the matrix product of two arrays and is the implementation of
 *     the `@` operator introduced in Python 3.5 following PEP465.
 */

static PyObject *__pyx_pw_4cupy_4core_4core_105matmul(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_matmul(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_matmul *__pyx_optional_args) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_n;
  Py_ssize_t __pyx_v_m;
  Py_ssize_t __pyx_v_ka;
  Py_ssize_t __pyx_v_kb;
  Py_ssize_t __pyx_v_batchCount;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ap = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_bp = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_outp = 0;
  PyObject *__pyx_v_orig_a_shape = NULL;
  PyObject *__pyx_v_orig_b_shape = NULL;
  PyObject *__pyx_v_ret_dtype = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_a_part_outshape = NULL;
  PyObject *__pyx_v_b_part_outshape = NULL;
  PyObject *__pyx_v_ldout = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_view = NULL;
  PyObject *__pyx_v_broadcast_pre_shape = NULL;
  PyObject *__pyx_v_out_shape = NULL;
  PyObject *__pyx_v_a_strides = NULL;
  PyObject *__pyx_v_a_shape = NULL;
  PyObject *__pyx_v_b_strides = NULL;
  PyObject *__pyx_v_b_shape = NULL;
  int __pyx_v_use_broadcast;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out_view = NULL;
  PyObject *__pyx_v_out_view_shape = NULL;
  PyObject *__pyx_v_out_view_strides = NULL;
  PyObject *__pyx_v_lda = NULL;
  PyObject *__pyx_v_ldb = NULL;
  PyObject *__pyx_v_la = NULL;
  PyObject *__pyx_v_lb = NULL;
  PyObject *__pyx_v_la_ = NULL;
  PyObject *__pyx_v_lb_ = NULL;
  int __pyx_v_strideA;
  int __pyx_v_strideB;
  int __pyx_v_strideC;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = NULL;
  PyObject *__pyx_v__ = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  std::vector<Py_ssize_t>  __pyx_t_10;
  std::vector<Py_ssize_t>  __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray __pyx_t_16;
  Py_ssize_t __pyx_t_17;
  Py_ssize_t __pyx_t_18;
  size_t __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *(*__pyx_t_22)(PyObject *);
  PyObject *(*__pyx_t_23)(PyObject *);
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29 = NULL;
  __Pyx_RefNannySetupContext("matmul", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_out = __pyx_optional_args->out;
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF((PyObject *)__pyx_v_b);
  __Pyx_INCREF((PyObject *)__pyx_v_out);

  /* "cupy/core/core.pyx":3545
 *     # ToDo: remove python object out_shape
 *     # ToDo: remove python object .reshape
 *     if out is not None:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError('The out array as input is currently not '
 *                                   'supported')
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_out) != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "cupy/core/core.pyx":3546
 *     # ToDo: remove python object .reshape
 *     if out is not None:
 *         raise NotImplementedError('The out array as input is currently not '             # <<<<<<<<<<<<<<
 *                                   'supported')
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__150, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3546, __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(0, 3546, __pyx_L1_error)

    /* "cupy/core/core.pyx":3545
 *     # ToDo: remove python object out_shape
 *     # ToDo: remove python object .reshape
 *     if out is not None:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError('The out array as input is currently not '
 *                                   'supported')
 */
  }

  /* "cupy/core/core.pyx":3553
 *     cdef ndarray ap, bp, outp
 * 
 *     orig_a_shape = a.shape             # <<<<<<<<<<<<<<
 *     orig_b_shape = b.shape
 *     if len(orig_a_shape) == 0 or len(orig_b_shape) == 0:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3553, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_orig_a_shape = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3554
 * 
 *     orig_a_shape = a.shape
 *     orig_b_shape = b.shape             # <<<<<<<<<<<<<<
 *     if len(orig_a_shape) == 0 or len(orig_b_shape) == 0:
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_orig_b_shape = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3555
 *     orig_a_shape = a.shape
 *     orig_b_shape = b.shape
 *     if len(orig_a_shape) == 0 or len(orig_b_shape) == 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')
 * 
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_orig_a_shape); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3555, __pyx_L1_error)
  __pyx_t_1 = ((__pyx_t_4 == 0) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_4 = PyObject_Length(__pyx_v_orig_b_shape); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3555, __pyx_L1_error)
  __pyx_t_1 = ((__pyx_t_4 == 0) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L5_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "cupy/core/core.pyx":3556
 *     orig_b_shape = b.shape
 *     if len(orig_a_shape) == 0 or len(orig_b_shape) == 0:
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')             # <<<<<<<<<<<<<<
 * 
 *     ret_dtype = numpy.result_type(a.dtype, b.dtype)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__151, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3556, __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(0, 3556, __pyx_L1_error)

    /* "cupy/core/core.pyx":3555
 *     orig_a_shape = a.shape
 *     orig_b_shape = b.shape
 *     if len(orig_a_shape) == 0 or len(orig_b_shape) == 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')
 * 
 */
  }

  /* "cupy/core/core.pyx":3558
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')
 * 
 *     ret_dtype = numpy.result_type(a.dtype, b.dtype)             # <<<<<<<<<<<<<<
 *     dtype = numpy.find_common_type((ret_dtype, 'f'), ())
 * 
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_result_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_v_a->dtype, __pyx_v_b->dtype};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3558, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_a->dtype, __pyx_v_b->dtype};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3558, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3558, __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_INCREF(__pyx_v_a->dtype);
    __Pyx_GIVEREF(__pyx_v_a->dtype);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_a->dtype);
    __Pyx_INCREF(__pyx_v_b->dtype);
    __Pyx_GIVEREF(__pyx_v_b->dtype);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_b->dtype);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3558, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_ret_dtype = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3559
 * 
 *     ret_dtype = numpy.result_type(a.dtype, b.dtype)
 *     dtype = numpy.find_common_type((ret_dtype, 'f'), ())             # <<<<<<<<<<<<<<
 * 
 *     a = a.astype(dtype, copy=False)
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3559, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_find_common_type); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3559, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3559, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_ret_dtype);
  __Pyx_GIVEREF(__pyx_v_ret_dtype);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_ret_dtype);
  __Pyx_INCREF(__pyx_n_s_f);
  __Pyx_GIVEREF(__pyx_n_s_f);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_f);
  __pyx_t_5 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_6, __pyx_empty_tuple};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3559, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_6, __pyx_empty_tuple};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3559, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_7, __pyx_t_6);
    __Pyx_INCREF(__pyx_empty_tuple);
    __Pyx_GIVEREF(__pyx_empty_tuple);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_7, __pyx_empty_tuple);
    __pyx_t_6 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_dtype = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3561
 *     dtype = numpy.find_common_type((ret_dtype, 'f'), ())
 * 
 *     a = a.astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 *     b = b.astype(dtype, copy=False)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_astype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_dtype);
  __pyx_t_9 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 3561, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3561, __pyx_L1_error)
  __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6));
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3562
 * 
 *     a = a.astype(dtype, copy=False)
 *     b = b.astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 * 
 *     if a.ndim == 1:
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_astype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_dtype);
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 3562, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3562, __pyx_L1_error)
  __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3564
 *     b = b.astype(dtype, copy=False)
 * 
 *     if a.ndim == 1:             # <<<<<<<<<<<<<<
 *         a = a.reshape(1, len(a))
 *         a_part_outshape = ()
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3564, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3565
 * 
 *     if a.ndim == 1:
 *         a = a.reshape(1, len(a))             # <<<<<<<<<<<<<<
 *         a_part_outshape = ()
 *     else:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_a)); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3565, __pyx_L1_error)
    __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_6 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_int_1, __pyx_t_9};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3565, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_int_1, __pyx_t_9};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3565, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3565, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_int_1);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3565, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3565, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8));
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3566
 *     if a.ndim == 1:
 *         a = a.reshape(1, len(a))
 *         a_part_outshape = ()             # <<<<<<<<<<<<<<
 *     else:
 *         a_part_outshape = (a.shape[-2],)
 */
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_v_a_part_outshape = __pyx_empty_tuple;

    /* "cupy/core/core.pyx":3564
 *     b = b.astype(dtype, copy=False)
 * 
 *     if a.ndim == 1:             # <<<<<<<<<<<<<<
 *         a = a.reshape(1, len(a))
 *         a_part_outshape = ()
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":3568
 *         a_part_outshape = ()
 *     else:
 *         a_part_outshape = (a.shape[-2],)             # <<<<<<<<<<<<<<
 *     if b.ndim == 1:
 *         b = b.reshape(len(b), 1)
 */
  /*else*/ {
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_8, -2L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_v_a_part_outshape = ((PyObject*)__pyx_t_8);
    __pyx_t_8 = 0;
  }
  __pyx_L7:;

  /* "cupy/core/core.pyx":3569
 *     else:
 *         a_part_outshape = (a.shape[-2],)
 *     if b.ndim == 1:             # <<<<<<<<<<<<<<
 *         b = b.reshape(len(b), 1)
 *         b_part_outshape = ()
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_8, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3569, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3570
 *         a_part_outshape = (a.shape[-2],)
 *     if b.ndim == 1:
 *         b = b.reshape(len(b), 1)             # <<<<<<<<<<<<<<
 *         b_part_outshape = ()
 *         ldout = 1
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3570, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_b)); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3570, __pyx_L1_error)
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3570, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_5, __pyx_int_1};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3570, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_5, __pyx_int_1};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3570, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_9) {
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_t_5);
      __Pyx_INCREF(__pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_int_1);
      __pyx_t_5 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3570, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3571
 *     if b.ndim == 1:
 *         b = b.reshape(len(b), 1)
 *         b_part_outshape = ()             # <<<<<<<<<<<<<<
 *         ldout = 1
 *     else:
 */
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_v_b_part_outshape = __pyx_empty_tuple;

    /* "cupy/core/core.pyx":3572
 *         b = b.reshape(len(b), 1)
 *         b_part_outshape = ()
 *         ldout = 1             # <<<<<<<<<<<<<<
 *     else:
 *         b_part_outshape = b.shape[-1:]
 */
    __Pyx_INCREF(__pyx_int_1);
    __pyx_v_ldout = __pyx_int_1;

    /* "cupy/core/core.pyx":3569
 *     else:
 *         a_part_outshape = (a.shape[-2],)
 *     if b.ndim == 1:             # <<<<<<<<<<<<<<
 *         b = b.reshape(len(b), 1)
 *         b_part_outshape = ()
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":3574
 *         ldout = 1
 *     else:
 *         b_part_outshape = b.shape[-1:]             # <<<<<<<<<<<<<<
 *         ldout = b.shape[-1]
 * 
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3574, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_PyObject_GetSlice(__pyx_t_3, -1L, 0, NULL, NULL, &__pyx_slice__152, 1, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3574, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_b_part_outshape = __pyx_t_8;
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":3575
 *     else:
 *         b_part_outshape = b.shape[-1:]
 *         ldout = b.shape[-1]             # <<<<<<<<<<<<<<
 * 
 *     # expand dims
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3575, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_8, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3575, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_v_ldout = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":3578
 * 
 *     # expand dims
 *     if a.ndim < b.ndim:             # <<<<<<<<<<<<<<
 *         view = a.view()
 *         view._set_shape_and_strides(
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, __pyx_t_8, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3578, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3578, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3579
 *     # expand dims
 *     if a.ndim < b.ndim:
 *         view = a.view()             # <<<<<<<<<<<<<<
 *         view._set_shape_and_strides(
 *             (1,) * (b.ndim - a.ndim) + a.shape,
 */
    __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3579, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":3581
 *         view = a.view()
 *         view._set_shape_and_strides(
 *             (1,) * (b.ndim - a.ndim) + a.shape,             # <<<<<<<<<<<<<<
 *             (0,) * (b.ndim - a.ndim) + a.strides)
 *         a = view
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyNumber_Multiply(__pyx_tuple__153, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyNumber_Add(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_10 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3581, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":3582
 *         view._set_shape_and_strides(
 *             (1,) * (b.ndim - a.ndim) + a.shape,
 *             (0,) * (b.ndim - a.ndim) + a.strides)             # <<<<<<<<<<<<<<
 *         a = view
 *     elif a.ndim > b.ndim:
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3582, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3582, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = PyNumber_Subtract(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3582, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__154, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3582, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3582, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = PyNumber_Add(__pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3582, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3582, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":3580
 *     if a.ndim < b.ndim:
 *         view = a.view()
 *         view._set_shape_and_strides(             # <<<<<<<<<<<<<<
 *             (1,) * (b.ndim - a.ndim) + a.shape,
 *             (0,) * (b.ndim - a.ndim) + a.strides)
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_t_10, __pyx_t_11, 0, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":3583
 *             (1,) * (b.ndim - a.ndim) + a.shape,
 *             (0,) * (b.ndim - a.ndim) + a.strides)
 *         a = view             # <<<<<<<<<<<<<<
 *     elif a.ndim > b.ndim:
 *         view = b.view()
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_view));
    __Pyx_DECREF_SET(__pyx_v_a, __pyx_v_view);

    /* "cupy/core/core.pyx":3578
 * 
 *     # expand dims
 *     if a.ndim < b.ndim:             # <<<<<<<<<<<<<<
 *         view = a.view()
 *         view._set_shape_and_strides(
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":3584
 *             (0,) * (b.ndim - a.ndim) + a.strides)
 *         a = view
 *     elif a.ndim > b.ndim:             # <<<<<<<<<<<<<<
 *         view = b.view()
 *         view._set_shape_and_strides(
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_6, __pyx_t_8, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3585
 *         a = view
 *     elif a.ndim > b.ndim:
 *         view = b.view()             # <<<<<<<<<<<<<<
 *         view._set_shape_and_strides(
 *             (1,) * (a.ndim - b.ndim) + b.shape,
 */
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->view(__pyx_v_b, 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3585, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3587
 *         view = b.view()
 *         view._set_shape_and_strides(
 *             (1,) * (a.ndim - b.ndim) + b.shape,             # <<<<<<<<<<<<<<
 *             (0,) * (a.ndim - b.ndim) + b.strides)
 *         b = view
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3587, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3587, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = PyNumber_Subtract(__pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3587, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyNumber_Multiply(__pyx_tuple__155, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3587, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3587, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyNumber_Add(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3587, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3587, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3588
 *         view._set_shape_and_strides(
 *             (1,) * (a.ndim - b.ndim) + b.shape,
 *             (0,) * (a.ndim - b.ndim) + b.strides)             # <<<<<<<<<<<<<<
 *         b = view
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = PyNumber_Subtract(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Multiply(__pyx_tuple__156, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_strides); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = PyNumber_Add(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_10 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3588, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3586
 *     elif a.ndim > b.ndim:
 *         view = b.view()
 *         view._set_shape_and_strides(             # <<<<<<<<<<<<<<
 *             (1,) * (a.ndim - b.ndim) + b.shape,
 *             (0,) * (a.ndim - b.ndim) + b.strides)
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_t_11, __pyx_t_10, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3589
 *             (1,) * (a.ndim - b.ndim) + b.shape,
 *             (0,) * (a.ndim - b.ndim) + b.strides)
 *         b = view             # <<<<<<<<<<<<<<
 * 
 *     broadcast_pre_shape = numpy.maximum(
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_view));
    __Pyx_DECREF_SET(__pyx_v_b, __pyx_v_view);

    /* "cupy/core/core.pyx":3584
 *             (0,) * (b.ndim - a.ndim) + a.strides)
 *         a = view
 *     elif a.ndim > b.ndim:             # <<<<<<<<<<<<<<
 *         view = b.view()
 *         view._set_shape_and_strides(
 */
  }
  __pyx_L9:;

  /* "cupy/core/core.pyx":3591
 *         b = view
 * 
 *     broadcast_pre_shape = numpy.maximum(             # <<<<<<<<<<<<<<
 *         numpy.array(a.shape[:-2], numpy.uint64) - 1,
 *         numpy.array(b.shape[:-2], numpy.uint64) - 1
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_maximum); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3592
 * 
 *     broadcast_pre_shape = numpy.maximum(
 *         numpy.array(a.shape[:-2], numpy.uint64) - 1,             # <<<<<<<<<<<<<<
 *         numpy.array(b.shape[:-2], numpy.uint64) - 1
 *     ) + 1
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_array); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_12 = __Pyx_PyObject_GetSlice(__pyx_t_5, 0, -2L, NULL, NULL, &__pyx_slice__157, 0, 1, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_uint64); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_9)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_12, __pyx_t_13};
    __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3592, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_12, __pyx_t_13};
    __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3592, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_7, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_7, __pyx_t_13);
    __pyx_t_12 = 0;
    __pyx_t_13 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyInt_SubtractObjC(__pyx_t_8, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3593
 *     broadcast_pre_shape = numpy.maximum(
 *         numpy.array(a.shape[:-2], numpy.uint64) - 1,
 *         numpy.array(b.shape[:-2], numpy.uint64) - 1             # <<<<<<<<<<<<<<
 *     ) + 1
 * 
 */
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_array); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_12 = __Pyx_PyObject_GetSlice(__pyx_t_14, 0, -2L, NULL, NULL, &__pyx_slice__158, 0, 1, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_uint64); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_13, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_13)) {
    PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_t_12, __pyx_t_5};
    __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3593, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
    PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_t_12, __pyx_t_5};
    __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3593, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_15 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3593, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (__pyx_t_14) {
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_7, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_7, __pyx_t_5);
    __pyx_t_12 = 0;
    __pyx_t_5 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_15, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3593, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  }
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = __Pyx_PyInt_SubtractObjC(__pyx_t_8, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_8);
      __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_8, __pyx_t_9, __pyx_t_13};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3591, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_9, __pyx_t_13};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3591, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else
  #endif
  {
    __pyx_t_15 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3591, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_7, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_7, __pyx_t_13);
    __pyx_t_9 = 0;
    __pyx_t_13 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3591, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3594
 *         numpy.array(a.shape[:-2], numpy.uint64) - 1,
 *         numpy.array(b.shape[:-2], numpy.uint64) - 1
 *     ) + 1             # <<<<<<<<<<<<<<
 * 
 *     out_shape = (*broadcast_pre_shape, *a_part_outshape, *b_part_outshape)
 */
  __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_broadcast_pre_shape = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3596
 *     ) + 1
 * 
 *     out_shape = (*broadcast_pre_shape, *a_part_outshape, *b_part_outshape)             # <<<<<<<<<<<<<<
 * 
 *     a = ascontiguousarray(a, dtype=dtype)
 */
  __pyx_t_6 = PySequence_List(__pyx_v_broadcast_pre_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3596, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (__Pyx_PyList_Extend(__pyx_t_6, __pyx_v_a_part_outshape) < 0) __PYX_ERR(0, 3596, __pyx_L1_error)
  if (__Pyx_PyList_Extend(__pyx_t_6, __pyx_v_b_part_outshape) < 0) __PYX_ERR(0, 3596, __pyx_L1_error)
  {
    PyObject *__pyx_temp = PyList_AsTuple(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_6);
    __pyx_t_6 = __pyx_temp; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3596, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  }
  __pyx_v_out_shape = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3598
 *     out_shape = (*broadcast_pre_shape, *a_part_outshape, *b_part_outshape)
 * 
 *     a = ascontiguousarray(a, dtype=dtype)             # <<<<<<<<<<<<<<
 *     b = ascontiguousarray(b, dtype=dtype)
 * 
 */
  __pyx_t_16.__pyx_n = 1;
  __pyx_t_16.dtype = __pyx_v_dtype;
  __pyx_t_6 = ((PyObject *)__pyx_f_4cupy_4core_4core_ascontiguousarray(__pyx_v_a, 0, &__pyx_t_16)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6));
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3599
 * 
 *     a = ascontiguousarray(a, dtype=dtype)
 *     b = ascontiguousarray(b, dtype=dtype)             # <<<<<<<<<<<<<<
 * 
 *     # broadcast
 */
  __pyx_t_16.__pyx_n = 1;
  __pyx_t_16.dtype = __pyx_v_dtype;
  __pyx_t_6 = ((PyObject *)__pyx_f_4cupy_4core_4core_ascontiguousarray(__pyx_v_b, 0, &__pyx_t_16)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3599, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6));
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3602
 * 
 *     # broadcast
 *     a_strides = list(a.strides)             # <<<<<<<<<<<<<<
 *     a_shape = list(a.shape)
 *     b_strides = list(b.strides)
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3602, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = PySequence_List(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3602, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_a_strides = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3603
 *     # broadcast
 *     a_strides = list(a.strides)
 *     a_shape = list(a.shape)             # <<<<<<<<<<<<<<
 *     b_strides = list(b.strides)
 *     b_shape = list(b.shape)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_a_shape = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3604
 *     a_strides = list(a.strides)
 *     a_shape = list(a.shape)
 *     b_strides = list(b.strides)             # <<<<<<<<<<<<<<
 *     b_shape = list(b.shape)
 *     use_broadcast = False
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_strides); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3604, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = PySequence_List(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3604, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_b_strides = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3605
 *     a_shape = list(a.shape)
 *     b_strides = list(b.strides)
 *     b_shape = list(b.shape)             # <<<<<<<<<<<<<<
 *     use_broadcast = False
 *     for i in range(len(a_strides) - 2):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3605, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3605, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_b_shape = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3606
 *     b_strides = list(b.strides)
 *     b_shape = list(b.shape)
 *     use_broadcast = False             # <<<<<<<<<<<<<<
 *     for i in range(len(a_strides) - 2):
 *         if a_shape[i] == 1 and broadcast_pre_shape[i] > 1:
 */
  __pyx_v_use_broadcast = 0;

  /* "cupy/core/core.pyx":3607
 *     b_shape = list(b.shape)
 *     use_broadcast = False
 *     for i in range(len(a_strides) - 2):             # <<<<<<<<<<<<<<
 *         if a_shape[i] == 1 and broadcast_pre_shape[i] > 1:
 *             a_strides[i] = 0
 */
  __pyx_t_4 = PyList_GET_SIZE(__pyx_v_a_strides); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3607, __pyx_L1_error)
  __pyx_t_17 = (__pyx_t_4 - 2);
  __pyx_t_4 = __pyx_t_17;
  for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_4; __pyx_t_18+=1) {
    __pyx_v_i = __pyx_t_18;

    /* "cupy/core/core.pyx":3608
 *     use_broadcast = False
 *     for i in range(len(a_strides) - 2):
 *         if a_shape[i] == 1 and broadcast_pre_shape[i] > 1:             # <<<<<<<<<<<<<<
 *             a_strides[i] = 0
 *             a_shape[i] = broadcast_pre_shape[i]
 */
    __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_a_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3608, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_6, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3608, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3608, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_broadcast_pre_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3608, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3608, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3608, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_L13_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3609
 *     for i in range(len(a_strides) - 2):
 *         if a_shape[i] == 1 and broadcast_pre_shape[i] > 1:
 *             a_strides[i] = 0             # <<<<<<<<<<<<<<
 *             a_shape[i] = broadcast_pre_shape[i]
 *             use_broadcast = True
 */
      if (unlikely(__Pyx_SetItemInt(__pyx_v_a_strides, __pyx_v_i, __pyx_int_0, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 3609, __pyx_L1_error)

      /* "cupy/core/core.pyx":3610
 *         if a_shape[i] == 1 and broadcast_pre_shape[i] > 1:
 *             a_strides[i] = 0
 *             a_shape[i] = broadcast_pre_shape[i]             # <<<<<<<<<<<<<<
 *             use_broadcast = True
 *     for i in range(len(b_strides) - 2):
 */
      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_broadcast_pre_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3610, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (unlikely(__Pyx_SetItemInt(__pyx_v_a_shape, __pyx_v_i, __pyx_t_6, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 3610, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/core.pyx":3611
 *             a_strides[i] = 0
 *             a_shape[i] = broadcast_pre_shape[i]
 *             use_broadcast = True             # <<<<<<<<<<<<<<
 *     for i in range(len(b_strides) - 2):
 *         if b_shape[i] == 1 and broadcast_pre_shape[i] > 1:
 */
      __pyx_v_use_broadcast = 1;

      /* "cupy/core/core.pyx":3608
 *     use_broadcast = False
 *     for i in range(len(a_strides) - 2):
 *         if a_shape[i] == 1 and broadcast_pre_shape[i] > 1:             # <<<<<<<<<<<<<<
 *             a_strides[i] = 0
 *             a_shape[i] = broadcast_pre_shape[i]
 */
    }
  }

  /* "cupy/core/core.pyx":3612
 *             a_shape[i] = broadcast_pre_shape[i]
 *             use_broadcast = True
 *     for i in range(len(b_strides) - 2):             # <<<<<<<<<<<<<<
 *         if b_shape[i] == 1 and broadcast_pre_shape[i] > 1:
 *             b_strides[i] = 0
 */
  __pyx_t_17 = PyList_GET_SIZE(__pyx_v_b_strides); if (unlikely(__pyx_t_17 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3612, __pyx_L1_error)
  __pyx_t_4 = (__pyx_t_17 - 2);
  __pyx_t_17 = __pyx_t_4;
  for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
    __pyx_v_i = __pyx_t_18;

    /* "cupy/core/core.pyx":3613
 *             use_broadcast = True
 *     for i in range(len(b_strides) - 2):
 *         if b_shape[i] == 1 and broadcast_pre_shape[i] > 1:             # <<<<<<<<<<<<<<
 *             b_strides[i] = 0
 *             b_shape[i] = broadcast_pre_shape[i]
 */
    __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_b_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3613, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_6, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3613, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3613, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L18_bool_binop_done;
    }
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_broadcast_pre_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3613, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3613, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3613, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_L18_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3614
 *     for i in range(len(b_strides) - 2):
 *         if b_shape[i] == 1 and broadcast_pre_shape[i] > 1:
 *             b_strides[i] = 0             # <<<<<<<<<<<<<<
 *             b_shape[i] = broadcast_pre_shape[i]
 *             use_broadcast = True
 */
      if (unlikely(__Pyx_SetItemInt(__pyx_v_b_strides, __pyx_v_i, __pyx_int_0, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 3614, __pyx_L1_error)

      /* "cupy/core/core.pyx":3615
 *         if b_shape[i] == 1 and broadcast_pre_shape[i] > 1:
 *             b_strides[i] = 0
 *             b_shape[i] = broadcast_pre_shape[i]             # <<<<<<<<<<<<<<
 *             use_broadcast = True
 * 
 */
      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_broadcast_pre_shape, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3615, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (unlikely(__Pyx_SetItemInt(__pyx_v_b_shape, __pyx_v_i, __pyx_t_6, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 3615, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/core.pyx":3616
 *             b_strides[i] = 0
 *             b_shape[i] = broadcast_pre_shape[i]
 *             use_broadcast = True             # <<<<<<<<<<<<<<
 * 
 *     view = a.view()
 */
      __pyx_v_use_broadcast = 1;

      /* "cupy/core/core.pyx":3613
 *             use_broadcast = True
 *     for i in range(len(b_strides) - 2):
 *         if b_shape[i] == 1 and broadcast_pre_shape[i] > 1:             # <<<<<<<<<<<<<<
 *             b_strides[i] = 0
 *             b_shape[i] = broadcast_pre_shape[i]
 */
    }
  }

  /* "cupy/core/core.pyx":3618
 *             use_broadcast = True
 * 
 *     view = a.view()             # <<<<<<<<<<<<<<
 *     view._set_shape_and_strides(a_shape, a_strides)
 *     a = view
 */
  __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3618, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_XDECREF_SET(__pyx_v_view, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6));
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3619
 * 
 *     view = a.view()
 *     view._set_shape_and_strides(a_shape, a_strides)             # <<<<<<<<<<<<<<
 *     a = view
 *     view = b.view()
 */
  __pyx_t_10 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_a_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3619, __pyx_L1_error)
  __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_a_strides); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3619, __pyx_L1_error)
  __pyx_t_6 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_t_10, __pyx_t_11, 0, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3619, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3620
 *     view = a.view()
 *     view._set_shape_and_strides(a_shape, a_strides)
 *     a = view             # <<<<<<<<<<<<<<
 *     view = b.view()
 *     view._set_shape_and_strides(b_shape, b_strides)
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_view));
  __Pyx_DECREF_SET(__pyx_v_a, __pyx_v_view);

  /* "cupy/core/core.pyx":3621
 *     view._set_shape_and_strides(a_shape, a_strides)
 *     a = view
 *     view = b.view()             # <<<<<<<<<<<<<<
 *     view._set_shape_and_strides(b_shape, b_strides)
 *     b = view
 */
  __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->view(__pyx_v_b, 0, NULL)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3621, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF_SET(__pyx_v_view, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6));
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3622
 *     a = view
 *     view = b.view()
 *     view._set_shape_and_strides(b_shape, b_strides)             # <<<<<<<<<<<<<<
 *     b = view
 * 
 */
  __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_b_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3622, __pyx_L1_error)
  __pyx_t_10 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_b_strides); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3622, __pyx_L1_error)
  __pyx_t_6 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_view, __pyx_t_11, __pyx_t_10, 0, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3622, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":3623
 *     view = b.view()
 *     view._set_shape_and_strides(b_shape, b_strides)
 *     b = view             # <<<<<<<<<<<<<<
 * 
 *     out = ndarray(out_shape, dtype=dtype)
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_view));
  __Pyx_DECREF_SET(__pyx_v_b, __pyx_v_view);

  /* "cupy/core/core.pyx":3625
 *     b = view
 * 
 *     out = ndarray(out_shape, dtype=dtype)             # <<<<<<<<<<<<<<
 *     out.data.memset_async(0, out.nbytes)
 * 
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_out_shape);
  __Pyx_GIVEREF(__pyx_v_out_shape);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_out_shape);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 3625, __pyx_L1_error)
  __pyx_t_15 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_15));
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":3626
 * 
 *     out = ndarray(out_shape, dtype=dtype)
 *     out.data.memset_async(0, out.nbytes)             # <<<<<<<<<<<<<<
 * 
 *     out_view = out.view()
 */
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_19 = __Pyx_PyInt_As_size_t(__pyx_t_15); if (unlikely((__pyx_t_19 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3626, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_out->data->__pyx_vtab)->memset_async(__pyx_v_out->data, 0, __pyx_t_19, 0, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":3628
 *     out.data.memset_async(0, out.nbytes)
 * 
 *     out_view = out.view()             # <<<<<<<<<<<<<<
 *     out_view_shape = out.shape
 *     out_view_strides = out.strides
 */
  __pyx_t_15 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_out->__pyx_vtab)->view(__pyx_v_out, 0, NULL)); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3628, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_v_out_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_15);
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":3629
 * 
 *     out_view = out.view()
 *     out_view_shape = out.shape             # <<<<<<<<<<<<<<
 *     out_view_strides = out.strides
 *     if a_part_outshape == ():
 */
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_v_out_view_shape = __pyx_t_15;
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":3630
 *     out_view = out.view()
 *     out_view_shape = out.shape
 *     out_view_strides = out.strides             # <<<<<<<<<<<<<<
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)
 */
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_strides); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_v_out_view_strides = __pyx_t_15;
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":3631
 *     out_view_shape = out.shape
 *     out_view_strides = out.strides
 *     if a_part_outshape == ():             # <<<<<<<<<<<<<<
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 */
  __pyx_t_15 = PyObject_RichCompare(__pyx_v_a_part_outshape, __pyx_empty_tuple, Py_EQ); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3631, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3631, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3632
 *     out_view_strides = out.strides
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)             # <<<<<<<<<<<<<<
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():
 */
    __pyx_t_15 = PyNumber_InPlaceAdd(__pyx_v_out_view_shape, __pyx_tuple__159); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF_SET(__pyx_v_out_view_shape, __pyx_t_15);
    __pyx_t_15 = 0;

    /* "cupy/core/core.pyx":3633
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)             # <<<<<<<<<<<<<<
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)
 */
    __pyx_t_15 = PyNumber_InPlaceAdd(__pyx_v_out_view_strides, __pyx_tuple__160); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF_SET(__pyx_v_out_view_strides, __pyx_t_15);
    __pyx_t_15 = 0;

    /* "cupy/core/core.pyx":3631
 *     out_view_shape = out.shape
 *     out_view_strides = out.strides
 *     if a_part_outshape == ():             # <<<<<<<<<<<<<<
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 */
  }

  /* "cupy/core/core.pyx":3634
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():             # <<<<<<<<<<<<<<
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 */
  __pyx_t_15 = PyObject_RichCompare(__pyx_v_b_part_outshape, __pyx_empty_tuple, Py_EQ); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3634, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3634, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3635
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)             # <<<<<<<<<<<<<<
 *         out_view_strides += (0,)
 * 
 */
    __pyx_t_15 = PyNumber_InPlaceAdd(__pyx_v_out_view_shape, __pyx_tuple__161); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3635, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF_SET(__pyx_v_out_view_shape, __pyx_t_15);
    __pyx_t_15 = 0;

    /* "cupy/core/core.pyx":3636
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)             # <<<<<<<<<<<<<<
 * 
 *     out_view._set_shape_and_strides(out_view_shape, out_view_strides)
 */
    __pyx_t_15 = PyNumber_InPlaceAdd(__pyx_v_out_view_strides, __pyx_tuple__162); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3636, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF_SET(__pyx_v_out_view_strides, __pyx_t_15);
    __pyx_t_15 = 0;

    /* "cupy/core/core.pyx":3634
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():             # <<<<<<<<<<<<<<
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)
 */
  }

  /* "cupy/core/core.pyx":3638
 *         out_view_strides += (0,)
 * 
 *     out_view._set_shape_and_strides(out_view_shape, out_view_strides)             # <<<<<<<<<<<<<<
 * 
 *     # (A B)^T = B^T A^T
 */
  __pyx_t_10 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_out_view_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3638, __pyx_L1_error)
  __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_out_view_strides); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3638, __pyx_L1_error)
  __pyx_t_15 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_out_view->__pyx_vtab)->_set_shape_and_strides(__pyx_v_out_view, __pyx_t_10, __pyx_t_11, 0, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3638, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":3641
 * 
 *     # (A B)^T = B^T A^T
 *     a, b = b, a             # <<<<<<<<<<<<<<
 * 
 *     lda = a.shape[-1]
 */
  __pyx_t_20 = ((PyObject *)__pyx_v_b);
  __pyx_t_21 = ((PyObject *)__pyx_v_a);
  __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_20);
  __pyx_t_20 = 0;
  __pyx_v_b = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_21);
  __pyx_t_21 = 0;

  /* "cupy/core/core.pyx":3643
 *     a, b = b, a
 * 
 *     lda = a.shape[-1]             # <<<<<<<<<<<<<<
 *     ldb = b.shape[-1]
 * 
 */
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3643, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_15, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3643, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_v_lda = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":3644
 * 
 *     lda = a.shape[-1]
 *     ldb = b.shape[-1]             # <<<<<<<<<<<<<<
 * 
 *     *la, ka, n = a.shape
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_15 = __Pyx_GetItemInt(__pyx_t_3, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_ldb = __pyx_t_15;
  __pyx_t_15 = 0;

  /* "cupy/core/core.pyx":3646
 *     ldb = b.shape[-1]
 * 
 *     *la, ka, n = a.shape             # <<<<<<<<<<<<<<
 *     *lb, m, kb = b.shape
 * 
 */
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_3 = PySequence_List(__pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_4 = PyList_GET_SIZE(__pyx_t_3);
  if (unlikely(__pyx_t_4 < 2)) {
    __Pyx_RaiseNeedMoreValuesError(0+__pyx_t_4); __PYX_ERR(0, 3646, __pyx_L1_error)
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4-1); 
  ((PyVarObject*)__pyx_t_3)->ob_size--;
  #else
  __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4-1); 
  #endif
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_17 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_17 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3646, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_13 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4-2); 
  ((PyVarObject*)__pyx_t_3)->ob_size--;
  #else
  __pyx_t_13 = PySequence_ITEM(__pyx_t_3, __pyx_t_4-2); 
  #endif
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_18 = __Pyx_PyIndex_AsSsize_t(__pyx_t_13); if (unlikely((__pyx_t_18 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3646, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  #if !CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_9 = PySequence_GetSlice(__pyx_t_3, 0, __pyx_t_4-2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_3);
  __pyx_t_3 = __pyx_t_9; __pyx_t_9 = NULL;
  #else

  #endif
  __pyx_v_la = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_ka = __pyx_t_18;
  __pyx_v_n = __pyx_t_17;

  /* "cupy/core/core.pyx":3647
 * 
 *     *la, ka, n = a.shape
 *     *lb, m, kb = b.shape             # <<<<<<<<<<<<<<
 * 
 *     if ka != kb:
 */
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3647, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_6 = PySequence_List(__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3647, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_17 = PyList_GET_SIZE(__pyx_t_6);
  if (unlikely(__pyx_t_17 < 2)) {
    __Pyx_RaiseNeedMoreValuesError(0+__pyx_t_17); __PYX_ERR(0, 3647, __pyx_L1_error)
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_13 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_17-1); 
  ((PyVarObject*)__pyx_t_6)->ob_size--;
  #else
  __pyx_t_13 = PySequence_ITEM(__pyx_t_6, __pyx_t_17-1); 
  #endif
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_18 = __Pyx_PyIndex_AsSsize_t(__pyx_t_13); if (unlikely((__pyx_t_18 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3647, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_17-2); 
  ((PyVarObject*)__pyx_t_6)->ob_size--;
  #else
  __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_17-2); 
  #endif
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3647, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  #if !CYTHON_COMPILING_IN_CPYTHON
  __pyx_t_9 = PySequence_GetSlice(__pyx_t_6, 0, __pyx_t_17-2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3647, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_6);
  __pyx_t_6 = __pyx_t_9; __pyx_t_9 = NULL;
  #else

  #endif
  __pyx_v_lb = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_v_m = __pyx_t_4;
  __pyx_v_kb = __pyx_t_18;

  /* "cupy/core/core.pyx":3649
 *     *lb, m, kb = b.shape
 * 
 *     if ka != kb:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'shapes ({}) and ({}) not aligned'.format(
 */
  __pyx_t_2 = ((__pyx_v_ka != __pyx_v_kb) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "cupy/core/core.pyx":3651
 *     if ka != kb:
 *         raise ValueError(
 *             'shapes ({}) and ({}) not aligned'.format(             # <<<<<<<<<<<<<<
 *                 ','.join([str(_) for _ in orig_a_shape]),
 *                 ','.join([str(_) for _ in orig_b_shape])))
 */
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_shapes_and_not_aligned, __pyx_n_s_format); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);

    /* "cupy/core/core.pyx":3652
 *         raise ValueError(
 *             'shapes ({}) and ({}) not aligned'.format(
 *                 ','.join([str(_) for _ in orig_a_shape]),             # <<<<<<<<<<<<<<
 *                 ','.join([str(_) for _ in orig_b_shape])))
 *     for la_, lb_ in zip(la, lb):
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_v_orig_a_shape)) || PyTuple_CheckExact(__pyx_v_orig_a_shape)) {
      __pyx_t_6 = __pyx_v_orig_a_shape; __Pyx_INCREF(__pyx_t_6); __pyx_t_18 = 0;
      __pyx_t_22 = NULL;
    } else {
      __pyx_t_18 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_orig_a_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3652, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_22 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3652, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_22)) {
        if (likely(PyList_CheckExact(__pyx_t_6))) {
          if (__pyx_t_18 >= PyList_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_18); __Pyx_INCREF(__pyx_t_9); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3652, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_6, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3652, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_18 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_18); __Pyx_INCREF(__pyx_t_9); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3652, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_6, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3652, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_22(__pyx_t_6);
        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(0, 3652, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v__); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3652, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 3652, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyString_Join(__pyx_kp_s__57, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3653
 *             'shapes ({}) and ({}) not aligned'.format(
 *                 ','.join([str(_) for _ in orig_a_shape]),
 *                 ','.join([str(_) for _ in orig_b_shape])))             # <<<<<<<<<<<<<<
 *     for la_, lb_ in zip(la, lb):
 *         if not (la_ == lb_ or la_ == 1 or lb_ == 1):
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3653, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_v_orig_b_shape)) || PyTuple_CheckExact(__pyx_v_orig_b_shape)) {
      __pyx_t_9 = __pyx_v_orig_b_shape; __Pyx_INCREF(__pyx_t_9); __pyx_t_18 = 0;
      __pyx_t_22 = NULL;
    } else {
      __pyx_t_18 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_v_orig_b_shape); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3653, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_22 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3653, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_22)) {
        if (likely(PyList_CheckExact(__pyx_t_9))) {
          if (__pyx_t_18 >= PyList_GET_SIZE(__pyx_t_9)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_8 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_18); __Pyx_INCREF(__pyx_t_8); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3653, __pyx_L1_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_9, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3653, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        } else {
          if (__pyx_t_18 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_18); __Pyx_INCREF(__pyx_t_8); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3653, __pyx_L1_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_9, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3653, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        }
      } else {
        __pyx_t_8 = __pyx_t_22(__pyx_t_9);
        if (unlikely(!__pyx_t_8)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 3653, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_8);
      }
      __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v__); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3653, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 3653, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyString_Join(__pyx_kp_s__57, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3653, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_13);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_13, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_13)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_6, __pyx_t_9};
      __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3651, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_6, __pyx_t_9};
      __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3651, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3651, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_9);
      __pyx_t_6 = 0;
      __pyx_t_9 = 0;
      __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_8, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3651, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

    /* "cupy/core/core.pyx":3650
 * 
 *     if ka != kb:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'shapes ({}) and ({}) not aligned'.format(
 *                 ','.join([str(_) for _ in orig_a_shape]),
 */
    __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_15); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3650, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_Raise(__pyx_t_13, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __PYX_ERR(0, 3650, __pyx_L1_error)

    /* "cupy/core/core.pyx":3649
 *     *lb, m, kb = b.shape
 * 
 *     if ka != kb:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'shapes ({}) and ({}) not aligned'.format(
 */
  }

  /* "cupy/core/core.pyx":3654
 *                 ','.join([str(_) for _ in orig_a_shape]),
 *                 ','.join([str(_) for _ in orig_b_shape])))
 *     for la_, lb_ in zip(la, lb):             # <<<<<<<<<<<<<<
 *         if not (la_ == lb_ or la_ == 1 or lb_ == 1):
 *             raise ValueError(
 */
  __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3654, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_INCREF(__pyx_v_la);
  __Pyx_GIVEREF(__pyx_v_la);
  PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_la);
  __Pyx_INCREF(__pyx_v_lb);
  __Pyx_GIVEREF(__pyx_v_lb);
  PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_lb);
  __pyx_t_15 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_13, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3654, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  if (likely(PyList_CheckExact(__pyx_t_15)) || PyTuple_CheckExact(__pyx_t_15)) {
    __pyx_t_13 = __pyx_t_15; __Pyx_INCREF(__pyx_t_13); __pyx_t_18 = 0;
    __pyx_t_22 = NULL;
  } else {
    __pyx_t_18 = -1; __pyx_t_13 = PyObject_GetIter(__pyx_t_15); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3654, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_22 = Py_TYPE(__pyx_t_13)->tp_iternext; if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3654, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  for (;;) {
    if (likely(!__pyx_t_22)) {
      if (likely(PyList_CheckExact(__pyx_t_13))) {
        if (__pyx_t_18 >= PyList_GET_SIZE(__pyx_t_13)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_15 = PyList_GET_ITEM(__pyx_t_13, __pyx_t_18); __Pyx_INCREF(__pyx_t_15); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3654, __pyx_L1_error)
        #else
        __pyx_t_15 = PySequence_ITEM(__pyx_t_13, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3654, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        #endif
      } else {
        if (__pyx_t_18 >= PyTuple_GET_SIZE(__pyx_t_13)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_15 = PyTuple_GET_ITEM(__pyx_t_13, __pyx_t_18); __Pyx_INCREF(__pyx_t_15); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3654, __pyx_L1_error)
        #else
        __pyx_t_15 = PySequence_ITEM(__pyx_t_13, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3654, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        #endif
      }
    } else {
      __pyx_t_15 = __pyx_t_22(__pyx_t_13);
      if (unlikely(!__pyx_t_15)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 3654, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_15);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_15))) || (PyList_CheckExact(__pyx_t_15))) {
      PyObject* sequence = __pyx_t_15;
      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(0, 3654, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      #else
      __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3654, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3654, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      #endif
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_6 = PyObject_GetIter(__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3654, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_23 = Py_TYPE(__pyx_t_6)->tp_iternext;
      index = 0; __pyx_t_8 = __pyx_t_23(__pyx_t_6); if (unlikely(!__pyx_t_8)) goto __pyx_L29_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_8);
      index = 1; __pyx_t_9 = __pyx_t_23(__pyx_t_6); if (unlikely(!__pyx_t_9)) goto __pyx_L29_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_9);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_23(__pyx_t_6), 2) < 0) __PYX_ERR(0, 3654, __pyx_L1_error)
      __pyx_t_23 = NULL;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L30_unpacking_done;
      __pyx_L29_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_23 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 3654, __pyx_L1_error)
      __pyx_L30_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_la_, __pyx_t_8);
    __pyx_t_8 = 0;
    __Pyx_XDECREF_SET(__pyx_v_lb_, __pyx_t_9);
    __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":3655
 *                 ','.join([str(_) for _ in orig_b_shape])))
 *     for la_, lb_ in zip(la, lb):
 *         if not (la_ == lb_ or la_ == 1 or lb_ == 1):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'operands could not be broadcast together with '
 */
    __pyx_t_15 = PyObject_RichCompare(__pyx_v_la_, __pyx_v_lb_, Py_EQ); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3655, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3655, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    if (!__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L32_bool_binop_done;
    }
    __pyx_t_15 = __Pyx_PyInt_EqObjC(__pyx_v_la_, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3655, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3655, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    if (!__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L32_bool_binop_done;
    }
    __pyx_t_15 = __Pyx_PyInt_EqObjC(__pyx_v_lb_, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3655, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3655, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_L32_bool_binop_done:;
    __pyx_t_1 = ((!__pyx_t_2) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "cupy/core/core.pyx":3656
 *     for la_, lb_ in zip(la, lb):
 *         if not (la_ == lb_ or la_ == 1 or lb_ == 1):
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'operands could not be broadcast together with '
 *                 'remapped shapes')
 */
      __pyx_t_15 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__163, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3656, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_Raise(__pyx_t_15, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __PYX_ERR(0, 3656, __pyx_L1_error)

      /* "cupy/core/core.pyx":3655
 *                 ','.join([str(_) for _ in orig_b_shape])))
 *     for la_, lb_ in zip(la, lb):
 *         if not (la_ == lb_ or la_ == 1 or lb_ == 1):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'operands could not be broadcast together with '
 */
    }

    /* "cupy/core/core.pyx":3654
 *                 ','.join([str(_) for _ in orig_a_shape]),
 *                 ','.join([str(_) for _ in orig_b_shape])))
 *     for la_, lb_ in zip(la, lb):             # <<<<<<<<<<<<<<
 *         if not (la_ == lb_ or la_ == 1 or lb_ == 1):
 *             raise ValueError(
 */
  }
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":3660
 *                 'remapped shapes')
 * 
 *     if a.size == 0 or b.size == 0:             # <<<<<<<<<<<<<<
 *         return cupy.zeros(out_shape, ret_dtype)
 * 
 */
  __pyx_t_2 = ((__pyx_v_a->size == 0) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L36_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_b->size == 0) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L36_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3661
 * 
 *     if a.size == 0 or b.size == 0:
 *         return cupy.zeros(out_shape, ret_dtype)             # <<<<<<<<<<<<<<
 * 
 *     batchCount = 1  # batchCount = numpy.prod(la)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_zeros); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_15)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_15);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[3] = {__pyx_t_15, __pyx_v_out_shape, __pyx_v_ret_dtype};
      __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3661, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_GOTREF(__pyx_t_13);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[3] = {__pyx_t_15, __pyx_v_out_shape, __pyx_v_ret_dtype};
      __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3661, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_GOTREF(__pyx_t_13);
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3661, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_15) {
        __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_15); __pyx_t_15 = NULL;
      }
      __Pyx_INCREF(__pyx_v_out_shape);
      __Pyx_GIVEREF(__pyx_v_out_shape);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_out_shape);
      __Pyx_INCREF(__pyx_v_ret_dtype);
      __Pyx_GIVEREF(__pyx_v_ret_dtype);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_ret_dtype);
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3661, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3661, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_13);
    __pyx_t_13 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3660
 *                 'remapped shapes')
 * 
 *     if a.size == 0 or b.size == 0:             # <<<<<<<<<<<<<<
 *         return cupy.zeros(out_shape, ret_dtype)
 * 
 */
  }

  /* "cupy/core/core.pyx":3663
 *         return cupy.zeros(out_shape, ret_dtype)
 * 
 *     batchCount = 1  # batchCount = numpy.prod(la)             # <<<<<<<<<<<<<<
 *     for i in la:
 *         batchCount *= i
 */
  __pyx_v_batchCount = 1;

  /* "cupy/core/core.pyx":3664
 * 
 *     batchCount = 1  # batchCount = numpy.prod(la)
 *     for i in la:             # <<<<<<<<<<<<<<
 *         batchCount *= i
 * 
 */
  if (likely(PyList_CheckExact(__pyx_v_la)) || PyTuple_CheckExact(__pyx_v_la)) {
    __pyx_t_13 = __pyx_v_la; __Pyx_INCREF(__pyx_t_13); __pyx_t_18 = 0;
    __pyx_t_22 = NULL;
  } else {
    __pyx_t_18 = -1; __pyx_t_13 = PyObject_GetIter(__pyx_v_la); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3664, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_22 = Py_TYPE(__pyx_t_13)->tp_iternext; if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3664, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_22)) {
      if (likely(PyList_CheckExact(__pyx_t_13))) {
        if (__pyx_t_18 >= PyList_GET_SIZE(__pyx_t_13)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyList_GET_ITEM(__pyx_t_13, __pyx_t_18); __Pyx_INCREF(__pyx_t_9); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3664, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_13, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3664, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      } else {
        if (__pyx_t_18 >= PyTuple_GET_SIZE(__pyx_t_13)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_13, __pyx_t_18); __Pyx_INCREF(__pyx_t_9); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 3664, __pyx_L1_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_13, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3664, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      }
    } else {
      __pyx_t_9 = __pyx_t_22(__pyx_t_13);
      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(0, 3664, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_9);
    }
    __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3664, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_i = __pyx_t_4;

    /* "cupy/core/core.pyx":3665
 *     batchCount = 1  # batchCount = numpy.prod(la)
 *     for i in la:
 *         batchCount *= i             # <<<<<<<<<<<<<<
 * 
 *     global _cuda_runtime_version
 */
    __pyx_v_batchCount = (__pyx_v_batchCount * __pyx_v_i);

    /* "cupy/core/core.pyx":3664
 * 
 *     batchCount = 1  # batchCount = numpy.prod(la)
 *     for i in la:             # <<<<<<<<<<<<<<
 *         batchCount *= i
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "cupy/core/core.pyx":3668
 * 
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  __pyx_t_1 = (__pyx_v_4cupy_4core_4core__cuda_runtime_version == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3669
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:
 *         _cuda_runtime_version = runtime.runtimeGetVersion()             # <<<<<<<<<<<<<<
 * 
 *     # TODO(anaruse) use cublasGemmStridedBatchedEx() when cuda version >= 9.1
 */
    __pyx_t_7 = __pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3669, __pyx_L1_error)
    __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3669, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cuda_runtime_version);
    __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cuda_runtime_version, __pyx_t_13);
    __Pyx_GIVEREF(__pyx_t_13);
    __pyx_t_13 = 0;

    /* "cupy/core/core.pyx":3668
 * 
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  }

  /* "cupy/core/core.pyx":3672
 * 
 *     # TODO(anaruse) use cublasGemmStridedBatchedEx() when cuda version >= 9.1
 *     if not use_broadcast and _cuda_runtime_version >= 8000:             # <<<<<<<<<<<<<<
 *         strideA = _get_stride_for_strided_batched_gemm(a)
 *         strideB = _get_stride_for_strided_batched_gemm(b)
 */
  __pyx_t_1 = ((!(__pyx_v_use_broadcast != 0)) != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L42_bool_binop_done;
  }
  __pyx_t_13 = PyObject_RichCompare(__pyx_v_4cupy_4core_4core__cuda_runtime_version, __pyx_int_8000, Py_GE); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3672, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3672, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_2 = __pyx_t_1;
  __pyx_L42_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3673
 *     # TODO(anaruse) use cublasGemmStridedBatchedEx() when cuda version >= 9.1
 *     if not use_broadcast and _cuda_runtime_version >= 8000:
 *         strideA = _get_stride_for_strided_batched_gemm(a)             # <<<<<<<<<<<<<<
 *         strideB = _get_stride_for_strided_batched_gemm(b)
 *         strideC = _get_stride_for_strided_batched_gemm(out_view)
 */
    __pyx_v_strideA = __pyx_f_4cupy_4core_4core__get_stride_for_strided_batched_gemm(__pyx_v_a, 0);

    /* "cupy/core/core.pyx":3674
 *     if not use_broadcast and _cuda_runtime_version >= 8000:
 *         strideA = _get_stride_for_strided_batched_gemm(a)
 *         strideB = _get_stride_for_strided_batched_gemm(b)             # <<<<<<<<<<<<<<
 *         strideC = _get_stride_for_strided_batched_gemm(out_view)
 *         if dtype == numpy.float32:
 */
    __pyx_v_strideB = __pyx_f_4cupy_4core_4core__get_stride_for_strided_batched_gemm(__pyx_v_b, 0);

    /* "cupy/core/core.pyx":3675
 *         strideA = _get_stride_for_strided_batched_gemm(a)
 *         strideB = _get_stride_for_strided_batched_gemm(b)
 *         strideC = _get_stride_for_strided_batched_gemm(out_view)             # <<<<<<<<<<<<<<
 *         if dtype == numpy.float32:
 *             cuda.cublas.sgemmStridedBatched(
 */
    __pyx_v_strideC = __pyx_f_4cupy_4core_4core__get_stride_for_strided_batched_gemm(__pyx_v_out_view, 0);

    /* "cupy/core/core.pyx":3676
 *         strideB = _get_stride_for_strided_batched_gemm(b)
 *         strideC = _get_stride_for_strided_batched_gemm(out_view)
 *         if dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *             cuda.cublas.sgemmStridedBatched(
 *                 cuda.Device().cublas_handle,
 */
    __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3676, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_float32); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3676, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3676, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3676, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3677
 *         strideC = _get_stride_for_strided_batched_gemm(out_view)
 *         if dtype == numpy.float32:
 *             cuda.cublas.sgemmStridedBatched(             # <<<<<<<<<<<<<<
 *                 cuda.Device().cublas_handle,
 *                 0,  # transa
 */
      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3677, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_cublas); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3677, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sgemmStridedBatched); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3677, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":3678
 *         if dtype == numpy.float32:
 *             cuda.cublas.sgemmStridedBatched(
 *                 cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3678, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_Device); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3678, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_15 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_15)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (__pyx_t_15) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3678, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      } else {
        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3678, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3678, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":3681
 *                 0,  # transa
 *                 0,  # transb
 *                 n, m, ka, 1.0,             # <<<<<<<<<<<<<<
 *                 a.data.ptr, lda, strideA,
 *                 b.data.ptr, ldb, strideB,
 */
      __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3681, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_15 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3681, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ka); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3681, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "cupy/core/core.pyx":3682
 *                 0,  # transb
 *                 n, m, ka, 1.0,
 *                 a.data.ptr, lda, strideA,             # <<<<<<<<<<<<<<
 *                 b.data.ptr, ldb, strideB,
 *                 0.0, out_view.data.ptr, ldout, strideC,
 */
      __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3682, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_strideA); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3682, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);

      /* "cupy/core/core.pyx":3683
 *                 n, m, ka, 1.0,
 *                 a.data.ptr, lda, strideA,
 *                 b.data.ptr, ldb, strideB,             # <<<<<<<<<<<<<<
 *                 0.0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 */
      __pyx_t_14 = __Pyx_PyInt_FromSize_t(__pyx_v_b->data->ptr); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3683, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_24 = __Pyx_PyInt_From_int(__pyx_v_strideB); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3683, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);

      /* "cupy/core/core.pyx":3684
 *                 a.data.ptr, lda, strideA,
 *                 b.data.ptr, ldb, strideB,
 *                 0.0, out_view.data.ptr, ldout, strideC,             # <<<<<<<<<<<<<<
 *                 batchCount)
 *         elif dtype == numpy.float64:
 */
      __pyx_t_25 = __Pyx_PyInt_FromSize_t(__pyx_v_out_view->data->ptr); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3684, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);
      __pyx_t_26 = __Pyx_PyInt_From_int(__pyx_v_strideC); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3684, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_26);

      /* "cupy/core/core.pyx":3685
 *                 b.data.ptr, ldb, strideB,
 *                 0.0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)             # <<<<<<<<<<<<<<
 *         elif dtype == numpy.float64:
 *             cuda.cublas.dgemmStridedBatched(
 */
      __pyx_t_27 = PyInt_FromSsize_t(__pyx_v_batchCount); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 3685, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_27);
      __pyx_t_28 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_28 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_28)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_28);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[19] = {__pyx_t_28, __pyx_t_6, __pyx_int_0, __pyx_int_0, __pyx_t_8, __pyx_t_15, __pyx_t_3, __pyx_float_1_0, __pyx_t_5, __pyx_v_lda, __pyx_t_12, __pyx_t_14, __pyx_v_ldb, __pyx_t_24, __pyx_float_0_0, __pyx_t_25, __pyx_v_ldout, __pyx_t_26, __pyx_t_27};
        __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 18+__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3677, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[19] = {__pyx_t_28, __pyx_t_6, __pyx_int_0, __pyx_int_0, __pyx_t_8, __pyx_t_15, __pyx_t_3, __pyx_float_1_0, __pyx_t_5, __pyx_v_lda, __pyx_t_12, __pyx_t_14, __pyx_v_ldb, __pyx_t_24, __pyx_float_0_0, __pyx_t_25, __pyx_v_ldout, __pyx_t_26, __pyx_t_27};
        __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 18+__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3677, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      } else
      #endif
      {
        __pyx_t_29 = PyTuple_New(18+__pyx_t_7); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3677, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_29);
        if (__pyx_t_28) {
          __Pyx_GIVEREF(__pyx_t_28); PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_t_28); __pyx_t_28 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_29, 0+__pyx_t_7, __pyx_t_6);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_29, 1+__pyx_t_7, __pyx_int_0);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_29, 2+__pyx_t_7, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_29, 3+__pyx_t_7, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_29, 4+__pyx_t_7, __pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_29, 5+__pyx_t_7, __pyx_t_3);
        __Pyx_INCREF(__pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_float_1_0);
        PyTuple_SET_ITEM(__pyx_t_29, 6+__pyx_t_7, __pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_29, 7+__pyx_t_7, __pyx_t_5);
        __Pyx_INCREF(__pyx_v_lda);
        __Pyx_GIVEREF(__pyx_v_lda);
        PyTuple_SET_ITEM(__pyx_t_29, 8+__pyx_t_7, __pyx_v_lda);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_29, 9+__pyx_t_7, __pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_29, 10+__pyx_t_7, __pyx_t_14);
        __Pyx_INCREF(__pyx_v_ldb);
        __Pyx_GIVEREF(__pyx_v_ldb);
        PyTuple_SET_ITEM(__pyx_t_29, 11+__pyx_t_7, __pyx_v_ldb);
        __Pyx_GIVEREF(__pyx_t_24);
        PyTuple_SET_ITEM(__pyx_t_29, 12+__pyx_t_7, __pyx_t_24);
        __Pyx_INCREF(__pyx_float_0_0);
        __Pyx_GIVEREF(__pyx_float_0_0);
        PyTuple_SET_ITEM(__pyx_t_29, 13+__pyx_t_7, __pyx_float_0_0);
        __Pyx_GIVEREF(__pyx_t_25);
        PyTuple_SET_ITEM(__pyx_t_29, 14+__pyx_t_7, __pyx_t_25);
        __Pyx_INCREF(__pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_v_ldout);
        PyTuple_SET_ITEM(__pyx_t_29, 15+__pyx_t_7, __pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_t_26);
        PyTuple_SET_ITEM(__pyx_t_29, 16+__pyx_t_7, __pyx_t_26);
        __Pyx_GIVEREF(__pyx_t_27);
        PyTuple_SET_ITEM(__pyx_t_29, 17+__pyx_t_7, __pyx_t_27);
        __pyx_t_6 = 0;
        __pyx_t_8 = 0;
        __pyx_t_15 = 0;
        __pyx_t_3 = 0;
        __pyx_t_5 = 0;
        __pyx_t_12 = 0;
        __pyx_t_14 = 0;
        __pyx_t_24 = 0;
        __pyx_t_25 = 0;
        __pyx_t_26 = 0;
        __pyx_t_27 = 0;
        __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_29, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3677, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "cupy/core/core.pyx":3676
 *         strideB = _get_stride_for_strided_batched_gemm(b)
 *         strideC = _get_stride_for_strided_batched_gemm(out_view)
 *         if dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *             cuda.cublas.sgemmStridedBatched(
 *                 cuda.Device().cublas_handle,
 */
      goto __pyx_L44;
    }

    /* "cupy/core/core.pyx":3686
 *                 0.0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 *         elif dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *             cuda.cublas.dgemmStridedBatched(
 *                 cuda.Device().cublas_handle,
 */
    __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3686, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_float64); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3686, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3686, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3686, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3687
 *                 batchCount)
 *         elif dtype == numpy.float64:
 *             cuda.cublas.dgemmStridedBatched(             # <<<<<<<<<<<<<<
 *                 cuda.Device().cublas_handle,
 *                 0,  # transa
 */
      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3687, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_29 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_cublas); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3687, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_29, __pyx_n_s_dgemmStridedBatched); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3687, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;

      /* "cupy/core/core.pyx":3688
 *         elif dtype == numpy.float64:
 *             cuda.cublas.dgemmStridedBatched(
 *                 cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_27 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 3688, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_27);
      __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_27, __pyx_n_s_Device); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3688, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      __pyx_t_27 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_26))) {
        __pyx_t_27 = PyMethod_GET_SELF(__pyx_t_26);
        if (likely(__pyx_t_27)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_26);
          __Pyx_INCREF(__pyx_t_27);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_26, function);
        }
      }
      if (__pyx_t_27) {
        __pyx_t_29 = __Pyx_PyObject_CallOneArg(__pyx_t_26, __pyx_t_27); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3688, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      } else {
        __pyx_t_29 = __Pyx_PyObject_CallNoArg(__pyx_t_26); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3688, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_29, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3688, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;

      /* "cupy/core/core.pyx":3691
 *                 0,  # transa
 *                 0,  # transb
 *                 n, m, ka, 1.0,             # <<<<<<<<<<<<<<
 *                 a.data.ptr, lda, strideA,
 *                 b.data.ptr, ldb, strideB,
 */
      __pyx_t_29 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3691, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_29);
      __pyx_t_27 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 3691, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_27);
      __pyx_t_25 = PyInt_FromSsize_t(__pyx_v_ka); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3691, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);

      /* "cupy/core/core.pyx":3692
 *                 0,  # transb
 *                 n, m, ka, 1.0,
 *                 a.data.ptr, lda, strideA,             # <<<<<<<<<<<<<<
 *                 b.data.ptr, ldb, strideB,
 *                 0.0, out_view.data.ptr, ldout, strideC,
 */
      __pyx_t_24 = __Pyx_PyInt_FromSize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3692, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);
      __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_strideA); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3692, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);

      /* "cupy/core/core.pyx":3693
 *                 n, m, ka, 1.0,
 *                 a.data.ptr, lda, strideA,
 *                 b.data.ptr, ldb, strideB,             # <<<<<<<<<<<<<<
 *                 0.0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 */
      __pyx_t_12 = __Pyx_PyInt_FromSize_t(__pyx_v_b->data->ptr); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3693, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_strideB); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3693, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);

      /* "cupy/core/core.pyx":3694
 *                 a.data.ptr, lda, strideA,
 *                 b.data.ptr, ldb, strideB,
 *                 0.0, out_view.data.ptr, ldout, strideC,             # <<<<<<<<<<<<<<
 *                 batchCount)
 *         elif dtype == numpy.complex64:
 */
      __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_out_view->data->ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3694, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_15 = __Pyx_PyInt_From_int(__pyx_v_strideC); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3694, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);

      /* "cupy/core/core.pyx":3695
 *                 b.data.ptr, ldb, strideB,
 *                 0.0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)             # <<<<<<<<<<<<<<
 *         elif dtype == numpy.complex64:
 *             cuda.cublas.cgemmStridedBatched(
 */
      __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_batchCount); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3695, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_6 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[19] = {__pyx_t_6, __pyx_t_26, __pyx_int_0, __pyx_int_0, __pyx_t_29, __pyx_t_27, __pyx_t_25, __pyx_float_1_0, __pyx_t_24, __pyx_v_lda, __pyx_t_14, __pyx_t_12, __pyx_v_ldb, __pyx_t_5, __pyx_float_0_0, __pyx_t_3, __pyx_v_ldout, __pyx_t_15, __pyx_t_8};
        __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 18+__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3687, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
        __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[19] = {__pyx_t_6, __pyx_t_26, __pyx_int_0, __pyx_int_0, __pyx_t_29, __pyx_t_27, __pyx_t_25, __pyx_float_1_0, __pyx_t_24, __pyx_v_lda, __pyx_t_14, __pyx_t_12, __pyx_v_ldb, __pyx_t_5, __pyx_float_0_0, __pyx_t_3, __pyx_v_ldout, __pyx_t_15, __pyx_t_8};
        __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 18+__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3687, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
        __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_28 = PyTuple_New(18+__pyx_t_7); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3687, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_28);
        if (__pyx_t_6) {
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_28, 0, __pyx_t_6); __pyx_t_6 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_26);
        PyTuple_SET_ITEM(__pyx_t_28, 0+__pyx_t_7, __pyx_t_26);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_28, 1+__pyx_t_7, __pyx_int_0);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_28, 2+__pyx_t_7, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_29);
        PyTuple_SET_ITEM(__pyx_t_28, 3+__pyx_t_7, __pyx_t_29);
        __Pyx_GIVEREF(__pyx_t_27);
        PyTuple_SET_ITEM(__pyx_t_28, 4+__pyx_t_7, __pyx_t_27);
        __Pyx_GIVEREF(__pyx_t_25);
        PyTuple_SET_ITEM(__pyx_t_28, 5+__pyx_t_7, __pyx_t_25);
        __Pyx_INCREF(__pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_float_1_0);
        PyTuple_SET_ITEM(__pyx_t_28, 6+__pyx_t_7, __pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_t_24);
        PyTuple_SET_ITEM(__pyx_t_28, 7+__pyx_t_7, __pyx_t_24);
        __Pyx_INCREF(__pyx_v_lda);
        __Pyx_GIVEREF(__pyx_v_lda);
        PyTuple_SET_ITEM(__pyx_t_28, 8+__pyx_t_7, __pyx_v_lda);
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_28, 9+__pyx_t_7, __pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_28, 10+__pyx_t_7, __pyx_t_12);
        __Pyx_INCREF(__pyx_v_ldb);
        __Pyx_GIVEREF(__pyx_v_ldb);
        PyTuple_SET_ITEM(__pyx_t_28, 11+__pyx_t_7, __pyx_v_ldb);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_28, 12+__pyx_t_7, __pyx_t_5);
        __Pyx_INCREF(__pyx_float_0_0);
        __Pyx_GIVEREF(__pyx_float_0_0);
        PyTuple_SET_ITEM(__pyx_t_28, 13+__pyx_t_7, __pyx_float_0_0);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_28, 14+__pyx_t_7, __pyx_t_3);
        __Pyx_INCREF(__pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_v_ldout);
        PyTuple_SET_ITEM(__pyx_t_28, 15+__pyx_t_7, __pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_28, 16+__pyx_t_7, __pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_28, 17+__pyx_t_7, __pyx_t_8);
        __pyx_t_26 = 0;
        __pyx_t_29 = 0;
        __pyx_t_27 = 0;
        __pyx_t_25 = 0;
        __pyx_t_24 = 0;
        __pyx_t_14 = 0;
        __pyx_t_12 = 0;
        __pyx_t_5 = 0;
        __pyx_t_3 = 0;
        __pyx_t_15 = 0;
        __pyx_t_8 = 0;
        __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_28, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3687, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "cupy/core/core.pyx":3686
 *                 0.0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 *         elif dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *             cuda.cublas.dgemmStridedBatched(
 *                 cuda.Device().cublas_handle,
 */
      goto __pyx_L44;
    }

    /* "cupy/core/core.pyx":3696
 *                 0.0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 *         elif dtype == numpy.complex64:             # <<<<<<<<<<<<<<
 *             cuda.cublas.cgemmStridedBatched(
 *                 cuda.Device().cublas_handle,
 */
    __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3696, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_complex64); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3696, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3696, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3696, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3697
 *                 batchCount)
 *         elif dtype == numpy.complex64:
 *             cuda.cublas.cgemmStridedBatched(             # <<<<<<<<<<<<<<
 *                 cuda.Device().cublas_handle,
 *                 0,  # transa
 */
      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3697, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_28 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_cublas); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3697, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_28);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_28, __pyx_n_s_cgemmStridedBatched); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3697, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;

      /* "cupy/core/core.pyx":3698
 *         elif dtype == numpy.complex64:
 *             cuda.cublas.cgemmStridedBatched(
 *                 cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3698, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_Device); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3698, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_15);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_15, function);
        }
      }
      if (__pyx_t_8) {
        __pyx_t_28 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_8); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3698, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else {
        __pyx_t_28 = __Pyx_PyObject_CallNoArg(__pyx_t_15); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3698, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_28);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_28, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3698, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;

      /* "cupy/core/core.pyx":3701
 *                 0,  # transa
 *                 0,  # transb
 *                 n, m, ka, 1,             # <<<<<<<<<<<<<<
 *                 a.data.ptr, lda, strideA,
 *                 b.data.ptr, ldb, strideB,
 */
      __pyx_t_28 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3701, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_28);
      __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3701, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ka); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3701, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "cupy/core/core.pyx":3702
 *                 0,  # transb
 *                 n, m, ka, 1,
 *                 a.data.ptr, lda, strideA,             # <<<<<<<<<<<<<<
 *                 b.data.ptr, ldb, strideB,
 *                 0, out_view.data.ptr, ldout, strideC,
 */
      __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3702, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_strideA); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3702, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);

      /* "cupy/core/core.pyx":3703
 *                 n, m, ka, 1,
 *                 a.data.ptr, lda, strideA,
 *                 b.data.ptr, ldb, strideB,             # <<<<<<<<<<<<<<
 *                 0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 */
      __pyx_t_14 = __Pyx_PyInt_FromSize_t(__pyx_v_b->data->ptr); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3703, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_24 = __Pyx_PyInt_From_int(__pyx_v_strideB); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3703, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);

      /* "cupy/core/core.pyx":3704
 *                 a.data.ptr, lda, strideA,
 *                 b.data.ptr, ldb, strideB,
 *                 0, out_view.data.ptr, ldout, strideC,             # <<<<<<<<<<<<<<
 *                 batchCount)
 *         elif dtype == numpy.complex128:
 */
      __pyx_t_25 = __Pyx_PyInt_FromSize_t(__pyx_v_out_view->data->ptr); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3704, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);
      __pyx_t_27 = __Pyx_PyInt_From_int(__pyx_v_strideC); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 3704, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_27);

      /* "cupy/core/core.pyx":3705
 *                 b.data.ptr, ldb, strideB,
 *                 0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)             # <<<<<<<<<<<<<<
 *         elif dtype == numpy.complex128:
 *             cuda.cublas.zgemmStridedBatched(
 */
      __pyx_t_29 = PyInt_FromSsize_t(__pyx_v_batchCount); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3705, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_29);
      __pyx_t_26 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_26)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_26);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[19] = {__pyx_t_26, __pyx_t_15, __pyx_int_0, __pyx_int_0, __pyx_t_28, __pyx_t_8, __pyx_t_3, __pyx_int_1, __pyx_t_5, __pyx_v_lda, __pyx_t_12, __pyx_t_14, __pyx_v_ldb, __pyx_t_24, __pyx_int_0, __pyx_t_25, __pyx_v_ldout, __pyx_t_27, __pyx_t_29};
        __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 18+__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3697, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[19] = {__pyx_t_26, __pyx_t_15, __pyx_int_0, __pyx_int_0, __pyx_t_28, __pyx_t_8, __pyx_t_3, __pyx_int_1, __pyx_t_5, __pyx_v_lda, __pyx_t_12, __pyx_t_14, __pyx_v_ldb, __pyx_t_24, __pyx_int_0, __pyx_t_25, __pyx_v_ldout, __pyx_t_27, __pyx_t_29};
        __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 18+__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3697, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(18+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3697, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_26) {
          __Pyx_GIVEREF(__pyx_t_26); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_26); __pyx_t_26 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_t_15);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_int_0);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_7, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_28);
        PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_7, __pyx_t_28);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_7, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_6, 5+__pyx_t_7, __pyx_t_3);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_6, 6+__pyx_t_7, __pyx_int_1);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_6, 7+__pyx_t_7, __pyx_t_5);
        __Pyx_INCREF(__pyx_v_lda);
        __Pyx_GIVEREF(__pyx_v_lda);
        PyTuple_SET_ITEM(__pyx_t_6, 8+__pyx_t_7, __pyx_v_lda);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_6, 9+__pyx_t_7, __pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_6, 10+__pyx_t_7, __pyx_t_14);
        __Pyx_INCREF(__pyx_v_ldb);
        __Pyx_GIVEREF(__pyx_v_ldb);
        PyTuple_SET_ITEM(__pyx_t_6, 11+__pyx_t_7, __pyx_v_ldb);
        __Pyx_GIVEREF(__pyx_t_24);
        PyTuple_SET_ITEM(__pyx_t_6, 12+__pyx_t_7, __pyx_t_24);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_6, 13+__pyx_t_7, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_25);
        PyTuple_SET_ITEM(__pyx_t_6, 14+__pyx_t_7, __pyx_t_25);
        __Pyx_INCREF(__pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_v_ldout);
        PyTuple_SET_ITEM(__pyx_t_6, 15+__pyx_t_7, __pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_t_27);
        PyTuple_SET_ITEM(__pyx_t_6, 16+__pyx_t_7, __pyx_t_27);
        __Pyx_GIVEREF(__pyx_t_29);
        PyTuple_SET_ITEM(__pyx_t_6, 17+__pyx_t_7, __pyx_t_29);
        __pyx_t_15 = 0;
        __pyx_t_28 = 0;
        __pyx_t_8 = 0;
        __pyx_t_3 = 0;
        __pyx_t_5 = 0;
        __pyx_t_12 = 0;
        __pyx_t_14 = 0;
        __pyx_t_24 = 0;
        __pyx_t_25 = 0;
        __pyx_t_27 = 0;
        __pyx_t_29 = 0;
        __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_6, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3697, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "cupy/core/core.pyx":3696
 *                 0.0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 *         elif dtype == numpy.complex64:             # <<<<<<<<<<<<<<
 *             cuda.cublas.cgemmStridedBatched(
 *                 cuda.Device().cublas_handle,
 */
      goto __pyx_L44;
    }

    /* "cupy/core/core.pyx":3706
 *                 0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 *         elif dtype == numpy.complex128:             # <<<<<<<<<<<<<<
 *             cuda.cublas.zgemmStridedBatched(
 *                 cuda.Device().cublas_handle,
 */
    __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3706, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_complex128); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3706, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3706, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3706, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    if (likely(__pyx_t_2)) {

      /* "cupy/core/core.pyx":3707
 *                 batchCount)
 *         elif dtype == numpy.complex128:
 *             cuda.cublas.zgemmStridedBatched(             # <<<<<<<<<<<<<<
 *                 cuda.Device().cublas_handle,
 *                 0,  # transa
 */
      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3707, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_cublas); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3707, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zgemmStridedBatched); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3707, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/core.pyx":3708
 *         elif dtype == numpy.complex128:
 *             cuda.cublas.zgemmStridedBatched(
 *                 cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_29 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3708, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_29);
      __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_29, __pyx_n_s_Device); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 3708, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      __pyx_t_29 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_27))) {
        __pyx_t_29 = PyMethod_GET_SELF(__pyx_t_27);
        if (likely(__pyx_t_29)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_27);
          __Pyx_INCREF(__pyx_t_29);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_27, function);
        }
      }
      if (__pyx_t_29) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_27, __pyx_t_29); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3708, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      } else {
        __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_27); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3708, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 3708, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/core.pyx":3711
 *                 0,  # transa
 *                 0,  # transb
 *                 n, m, ka, 1,             # <<<<<<<<<<<<<<
 *                 a.data.ptr, lda, strideA,
 *                 b.data.ptr, ldb, strideB,
 */
      __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3711, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_29 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3711, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_29);
      __pyx_t_25 = PyInt_FromSsize_t(__pyx_v_ka); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3711, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);

      /* "cupy/core/core.pyx":3712
 *                 0,  # transb
 *                 n, m, ka, 1,
 *                 a.data.ptr, lda, strideA,             # <<<<<<<<<<<<<<
 *                 b.data.ptr, ldb, strideB,
 *                 0, out_view.data.ptr, ldout, strideC,
 */
      __pyx_t_24 = __Pyx_PyInt_FromSize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3712, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);
      __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_strideA); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3712, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);

      /* "cupy/core/core.pyx":3713
 *                 n, m, ka, 1,
 *                 a.data.ptr, lda, strideA,
 *                 b.data.ptr, ldb, strideB,             # <<<<<<<<<<<<<<
 *                 0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 */
      __pyx_t_12 = __Pyx_PyInt_FromSize_t(__pyx_v_b->data->ptr); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3713, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_strideB); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3713, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);

      /* "cupy/core/core.pyx":3714
 *                 a.data.ptr, lda, strideA,
 *                 b.data.ptr, ldb, strideB,
 *                 0, out_view.data.ptr, ldout, strideC,             # <<<<<<<<<<<<<<
 *                 batchCount)
 *         else:
 */
      __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_out_view->data->ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3714, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_strideC); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3714, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);

      /* "cupy/core/core.pyx":3715
 *                 b.data.ptr, ldb, strideB,
 *                 0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError(dtype, a.dtype, b.dtype)
 */
      __pyx_t_28 = PyInt_FromSsize_t(__pyx_v_batchCount); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3715, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_28);
      __pyx_t_15 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_15)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[19] = {__pyx_t_15, __pyx_t_27, __pyx_int_0, __pyx_int_0, __pyx_t_6, __pyx_t_29, __pyx_t_25, __pyx_int_1, __pyx_t_24, __pyx_v_lda, __pyx_t_14, __pyx_t_12, __pyx_v_ldb, __pyx_t_5, __pyx_int_0, __pyx_t_3, __pyx_v_ldout, __pyx_t_8, __pyx_t_28};
        __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 18+__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3707, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[19] = {__pyx_t_15, __pyx_t_27, __pyx_int_0, __pyx_int_0, __pyx_t_6, __pyx_t_29, __pyx_t_25, __pyx_int_1, __pyx_t_24, __pyx_v_lda, __pyx_t_14, __pyx_t_12, __pyx_v_ldb, __pyx_t_5, __pyx_int_0, __pyx_t_3, __pyx_v_ldout, __pyx_t_8, __pyx_t_28};
        __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 18+__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3707, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      } else
      #endif
      {
        __pyx_t_26 = PyTuple_New(18+__pyx_t_7); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3707, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_26);
        if (__pyx_t_15) {
          __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_26, 0, __pyx_t_15); __pyx_t_15 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_27);
        PyTuple_SET_ITEM(__pyx_t_26, 0+__pyx_t_7, __pyx_t_27);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_26, 1+__pyx_t_7, __pyx_int_0);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_26, 2+__pyx_t_7, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_26, 3+__pyx_t_7, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_29);
        PyTuple_SET_ITEM(__pyx_t_26, 4+__pyx_t_7, __pyx_t_29);
        __Pyx_GIVEREF(__pyx_t_25);
        PyTuple_SET_ITEM(__pyx_t_26, 5+__pyx_t_7, __pyx_t_25);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_26, 6+__pyx_t_7, __pyx_int_1);
        __Pyx_GIVEREF(__pyx_t_24);
        PyTuple_SET_ITEM(__pyx_t_26, 7+__pyx_t_7, __pyx_t_24);
        __Pyx_INCREF(__pyx_v_lda);
        __Pyx_GIVEREF(__pyx_v_lda);
        PyTuple_SET_ITEM(__pyx_t_26, 8+__pyx_t_7, __pyx_v_lda);
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_26, 9+__pyx_t_7, __pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_26, 10+__pyx_t_7, __pyx_t_12);
        __Pyx_INCREF(__pyx_v_ldb);
        __Pyx_GIVEREF(__pyx_v_ldb);
        PyTuple_SET_ITEM(__pyx_t_26, 11+__pyx_t_7, __pyx_v_ldb);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_26, 12+__pyx_t_7, __pyx_t_5);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_26, 13+__pyx_t_7, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_26, 14+__pyx_t_7, __pyx_t_3);
        __Pyx_INCREF(__pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_v_ldout);
        PyTuple_SET_ITEM(__pyx_t_26, 15+__pyx_t_7, __pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_26, 16+__pyx_t_7, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_28);
        PyTuple_SET_ITEM(__pyx_t_26, 17+__pyx_t_7, __pyx_t_28);
        __pyx_t_27 = 0;
        __pyx_t_6 = 0;
        __pyx_t_29 = 0;
        __pyx_t_25 = 0;
        __pyx_t_24 = 0;
        __pyx_t_14 = 0;
        __pyx_t_12 = 0;
        __pyx_t_5 = 0;
        __pyx_t_3 = 0;
        __pyx_t_8 = 0;
        __pyx_t_28 = 0;
        __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_26, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3707, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "cupy/core/core.pyx":3706
 *                 0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 *         elif dtype == numpy.complex128:             # <<<<<<<<<<<<<<
 *             cuda.cublas.zgemmStridedBatched(
 *                 cuda.Device().cublas_handle,
 */
      goto __pyx_L44;
    }

    /* "cupy/core/core.pyx":3717
 *                 batchCount)
 *         else:
 *             raise TypeError(dtype, a.dtype, b.dtype)             # <<<<<<<<<<<<<<
 *     else:
 *         ap = _mat_ptrs(a)
 */
    /*else*/ {
      __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_dtype);
      __Pyx_INCREF(__pyx_v_a->dtype);
      __Pyx_GIVEREF(__pyx_v_a->dtype);
      PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_a->dtype);
      __Pyx_INCREF(__pyx_v_b->dtype);
      __Pyx_GIVEREF(__pyx_v_b->dtype);
      PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_v_b->dtype);
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_13, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 3717, __pyx_L1_error)
    }
    __pyx_L44:;

    /* "cupy/core/core.pyx":3672
 * 
 *     # TODO(anaruse) use cublasGemmStridedBatchedEx() when cuda version >= 9.1
 *     if not use_broadcast and _cuda_runtime_version >= 8000:             # <<<<<<<<<<<<<<
 *         strideA = _get_stride_for_strided_batched_gemm(a)
 *         strideB = _get_stride_for_strided_batched_gemm(b)
 */
    goto __pyx_L41;
  }

  /* "cupy/core/core.pyx":3719
 *             raise TypeError(dtype, a.dtype, b.dtype)
 *     else:
 *         ap = _mat_ptrs(a)             # <<<<<<<<<<<<<<
 *         bp = _mat_ptrs(b)
 *         outp = _mat_ptrs(out_view)
 */
  /*else*/ {
    __pyx_t_9 = ((PyObject *)__pyx_f_4cupy_4core_4core__mat_ptrs(__pyx_v_a)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3719, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_v_ap = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_9);
    __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":3720
 *     else:
 *         ap = _mat_ptrs(a)
 *         bp = _mat_ptrs(b)             # <<<<<<<<<<<<<<
 *         outp = _mat_ptrs(out_view)
 *         if dtype == numpy.float32:
 */
    __pyx_t_9 = ((PyObject *)__pyx_f_4cupy_4core_4core__mat_ptrs(__pyx_v_b)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3720, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_v_bp = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_9);
    __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":3721
 *         ap = _mat_ptrs(a)
 *         bp = _mat_ptrs(b)
 *         outp = _mat_ptrs(out_view)             # <<<<<<<<<<<<<<
 *         if dtype == numpy.float32:
 *             cuda.cublas.sgemmBatched(
 */
    __pyx_t_9 = ((PyObject *)__pyx_f_4cupy_4core_4core__mat_ptrs(__pyx_v_out_view)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3721, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_v_outp = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_9);
    __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":3722
 *         bp = _mat_ptrs(b)
 *         outp = _mat_ptrs(out_view)
 *         if dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *             cuda.cublas.sgemmBatched(
 *                 cuda.Device().cublas_handle,
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_float32); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_13, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3722, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3722, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3723
 *         outp = _mat_ptrs(out_view)
 *         if dtype == numpy.float32:
 *             cuda.cublas.sgemmBatched(             # <<<<<<<<<<<<<<
 *                 cuda.Device().cublas_handle,
 *                 0,  # transa
 */
      __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3723, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_cublas); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3723, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_n_s_sgemmBatched); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3723, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;

      /* "cupy/core/core.pyx":3724
 *         if dtype == numpy.float32:
 *             cuda.cublas.sgemmBatched(
 *                 cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_28 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3724, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_28);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_28, __pyx_n_s_Device); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3724, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      __pyx_t_28 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_28 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_28)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_28);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_28) {
        __pyx_t_26 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_28); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3724, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      } else {
        __pyx_t_26 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3724, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3724, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;

      /* "cupy/core/core.pyx":3727
 *                 0,  # transa
 *                 0,  # transb
 *                 n, m, ka, 1.0,             # <<<<<<<<<<<<<<
 *                 ap.data.ptr, lda,
 *                 bp.data.ptr, ldb,
 */
      __pyx_t_26 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3727, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_26);
      __pyx_t_28 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3727, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_28);
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ka); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3727, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "cupy/core/core.pyx":3728
 *                 0,  # transb
 *                 n, m, ka, 1.0,
 *                 ap.data.ptr, lda,             # <<<<<<<<<<<<<<
 *                 bp.data.ptr, ldb,
 *                 0.0, outp.data.ptr, ldout, batchCount)
 */
      __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_ap->data->ptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3728, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);

      /* "cupy/core/core.pyx":3729
 *                 n, m, ka, 1.0,
 *                 ap.data.ptr, lda,
 *                 bp.data.ptr, ldb,             # <<<<<<<<<<<<<<
 *                 0.0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.float64:
 */
      __pyx_t_12 = __Pyx_PyInt_FromSize_t(__pyx_v_bp->data->ptr); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3729, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);

      /* "cupy/core/core.pyx":3730
 *                 ap.data.ptr, lda,
 *                 bp.data.ptr, ldb,
 *                 0.0, outp.data.ptr, ldout, batchCount)             # <<<<<<<<<<<<<<
 *         elif dtype == numpy.float64:
 *             cuda.cublas.dgemmBatched(
 */
      __pyx_t_14 = __Pyx_PyInt_FromSize_t(__pyx_v_outp->data->ptr); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3730, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_24 = PyInt_FromSsize_t(__pyx_v_batchCount); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3730, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);
      __pyx_t_25 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_25)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_25);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
          __pyx_t_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[16] = {__pyx_t_25, __pyx_t_8, __pyx_int_0, __pyx_int_0, __pyx_t_26, __pyx_t_28, __pyx_t_3, __pyx_float_1_0, __pyx_t_5, __pyx_v_lda, __pyx_t_12, __pyx_v_ldb, __pyx_float_0_0, __pyx_t_14, __pyx_v_ldout, __pyx_t_24};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_7, 15+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3723, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[16] = {__pyx_t_25, __pyx_t_8, __pyx_int_0, __pyx_int_0, __pyx_t_26, __pyx_t_28, __pyx_t_3, __pyx_float_1_0, __pyx_t_5, __pyx_v_lda, __pyx_t_12, __pyx_v_ldb, __pyx_float_0_0, __pyx_t_14, __pyx_v_ldout, __pyx_t_24};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_7, 15+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3723, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      } else
      #endif
      {
        __pyx_t_29 = PyTuple_New(15+__pyx_t_7); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3723, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_29);
        if (__pyx_t_25) {
          __Pyx_GIVEREF(__pyx_t_25); PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_t_25); __pyx_t_25 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_29, 0+__pyx_t_7, __pyx_t_8);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_29, 1+__pyx_t_7, __pyx_int_0);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_29, 2+__pyx_t_7, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_26);
        PyTuple_SET_ITEM(__pyx_t_29, 3+__pyx_t_7, __pyx_t_26);
        __Pyx_GIVEREF(__pyx_t_28);
        PyTuple_SET_ITEM(__pyx_t_29, 4+__pyx_t_7, __pyx_t_28);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_29, 5+__pyx_t_7, __pyx_t_3);
        __Pyx_INCREF(__pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_float_1_0);
        PyTuple_SET_ITEM(__pyx_t_29, 6+__pyx_t_7, __pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_29, 7+__pyx_t_7, __pyx_t_5);
        __Pyx_INCREF(__pyx_v_lda);
        __Pyx_GIVEREF(__pyx_v_lda);
        PyTuple_SET_ITEM(__pyx_t_29, 8+__pyx_t_7, __pyx_v_lda);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_29, 9+__pyx_t_7, __pyx_t_12);
        __Pyx_INCREF(__pyx_v_ldb);
        __Pyx_GIVEREF(__pyx_v_ldb);
        PyTuple_SET_ITEM(__pyx_t_29, 10+__pyx_t_7, __pyx_v_ldb);
        __Pyx_INCREF(__pyx_float_0_0);
        __Pyx_GIVEREF(__pyx_float_0_0);
        PyTuple_SET_ITEM(__pyx_t_29, 11+__pyx_t_7, __pyx_float_0_0);
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_29, 12+__pyx_t_7, __pyx_t_14);
        __Pyx_INCREF(__pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_v_ldout);
        PyTuple_SET_ITEM(__pyx_t_29, 13+__pyx_t_7, __pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_t_24);
        PyTuple_SET_ITEM(__pyx_t_29, 14+__pyx_t_7, __pyx_t_24);
        __pyx_t_8 = 0;
        __pyx_t_26 = 0;
        __pyx_t_28 = 0;
        __pyx_t_3 = 0;
        __pyx_t_5 = 0;
        __pyx_t_12 = 0;
        __pyx_t_14 = 0;
        __pyx_t_24 = 0;
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_29, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3723, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "cupy/core/core.pyx":3722
 *         bp = _mat_ptrs(b)
 *         outp = _mat_ptrs(out_view)
 *         if dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *             cuda.cublas.sgemmBatched(
 *                 cuda.Device().cublas_handle,
 */
      goto __pyx_L45;
    }

    /* "cupy/core/core.pyx":3731
 *                 bp.data.ptr, ldb,
 *                 0.0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *             cuda.cublas.dgemmBatched(
 *                 cuda.Device().cublas_handle,
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3731, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_float64); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3731, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_13, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3731, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3731, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3732
 *                 0.0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.float64:
 *             cuda.cublas.dgemmBatched(             # <<<<<<<<<<<<<<
 *                 cuda.Device().cublas_handle,
 *                 0,  # transa
 */
      __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3732, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_29 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_cublas); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3732, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_29, __pyx_n_s_dgemmBatched); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3732, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;

      /* "cupy/core/core.pyx":3733
 *         elif dtype == numpy.float64:
 *             cuda.cublas.dgemmBatched(
 *                 cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_24 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3733, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_n_s_Device); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3733, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      __pyx_t_24 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
        __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_14);
        if (likely(__pyx_t_24)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_24);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_14, function);
        }
      }
      if (__pyx_t_24) {
        __pyx_t_29 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_24); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3733, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      } else {
        __pyx_t_29 = __Pyx_PyObject_CallNoArg(__pyx_t_14); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3733, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_29, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3733, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;

      /* "cupy/core/core.pyx":3736
 *                 0,  # transa
 *                 0,  # transb
 *                 n, m, ka, 1.0,             # <<<<<<<<<<<<<<
 *                 ap.data.ptr, lda,
 *                 bp.data.ptr, ldb,
 */
      __pyx_t_29 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3736, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_29);
      __pyx_t_24 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3736, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);
      __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_ka); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3736, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);

      /* "cupy/core/core.pyx":3737
 *                 0,  # transb
 *                 n, m, ka, 1.0,
 *                 ap.data.ptr, lda,             # <<<<<<<<<<<<<<
 *                 bp.data.ptr, ldb,
 *                 0.0, outp.data.ptr, ldout, batchCount)
 */
      __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_ap->data->ptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3737, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);

      /* "cupy/core/core.pyx":3738
 *                 n, m, ka, 1.0,
 *                 ap.data.ptr, lda,
 *                 bp.data.ptr, ldb,             # <<<<<<<<<<<<<<
 *                 0.0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.complex64:
 */
      __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_bp->data->ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3738, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "cupy/core/core.pyx":3739
 *                 ap.data.ptr, lda,
 *                 bp.data.ptr, ldb,
 *                 0.0, outp.data.ptr, ldout, batchCount)             # <<<<<<<<<<<<<<
 *         elif dtype == numpy.complex64:
 *             cuda.cublas.cgemmBatched(
 */
      __pyx_t_28 = __Pyx_PyInt_FromSize_t(__pyx_v_outp->data->ptr); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3739, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_28);
      __pyx_t_26 = PyInt_FromSsize_t(__pyx_v_batchCount); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3739, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_26);
      __pyx_t_8 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
          __pyx_t_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[16] = {__pyx_t_8, __pyx_t_14, __pyx_int_0, __pyx_int_0, __pyx_t_29, __pyx_t_24, __pyx_t_12, __pyx_float_1_0, __pyx_t_5, __pyx_v_lda, __pyx_t_3, __pyx_v_ldb, __pyx_float_0_0, __pyx_t_28, __pyx_v_ldout, __pyx_t_26};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_7, 15+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3732, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[16] = {__pyx_t_8, __pyx_t_14, __pyx_int_0, __pyx_int_0, __pyx_t_29, __pyx_t_24, __pyx_t_12, __pyx_float_1_0, __pyx_t_5, __pyx_v_lda, __pyx_t_3, __pyx_v_ldb, __pyx_float_0_0, __pyx_t_28, __pyx_v_ldout, __pyx_t_26};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_7, 15+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3732, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      } else
      #endif
      {
        __pyx_t_25 = PyTuple_New(15+__pyx_t_7); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3732, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_25);
        if (__pyx_t_8) {
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_25, 0, __pyx_t_8); __pyx_t_8 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_25, 0+__pyx_t_7, __pyx_t_14);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_25, 1+__pyx_t_7, __pyx_int_0);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_25, 2+__pyx_t_7, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_29);
        PyTuple_SET_ITEM(__pyx_t_25, 3+__pyx_t_7, __pyx_t_29);
        __Pyx_GIVEREF(__pyx_t_24);
        PyTuple_SET_ITEM(__pyx_t_25, 4+__pyx_t_7, __pyx_t_24);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_25, 5+__pyx_t_7, __pyx_t_12);
        __Pyx_INCREF(__pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_float_1_0);
        PyTuple_SET_ITEM(__pyx_t_25, 6+__pyx_t_7, __pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_25, 7+__pyx_t_7, __pyx_t_5);
        __Pyx_INCREF(__pyx_v_lda);
        __Pyx_GIVEREF(__pyx_v_lda);
        PyTuple_SET_ITEM(__pyx_t_25, 8+__pyx_t_7, __pyx_v_lda);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_25, 9+__pyx_t_7, __pyx_t_3);
        __Pyx_INCREF(__pyx_v_ldb);
        __Pyx_GIVEREF(__pyx_v_ldb);
        PyTuple_SET_ITEM(__pyx_t_25, 10+__pyx_t_7, __pyx_v_ldb);
        __Pyx_INCREF(__pyx_float_0_0);
        __Pyx_GIVEREF(__pyx_float_0_0);
        PyTuple_SET_ITEM(__pyx_t_25, 11+__pyx_t_7, __pyx_float_0_0);
        __Pyx_GIVEREF(__pyx_t_28);
        PyTuple_SET_ITEM(__pyx_t_25, 12+__pyx_t_7, __pyx_t_28);
        __Pyx_INCREF(__pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_v_ldout);
        PyTuple_SET_ITEM(__pyx_t_25, 13+__pyx_t_7, __pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_t_26);
        PyTuple_SET_ITEM(__pyx_t_25, 14+__pyx_t_7, __pyx_t_26);
        __pyx_t_14 = 0;
        __pyx_t_29 = 0;
        __pyx_t_24 = 0;
        __pyx_t_12 = 0;
        __pyx_t_5 = 0;
        __pyx_t_3 = 0;
        __pyx_t_28 = 0;
        __pyx_t_26 = 0;
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_25, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3732, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "cupy/core/core.pyx":3731
 *                 bp.data.ptr, ldb,
 *                 0.0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *             cuda.cublas.dgemmBatched(
 *                 cuda.Device().cublas_handle,
 */
      goto __pyx_L45;
    }

    /* "cupy/core/core.pyx":3740
 *                 bp.data.ptr, ldb,
 *                 0.0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.complex64:             # <<<<<<<<<<<<<<
 *             cuda.cublas.cgemmBatched(
 *                 cuda.Device().cublas_handle,
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3740, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_complex64); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3740, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_13, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3740, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3740, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3741
 *                 0.0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.complex64:
 *             cuda.cublas.cgemmBatched(             # <<<<<<<<<<<<<<
 *                 cuda.Device().cublas_handle,
 *                 0,  # transa
 */
      __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3741, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_cublas); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3741, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_n_s_cgemmBatched); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3741, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

      /* "cupy/core/core.pyx":3742
 *         elif dtype == numpy.complex64:
 *             cuda.cublas.cgemmBatched(
 *                 cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_26 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3742, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_26);
      __pyx_t_28 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_n_s_Device); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3742, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_28);
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      __pyx_t_26 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_28))) {
        __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_28);
        if (likely(__pyx_t_26)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_28);
          __Pyx_INCREF(__pyx_t_26);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_28, function);
        }
      }
      if (__pyx_t_26) {
        __pyx_t_25 = __Pyx_PyObject_CallOneArg(__pyx_t_28, __pyx_t_26); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3742, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      } else {
        __pyx_t_25 = __Pyx_PyObject_CallNoArg(__pyx_t_28); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3742, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_25);
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      __pyx_t_28 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3742, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_28);
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

      /* "cupy/core/core.pyx":3745
 *                 0,  # transa
 *                 0,  # transb
 *                 n, m, ka, 1,             # <<<<<<<<<<<<<<
 *                 ap.data.ptr, lda,
 *                 bp.data.ptr, ldb,
 */
      __pyx_t_25 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3745, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);
      __pyx_t_26 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3745, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_26);
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_ka); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3745, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "cupy/core/core.pyx":3746
 *                 0,  # transb
 *                 n, m, ka, 1,
 *                 ap.data.ptr, lda,             # <<<<<<<<<<<<<<
 *                 bp.data.ptr, ldb,
 *                 0, outp.data.ptr, ldout, batchCount)
 */
      __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_ap->data->ptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3746, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);

      /* "cupy/core/core.pyx":3747
 *                 n, m, ka, 1,
 *                 ap.data.ptr, lda,
 *                 bp.data.ptr, ldb,             # <<<<<<<<<<<<<<
 *                 0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.complex128:
 */
      __pyx_t_12 = __Pyx_PyInt_FromSize_t(__pyx_v_bp->data->ptr); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3747, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);

      /* "cupy/core/core.pyx":3748
 *                 ap.data.ptr, lda,
 *                 bp.data.ptr, ldb,
 *                 0, outp.data.ptr, ldout, batchCount)             # <<<<<<<<<<<<<<
 *         elif dtype == numpy.complex128:
 *             cuda.cublas.zgemmBatched(
 */
      __pyx_t_24 = __Pyx_PyInt_FromSize_t(__pyx_v_outp->data->ptr); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3748, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);
      __pyx_t_29 = PyInt_FromSsize_t(__pyx_v_batchCount); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3748, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_29);
      __pyx_t_14 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
          __pyx_t_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[16] = {__pyx_t_14, __pyx_t_28, __pyx_int_0, __pyx_int_0, __pyx_t_25, __pyx_t_26, __pyx_t_3, __pyx_int_1, __pyx_t_5, __pyx_v_lda, __pyx_t_12, __pyx_v_ldb, __pyx_int_0, __pyx_t_24, __pyx_v_ldout, __pyx_t_29};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_7, 15+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3741, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[16] = {__pyx_t_14, __pyx_t_28, __pyx_int_0, __pyx_int_0, __pyx_t_25, __pyx_t_26, __pyx_t_3, __pyx_int_1, __pyx_t_5, __pyx_v_lda, __pyx_t_12, __pyx_v_ldb, __pyx_int_0, __pyx_t_24, __pyx_v_ldout, __pyx_t_29};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_7, 15+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3741, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(15+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3741, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        if (__pyx_t_14) {
          __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_14); __pyx_t_14 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_28);
        PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_28);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_int_0);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_25);
        PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_7, __pyx_t_25);
        __Pyx_GIVEREF(__pyx_t_26);
        PyTuple_SET_ITEM(__pyx_t_8, 4+__pyx_t_7, __pyx_t_26);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_8, 5+__pyx_t_7, __pyx_t_3);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_8, 6+__pyx_t_7, __pyx_int_1);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_8, 7+__pyx_t_7, __pyx_t_5);
        __Pyx_INCREF(__pyx_v_lda);
        __Pyx_GIVEREF(__pyx_v_lda);
        PyTuple_SET_ITEM(__pyx_t_8, 8+__pyx_t_7, __pyx_v_lda);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_8, 9+__pyx_t_7, __pyx_t_12);
        __Pyx_INCREF(__pyx_v_ldb);
        __Pyx_GIVEREF(__pyx_v_ldb);
        PyTuple_SET_ITEM(__pyx_t_8, 10+__pyx_t_7, __pyx_v_ldb);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_8, 11+__pyx_t_7, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_24);
        PyTuple_SET_ITEM(__pyx_t_8, 12+__pyx_t_7, __pyx_t_24);
        __Pyx_INCREF(__pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_v_ldout);
        PyTuple_SET_ITEM(__pyx_t_8, 13+__pyx_t_7, __pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_t_29);
        PyTuple_SET_ITEM(__pyx_t_8, 14+__pyx_t_7, __pyx_t_29);
        __pyx_t_28 = 0;
        __pyx_t_25 = 0;
        __pyx_t_26 = 0;
        __pyx_t_3 = 0;
        __pyx_t_5 = 0;
        __pyx_t_12 = 0;
        __pyx_t_24 = 0;
        __pyx_t_29 = 0;
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3741, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "cupy/core/core.pyx":3740
 *                 bp.data.ptr, ldb,
 *                 0.0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.complex64:             # <<<<<<<<<<<<<<
 *             cuda.cublas.cgemmBatched(
 *                 cuda.Device().cublas_handle,
 */
      goto __pyx_L45;
    }

    /* "cupy/core/core.pyx":3749
 *                 bp.data.ptr, ldb,
 *                 0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.complex128:             # <<<<<<<<<<<<<<
 *             cuda.cublas.zgemmBatched(
 *                 cuda.Device().cublas_handle,
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_complex128); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_13, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3749, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3749, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (likely(__pyx_t_2)) {

      /* "cupy/core/core.pyx":3750
 *                 0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.complex128:
 *             cuda.cublas.zgemmBatched(             # <<<<<<<<<<<<<<
 *                 cuda.Device().cublas_handle,
 *                 0,  # transa
 */
      __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3750, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_cublas); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3750, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zgemmBatched); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3750, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":3751
 *         elif dtype == numpy.complex128:
 *             cuda.cublas.zgemmBatched(
 *                 cuda.Device().cublas_handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_29 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3751, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_29);
      __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_29, __pyx_n_s_Device); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3751, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      __pyx_t_29 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_24))) {
        __pyx_t_29 = PyMethod_GET_SELF(__pyx_t_24);
        if (likely(__pyx_t_29)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_24);
          __Pyx_INCREF(__pyx_t_29);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_24, function);
        }
      }
      if (__pyx_t_29) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_24, __pyx_t_29); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3751, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      } else {
        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_24); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3751, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_cublas_handle); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3751, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":3754
 *                 0,  # transa
 *                 0,  # transb
 *                 n, m, ka, 1,             # <<<<<<<<<<<<<<
 *                 ap.data.ptr, lda,
 *                 bp.data.ptr, ldb,
 */
      __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_29 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_29);
      __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_ka); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);

      /* "cupy/core/core.pyx":3755
 *                 0,  # transb
 *                 n, m, ka, 1,
 *                 ap.data.ptr, lda,             # <<<<<<<<<<<<<<
 *                 bp.data.ptr, ldb,
 *                 0, outp.data.ptr, ldout, batchCount)
 */
      __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_ap->data->ptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3755, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);

      /* "cupy/core/core.pyx":3756
 *                 n, m, ka, 1,
 *                 ap.data.ptr, lda,
 *                 bp.data.ptr, ldb,             # <<<<<<<<<<<<<<
 *                 0, outp.data.ptr, ldout, batchCount)
 *         else:
 */
      __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_bp->data->ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3756, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "cupy/core/core.pyx":3757
 *                 ap.data.ptr, lda,
 *                 bp.data.ptr, ldb,
 *                 0, outp.data.ptr, ldout, batchCount)             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError(dtype, a.dtype, b.dtype)
 */
      __pyx_t_26 = __Pyx_PyInt_FromSize_t(__pyx_v_outp->data->ptr); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3757, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_26);
      __pyx_t_25 = PyInt_FromSsize_t(__pyx_v_batchCount); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3757, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);
      __pyx_t_28 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_28 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_28)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_28);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
          __pyx_t_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[16] = {__pyx_t_28, __pyx_t_24, __pyx_int_0, __pyx_int_0, __pyx_t_8, __pyx_t_29, __pyx_t_12, __pyx_int_1, __pyx_t_5, __pyx_v_lda, __pyx_t_3, __pyx_v_ldb, __pyx_int_0, __pyx_t_26, __pyx_v_ldout, __pyx_t_25};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_7, 15+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3750, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[16] = {__pyx_t_28, __pyx_t_24, __pyx_int_0, __pyx_int_0, __pyx_t_8, __pyx_t_29, __pyx_t_12, __pyx_int_1, __pyx_t_5, __pyx_v_lda, __pyx_t_3, __pyx_v_ldb, __pyx_int_0, __pyx_t_26, __pyx_v_ldout, __pyx_t_25};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_7, 15+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3750, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
      } else
      #endif
      {
        __pyx_t_14 = PyTuple_New(15+__pyx_t_7); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3750, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        if (__pyx_t_28) {
          __Pyx_GIVEREF(__pyx_t_28); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_28); __pyx_t_28 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_24);
        PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_7, __pyx_t_24);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_7, __pyx_int_0);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_7, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_7, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_29);
        PyTuple_SET_ITEM(__pyx_t_14, 4+__pyx_t_7, __pyx_t_29);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_14, 5+__pyx_t_7, __pyx_t_12);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_14, 6+__pyx_t_7, __pyx_int_1);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_14, 7+__pyx_t_7, __pyx_t_5);
        __Pyx_INCREF(__pyx_v_lda);
        __Pyx_GIVEREF(__pyx_v_lda);
        PyTuple_SET_ITEM(__pyx_t_14, 8+__pyx_t_7, __pyx_v_lda);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_14, 9+__pyx_t_7, __pyx_t_3);
        __Pyx_INCREF(__pyx_v_ldb);
        __Pyx_GIVEREF(__pyx_v_ldb);
        PyTuple_SET_ITEM(__pyx_t_14, 10+__pyx_t_7, __pyx_v_ldb);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_14, 11+__pyx_t_7, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_26);
        PyTuple_SET_ITEM(__pyx_t_14, 12+__pyx_t_7, __pyx_t_26);
        __Pyx_INCREF(__pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_v_ldout);
        PyTuple_SET_ITEM(__pyx_t_14, 13+__pyx_t_7, __pyx_v_ldout);
        __Pyx_GIVEREF(__pyx_t_25);
        PyTuple_SET_ITEM(__pyx_t_14, 14+__pyx_t_7, __pyx_t_25);
        __pyx_t_24 = 0;
        __pyx_t_8 = 0;
        __pyx_t_29 = 0;
        __pyx_t_12 = 0;
        __pyx_t_5 = 0;
        __pyx_t_3 = 0;
        __pyx_t_26 = 0;
        __pyx_t_25 = 0;
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_14, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3750, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "cupy/core/core.pyx":3749
 *                 bp.data.ptr, ldb,
 *                 0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.complex128:             # <<<<<<<<<<<<<<
 *             cuda.cublas.zgemmBatched(
 *                 cuda.Device().cublas_handle,
 */
      goto __pyx_L45;
    }

    /* "cupy/core/core.pyx":3759
 *                 0, outp.data.ptr, ldout, batchCount)
 *         else:
 *             raise TypeError(dtype, a.dtype, b.dtype)             # <<<<<<<<<<<<<<
 * 
 *     if dtype == ret_dtype:
 */
    /*else*/ {
      __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3759, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_dtype);
      __Pyx_INCREF(__pyx_v_a->dtype);
      __Pyx_GIVEREF(__pyx_v_a->dtype);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_a->dtype);
      __Pyx_INCREF(__pyx_v_b->dtype);
      __Pyx_GIVEREF(__pyx_v_b->dtype);
      PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_v_b->dtype);
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3759, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_13, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __PYX_ERR(0, 3759, __pyx_L1_error)
    }
    __pyx_L45:;
  }
  __pyx_L41:;

  /* "cupy/core/core.pyx":3761
 *             raise TypeError(dtype, a.dtype, b.dtype)
 * 
 *     if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *         return out
 *     else:
 */
  __pyx_t_13 = PyObject_RichCompare(__pyx_v_dtype, __pyx_v_ret_dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3761, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3761, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3762
 * 
 *     if dtype == ret_dtype:
 *         return out             # <<<<<<<<<<<<<<
 *     else:
 *         ret = ndarray(out_shape, ret_dtype)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __pyx_r = __pyx_v_out;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3761
 *             raise TypeError(dtype, a.dtype, b.dtype)
 * 
 *     if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *         return out
 *     else:
 */
  }

  /* "cupy/core/core.pyx":3764
 *         return out
 *     else:
 *         ret = ndarray(out_shape, ret_dtype)             # <<<<<<<<<<<<<<
 *         elementwise_copy(out, ret)
 *         return ret
 */
  /*else*/ {
    __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_INCREF(__pyx_v_out_shape);
    __Pyx_GIVEREF(__pyx_v_out_shape);
    PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_out_shape);
    __Pyx_INCREF(__pyx_v_ret_dtype);
    __Pyx_GIVEREF(__pyx_v_ret_dtype);
    PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_ret_dtype);
    __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_13, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_9);
    __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":3765
 *     else:
 *         ret = ndarray(out_shape, ret_dtype)
 *         elementwise_copy(out, ret)             # <<<<<<<<<<<<<<
 *         return ret
 * 
 */
    __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3765, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_14 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
      __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
      if (likely(__pyx_t_14)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
        __Pyx_INCREF(__pyx_t_14);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_13, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_13)) {
      PyObject *__pyx_temp[3] = {__pyx_t_14, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3765, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_9);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
      PyObject *__pyx_temp[3] = {__pyx_t_14, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3765, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_9);
    } else
    #endif
    {
      __pyx_t_25 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3765, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);
      if (__pyx_t_14) {
        __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_25, 0, __pyx_t_14); __pyx_t_14 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_out));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
      PyTuple_SET_ITEM(__pyx_t_25, 0+__pyx_t_7, ((PyObject *)__pyx_v_out));
      __Pyx_INCREF(((PyObject *)__pyx_v_ret));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
      PyTuple_SET_ITEM(__pyx_t_25, 1+__pyx_t_7, ((PyObject *)__pyx_v_ret));
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_25, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3765, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    }
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":3766
 *         ret = ndarray(out_shape, ret_dtype)
 *         elementwise_copy(out, ret)
 *         return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_ret));
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":3520
 * 
 * 
 * cpdef ndarray matmul(ndarray a, ndarray b, ndarray out=None):             # <<<<<<<<<<<<<<
 *     """ Returns the matrix product of two arrays and is the implementation of
 *     the `@` operator introduced in Python 3.5 following PEP465.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_XDECREF(__pyx_t_25);
  __Pyx_XDECREF(__pyx_t_26);
  __Pyx_XDECREF(__pyx_t_27);
  __Pyx_XDECREF(__pyx_t_28);
  __Pyx_XDECREF(__pyx_t_29);
  __Pyx_AddTraceback("cupy.core.core.matmul", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ap);
  __Pyx_XDECREF((PyObject *)__pyx_v_bp);
  __Pyx_XDECREF((PyObject *)__pyx_v_outp);
  __Pyx_XDECREF(__pyx_v_orig_a_shape);
  __Pyx_XDECREF(__pyx_v_orig_b_shape);
  __Pyx_XDECREF(__pyx_v_ret_dtype);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_a_part_outshape);
  __Pyx_XDECREF(__pyx_v_b_part_outshape);
  __Pyx_XDECREF(__pyx_v_ldout);
  __Pyx_XDECREF((PyObject *)__pyx_v_view);
  __Pyx_XDECREF(__pyx_v_broadcast_pre_shape);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_a_strides);
  __Pyx_XDECREF(__pyx_v_a_shape);
  __Pyx_XDECREF(__pyx_v_b_strides);
  __Pyx_XDECREF(__pyx_v_b_shape);
  __Pyx_XDECREF((PyObject *)__pyx_v_out_view);
  __Pyx_XDECREF(__pyx_v_out_view_shape);
  __Pyx_XDECREF(__pyx_v_out_view_strides);
  __Pyx_XDECREF(__pyx_v_lda);
  __Pyx_XDECREF(__pyx_v_ldb);
  __Pyx_XDECREF(__pyx_v_la);
  __Pyx_XDECREF(__pyx_v_lb);
  __Pyx_XDECREF(__pyx_v_la_);
  __Pyx_XDECREF(__pyx_v_lb_);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_b);
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_105matmul(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_104matmul[] = "matmul(ndarray a, ndarray b, ndarray out=None) -> ndarray\n Returns the matrix product of two arrays and is the implementation of\n    the `@` operator introduced in Python 3.5 following PEP465.\n\n    The main difference against cupy.dot are the handling of arrays with more\n    than 2 dimensions. For more information see :func:`numpy.matmul`.\n\n    .. note::\n        The out array as input is currently not supported.\n\n    Args:\n        a (cupy.ndarray): The left argument.\n        b (cupy.ndarray): The right argument.\n        out (cupy.ndarray): Output array.\n\n    Returns:\n        cupy.ndarray: Output array.\n\n    .. seealso:: :func:`numpy.matmul`\n\n    ";
static PyObject *__pyx_pw_4cupy_4core_4core_105matmul(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("matmul (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_b,&__pyx_n_s_out,0};
    PyObject* values[3] = {0,0,0};
    values[2] = (PyObject *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
    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_a)) != 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_b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("matmul", 0, 2, 3, 1); __PYX_ERR(0, 3520, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "matmul") < 0)) __PYX_ERR(0, 3520, __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_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_b = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("matmul", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3520, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.matmul", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3520, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(0, 3520, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 3520, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_104matmul(__pyx_self, __pyx_v_a, __pyx_v_b, __pyx_v_out);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_104matmul(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_matmul __pyx_t_2;
  __Pyx_RefNannySetupContext("matmul", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_matmul(__pyx_v_a, __pyx_v_b, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3520, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.matmul", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3776
 * 
 * 
 * cpdef ndarray tensordot_core(             # <<<<<<<<<<<<<<
 *         ndarray a, ndarray b, ndarray out, Py_ssize_t n, Py_ssize_t m,
 *         Py_ssize_t k, vector.vector[Py_ssize_t] ret_shape):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_107tensordot_core(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_tensordot_core(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out, Py_ssize_t __pyx_v_n, Py_ssize_t __pyx_v_m, Py_ssize_t __pyx_v_k, std::vector<Py_ssize_t>  __pyx_v_ret_shape, CYTHON_UNUSED int __pyx_skip_dispatch) {
  std::vector<Py_ssize_t>  __pyx_v_shape;
  Py_ssize_t __pyx_v_transa;
  Py_ssize_t __pyx_v_transb;
  Py_ssize_t __pyx_v_lda;
  Py_ssize_t __pyx_v_ldb;
  Py_ssize_t __pyx_v_handle;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_ret_dtype = 0;
  int __pyx_v_use_sgemmEx;
  float __pyx_v_one_fp32;
  float __pyx_v_zero_fp32;
  PyObject *__pyx_v_use_tensor_core = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_c = NULL;
  int __pyx_v_Ctype;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  size_t __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  int __pyx_t_15;
  __Pyx_RefNannySetupContext("tensordot_core", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF((PyObject *)__pyx_v_b);
  __Pyx_INCREF((PyObject *)__pyx_v_out);

  /* "cupy/core/core.pyx":3785
 *     cdef bint use_sgemmEx
 *     cdef float one_fp32, zero_fp32
 *     ret_dtype = a.dtype.char             # <<<<<<<<<<<<<<
 *     if ret_dtype != b.dtype.char:
 *         ret_dtype = numpy.find_common_type((ret_dtype, b.dtype), ()).char
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a->dtype, __pyx_n_s_char); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 3785, __pyx_L1_error)
  __pyx_v_ret_dtype = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3786
 *     cdef float one_fp32, zero_fp32
 *     ret_dtype = a.dtype.char
 *     if ret_dtype != b.dtype.char:             # <<<<<<<<<<<<<<
 *         ret_dtype = numpy.find_common_type((ret_dtype, b.dtype), ()).char
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_b->dtype, __pyx_n_s_char); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_ret_dtype, __pyx_t_1, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3786, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3787
 *     ret_dtype = a.dtype.char
 *     if ret_dtype != b.dtype.char:
 *         ret_dtype = numpy.find_common_type((ret_dtype, b.dtype), ()).char             # <<<<<<<<<<<<<<
 * 
 *     if not a.size or not b.size:
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3787, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_find_common_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3787, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3787, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_ret_dtype);
    __Pyx_GIVEREF(__pyx_v_ret_dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_ret_dtype);
    __Pyx_INCREF(__pyx_v_b->dtype);
    __Pyx_GIVEREF(__pyx_v_b->dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_b->dtype);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    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_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_empty_tuple};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3787, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_empty_tuple};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3787, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3787, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
      __Pyx_INCREF(__pyx_empty_tuple);
      __Pyx_GIVEREF(__pyx_empty_tuple);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_empty_tuple);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3787, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_char); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3787, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 3787, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_ret_dtype, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3786
 *     cdef float one_fp32, zero_fp32
 *     ret_dtype = a.dtype.char
 *     if ret_dtype != b.dtype.char:             # <<<<<<<<<<<<<<
 *         ret_dtype = numpy.find_common_type((ret_dtype, b.dtype), ()).char
 * 
 */
  }

  /* "cupy/core/core.pyx":3789
 *         ret_dtype = numpy.find_common_type((ret_dtype, b.dtype), ()).char
 * 
 *     if not a.size or not b.size:             # <<<<<<<<<<<<<<
 *         if out is None:
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 */
  __pyx_t_8 = ((!(__pyx_v_a->size != 0)) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_8 = ((!(__pyx_v_b->size != 0)) != 0);
  __pyx_t_2 = __pyx_t_8;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3790
 * 
 *     if not a.size or not b.size:
 *         if out is None:             # <<<<<<<<<<<<<<
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 *         out.fill(0)
 */
    __pyx_t_2 = (((PyObject *)__pyx_v_out) == Py_None);
    __pyx_t_8 = (__pyx_t_2 != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":3791
 *     if not a.size or not b.size:
 *         if out is None:
 *             out = ndarray(ret_shape, dtype=ret_dtype)             # <<<<<<<<<<<<<<
 *         out.fill(0)
 *         return out
 */
      __pyx_t_4 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_ret_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3791, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3791, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3791, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_v_ret_dtype) < 0) __PYX_ERR(0, 3791, __pyx_L1_error)
      __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3791, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7));
      __pyx_t_7 = 0;

      /* "cupy/core/core.pyx":3790
 * 
 *     if not a.size or not b.size:
 *         if out is None:             # <<<<<<<<<<<<<<
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 *         out.fill(0)
 */
    }

    /* "cupy/core/core.pyx":3792
 *         if out is None:
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 *         out.fill(0)             # <<<<<<<<<<<<<<
 *         return out
 * 
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_out->__pyx_vtab)->fill(__pyx_v_out, __pyx_int_0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3792, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":3793
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 *         out.fill(0)
 *         return out             # <<<<<<<<<<<<<<
 * 
 *     global _cuda_runtime_version
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __pyx_r = __pyx_v_out;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3789
 *         ret_dtype = numpy.find_common_type((ret_dtype, b.dtype), ()).char
 * 
 *     if not a.size or not b.size:             # <<<<<<<<<<<<<<
 *         if out is None:
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 */
  }

  /* "cupy/core/core.pyx":3796
 * 
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  __pyx_t_8 = (__pyx_v_4cupy_4core_4core__cuda_runtime_version == Py_None);
  __pyx_t_2 = (__pyx_t_8 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3797
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:
 *         _cuda_runtime_version = runtime.runtimeGetVersion()             # <<<<<<<<<<<<<<
 * 
 *     use_sgemmEx = (_cuda_runtime_version >= 7500 and
 */
    __pyx_t_6 = __pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3797, __pyx_L1_error)
    __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3797, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cuda_runtime_version);
    __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cuda_runtime_version, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":3796
 * 
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version is None:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  }

  /* "cupy/core/core.pyx":3799
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 *     use_sgemmEx = (_cuda_runtime_version >= 7500 and             # <<<<<<<<<<<<<<
 *                    a.dtype == 'e' and b.dtype == 'e' and
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))
 */
  __pyx_t_7 = PyObject_RichCompare(__pyx_v_4cupy_4core_4core__cuda_runtime_version, __pyx_int_7500, Py_GE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3799, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 3799, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L9_bool_binop_done;
  }

  /* "cupy/core/core.pyx":3800
 * 
 *     use_sgemmEx = (_cuda_runtime_version >= 7500 and
 *                    a.dtype == 'e' and b.dtype == 'e' and             # <<<<<<<<<<<<<<
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))
 *     use_tensor_core = (use_sgemmEx and
 */
  __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_a->dtype, __pyx_n_s_e, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 3800, __pyx_L1_error)
  if (__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_b->dtype, __pyx_n_s_e, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 3800, __pyx_L1_error)
  if (__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L9_bool_binop_done;
  }

  /* "cupy/core/core.pyx":3801
 *     use_sgemmEx = (_cuda_runtime_version >= 7500 and
 *                    a.dtype == 'e' and b.dtype == 'e' and
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))             # <<<<<<<<<<<<<<
 *     use_tensor_core = (use_sgemmEx and
 *                        _cuda_runtime_version >= 9000 and
 */
  __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_ret_dtype, __pyx_n_s_e, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 3801, __pyx_L1_error)
  __pyx_t_9 = (__pyx_t_8 != 0);
  if (!__pyx_t_9) {
  } else {
    __pyx_t_2 = __pyx_t_9;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_ret_dtype, __pyx_n_s_f, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3801, __pyx_L1_error)
  __pyx_t_8 = (__pyx_t_9 != 0);
  __pyx_t_2 = __pyx_t_8;
  __pyx_L9_bool_binop_done:;
  __pyx_v_use_sgemmEx = __pyx_t_2;

  /* "cupy/core/core.pyx":3802
 *                    a.dtype == 'e' and b.dtype == 'e' and
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))
 *     use_tensor_core = (use_sgemmEx and             # <<<<<<<<<<<<<<
 *                        _cuda_runtime_version >= 9000 and
 *                        int(device.get_compute_capability()) == 70)
 */
  if (__pyx_v_use_sgemmEx) {
  } else {
    __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_use_sgemmEx); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3802, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L14_bool_binop_done;
  }

  /* "cupy/core/core.pyx":3803
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))
 *     use_tensor_core = (use_sgemmEx and
 *                        _cuda_runtime_version >= 9000 and             # <<<<<<<<<<<<<<
 *                        int(device.get_compute_capability()) == 70)
 * 
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_4cupy_4core_4core__cuda_runtime_version, __pyx_int_9000, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3803, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3803, __pyx_L1_error)
  if (__pyx_t_2) {
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_7 = __pyx_t_4;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L14_bool_binop_done;
  }

  /* "cupy/core/core.pyx":3804
 *     use_tensor_core = (use_sgemmEx and
 *                        _cuda_runtime_version >= 9000 and
 *                        int(device.get_compute_capability()) == 70)             # <<<<<<<<<<<<<<
 * 
 *     if use_sgemmEx or ret_dtype in 'fdFD':
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_6device_get_compute_capability(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3804, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3804, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_70, 70, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3804, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_7 = __pyx_t_4;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_L14_bool_binop_done:;
  __pyx_v_use_tensor_core = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":3806
 *                        int(device.get_compute_capability()) == 70)
 * 
 *     if use_sgemmEx or ret_dtype in 'fdFD':             # <<<<<<<<<<<<<<
 *         dtype = ret_dtype
 *     else:
 */
  __pyx_t_8 = (__pyx_v_use_sgemmEx != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L18_bool_binop_done;
  }
  __pyx_t_8 = (__Pyx_PySequence_ContainsTF(__pyx_v_ret_dtype, __pyx_n_s_fdFD, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 3806, __pyx_L1_error)
  __pyx_t_9 = (__pyx_t_8 != 0);
  __pyx_t_2 = __pyx_t_9;
  __pyx_L18_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3807
 * 
 *     if use_sgemmEx or ret_dtype in 'fdFD':
 *         dtype = ret_dtype             # <<<<<<<<<<<<<<
 *     else:
 *         dtype = numpy.find_common_type((ret_dtype, 'f'), ()).char
 */
    __Pyx_INCREF(__pyx_v_ret_dtype);
    __pyx_v_dtype = __pyx_v_ret_dtype;

    /* "cupy/core/core.pyx":3806
 *                        int(device.get_compute_capability()) == 70)
 * 
 *     if use_sgemmEx or ret_dtype in 'fdFD':             # <<<<<<<<<<<<<<
 *         dtype = ret_dtype
 *     else:
 */
    goto __pyx_L17;
  }

  /* "cupy/core/core.pyx":3809
 *         dtype = ret_dtype
 *     else:
 *         dtype = numpy.find_common_type((ret_dtype, 'f'), ()).char             # <<<<<<<<<<<<<<
 * 
 *     if out is None:
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3809, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_find_common_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3809, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3809, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_ret_dtype);
    __Pyx_GIVEREF(__pyx_v_ret_dtype);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_ret_dtype);
    __Pyx_INCREF(__pyx_n_s_f);
    __Pyx_GIVEREF(__pyx_n_s_f);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_f);
    __pyx_t_3 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(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_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, __pyx_empty_tuple};
      __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3809, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, __pyx_empty_tuple};
      __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3809, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3809, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_t_4);
      __Pyx_INCREF(__pyx_empty_tuple);
      __Pyx_GIVEREF(__pyx_empty_tuple);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_empty_tuple);
      __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3809, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_char); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3809, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 3809, __pyx_L1_error)
    __pyx_v_dtype = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
  }
  __pyx_L17:;

  /* "cupy/core/core.pyx":3811
 *         dtype = numpy.find_common_type((ret_dtype, 'f'), ()).char
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_out) == Py_None);
  __pyx_t_9 = (__pyx_t_2 != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3812
 * 
 *     if out is None:
 *         out = ndarray(ret_shape, dtype)             # <<<<<<<<<<<<<<
 *         if dtype == ret_dtype:
 *             ret = out
 */
    __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_ret_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3812, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3812, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_dtype);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3812, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3813
 *     if out is None:
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *             ret = out
 *         else:
 */
    __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_v_ret_dtype, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3813, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_9 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3814
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:
 *             ret = out             # <<<<<<<<<<<<<<
 *         else:
 *             ret = ndarray(ret_shape, ret_dtype)
 */
      __Pyx_INCREF(((PyObject *)__pyx_v_out));
      __pyx_v_ret = __pyx_v_out;

      /* "cupy/core/core.pyx":3813
 *     if out is None:
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *             ret = out
 *         else:
 */
      goto __pyx_L21;
    }

    /* "cupy/core/core.pyx":3816
 *             ret = out
 *         else:
 *             ret = ndarray(ret_shape, ret_dtype)             # <<<<<<<<<<<<<<
 *     else:
 *         ret = out
 */
    /*else*/ {
      __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_ret_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
      __Pyx_INCREF(__pyx_v_ret_dtype);
      __Pyx_GIVEREF(__pyx_v_ret_dtype);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_ret_dtype);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
      __pyx_t_1 = 0;
    }
    __pyx_L21:;

    /* "cupy/core/core.pyx":3811
 *         dtype = numpy.find_common_type((ret_dtype, 'f'), ()).char
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:
 */
    goto __pyx_L20;
  }

  /* "cupy/core/core.pyx":3818
 *             ret = ndarray(ret_shape, ret_dtype)
 *     else:
 *         ret = out             # <<<<<<<<<<<<<<
 *         if out.dtype != dtype:
 *             out = ndarray(ret_shape, dtype)
 */
  /*else*/ {
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __pyx_v_ret = __pyx_v_out;

    /* "cupy/core/core.pyx":3819
 *     else:
 *         ret = out
 *         if out.dtype != dtype:             # <<<<<<<<<<<<<<
 *             out = ndarray(ret_shape, dtype)
 * 
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_out->dtype, __pyx_v_dtype, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3819, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":3820
 *         ret = out
 *         if out.dtype != dtype:
 *             out = ndarray(ret_shape, dtype)             # <<<<<<<<<<<<<<
 * 
 *     if m == 1 and n == 1:
 */
      __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_ret_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3820, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3820, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_dtype);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3820, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":3819
 *     else:
 *         ret = out
 *         if out.dtype != dtype:             # <<<<<<<<<<<<<<
 *             out = ndarray(ret_shape, dtype)
 * 
 */
    }
  }
  __pyx_L20:;

  /* "cupy/core/core.pyx":3822
 *             out = ndarray(ret_shape, dtype)
 * 
 *     if m == 1 and n == 1:             # <<<<<<<<<<<<<<
 *         _tensordot_core_mul_sum(a.ravel(), b.ravel(), out.reshape(()))
 *         if out is not ret:
 */
  __pyx_t_9 = ((__pyx_v_m == 1) != 0);
  if (__pyx_t_9) {
  } else {
    __pyx_t_2 = __pyx_t_9;
    goto __pyx_L24_bool_binop_done;
  }
  __pyx_t_9 = ((__pyx_v_n == 1) != 0);
  __pyx_t_2 = __pyx_t_9;
  __pyx_L24_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3823
 * 
 *     if m == 1 and n == 1:
 *         _tensordot_core_mul_sum(a.ravel(), b.ravel(), out.reshape(()))             # <<<<<<<<<<<<<<
 *         if out is not ret:
 *             elementwise_copy(out, ret)
 */
    __pyx_t_7 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->ravel(__pyx_v_a, 0)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->ravel(__pyx_v_b, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__164, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__tensordot_core_mul_sum);
    __pyx_t_4 = __pyx_v_4cupy_4core_4core__tensordot_core_mul_sum; __pyx_t_10 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_t_7, __pyx_t_5, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3823, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_t_7, __pyx_t_5, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3823, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3823, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_6, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_6, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_6, __pyx_t_3);
      __pyx_t_7 = 0;
      __pyx_t_5 = 0;
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3823, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3824
 *     if m == 1 and n == 1:
 *         _tensordot_core_mul_sum(a.ravel(), b.ravel(), out.reshape(()))
 *         if out is not ret:             # <<<<<<<<<<<<<<
 *             elementwise_copy(out, ret)
 *         return ret
 */
    __pyx_t_2 = (__pyx_v_out != __pyx_v_ret);
    __pyx_t_9 = (__pyx_t_2 != 0);
    if (__pyx_t_9) {

      /* "cupy/core/core.pyx":3825
 *         _tensordot_core_mul_sum(a.ravel(), b.ravel(), out.reshape(()))
 *         if out is not ret:
 *             elementwise_copy(out, ret)             # <<<<<<<<<<<<<<
 *         return ret
 * 
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3825, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3825, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3825, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3825, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (__pyx_t_11) {
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_11); __pyx_t_11 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_out));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
        PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, ((PyObject *)__pyx_v_out));
        __Pyx_INCREF(((PyObject *)__pyx_v_ret));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
        PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, ((PyObject *)__pyx_v_ret));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3825, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":3824
 *     if m == 1 and n == 1:
 *         _tensordot_core_mul_sum(a.ravel(), b.ravel(), out.reshape(()))
 *         if out is not ret:             # <<<<<<<<<<<<<<
 *             elementwise_copy(out, ret)
 *         return ret
 */
    }

    /* "cupy/core/core.pyx":3826
 *         if out is not ret:
 *             elementwise_copy(out, ret)
 *         return ret             # <<<<<<<<<<<<<<
 * 
 *     # It copies the operands if needed
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_ret));
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3822
 *             out = ndarray(ret_shape, dtype)
 * 
 *     if m == 1 and n == 1:             # <<<<<<<<<<<<<<
 *         _tensordot_core_mul_sum(a.ravel(), b.ravel(), out.reshape(()))
 *         if out is not ret:
 */
  }

  /* "cupy/core/core.pyx":3829
 * 
 *     # It copies the operands if needed
 *     if a._shape.size() != 2 or a._shape[0] != k or a._shape[1] != n:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(k)
 */
  __pyx_t_2 = ((__pyx_v_a->_shape.size() != 2) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_9 = __pyx_t_2;
    goto __pyx_L28_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_a->_shape[0]) != __pyx_v_k) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_9 = __pyx_t_2;
    goto __pyx_L28_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_a->_shape[1]) != __pyx_v_n) != 0);
  __pyx_t_9 = __pyx_t_2;
  __pyx_L28_bool_binop_done:;
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3830
 *     # It copies the operands if needed
 *     if a._shape.size() != 2 or a._shape[0] != k or a._shape[1] != n:
 *         shape.clear()             # <<<<<<<<<<<<<<
 *         shape.push_back(k)
 *         shape.push_back(n)
 */
    __pyx_v_shape.clear();

    /* "cupy/core/core.pyx":3831
 *     if a._shape.size() != 2 or a._shape[0] != k or a._shape[1] != n:
 *         shape.clear()
 *         shape.push_back(k)             # <<<<<<<<<<<<<<
 *         shape.push_back(n)
 *         a = a._reshape(shape)
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_k);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3831, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3832
 *         shape.clear()
 *         shape.push_back(k)
 *         shape.push_back(n)             # <<<<<<<<<<<<<<
 *         a = a._reshape(shape)
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_n);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3832, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3833
 *         shape.push_back(k)
 *         shape.push_back(n)
 *         a = a._reshape(shape)             # <<<<<<<<<<<<<<
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:
 *         shape.clear()
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->_reshape(__pyx_v_a, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3833, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3829
 * 
 *     # It copies the operands if needed
 *     if a._shape.size() != 2 or a._shape[0] != k or a._shape[1] != n:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(k)
 */
  }

  /* "cupy/core/core.pyx":3834
 *         shape.push_back(n)
 *         a = a._reshape(shape)
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(k)
 */
  __pyx_t_2 = ((__pyx_v_b->_shape.size() != 2) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_9 = __pyx_t_2;
    goto __pyx_L32_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_b->_shape[0]) != __pyx_v_k) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_9 = __pyx_t_2;
    goto __pyx_L32_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_b->_shape[1]) != __pyx_v_m) != 0);
  __pyx_t_9 = __pyx_t_2;
  __pyx_L32_bool_binop_done:;
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3835
 *         a = a._reshape(shape)
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:
 *         shape.clear()             # <<<<<<<<<<<<<<
 *         shape.push_back(k)
 *         shape.push_back(m)
 */
    __pyx_v_shape.clear();

    /* "cupy/core/core.pyx":3836
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:
 *         shape.clear()
 *         shape.push_back(k)             # <<<<<<<<<<<<<<
 *         shape.push_back(m)
 *         b = b._reshape(shape)
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_k);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3836, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3837
 *         shape.clear()
 *         shape.push_back(k)
 *         shape.push_back(m)             # <<<<<<<<<<<<<<
 *         b = b._reshape(shape)
 *     c = out
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_m);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 3837, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":3838
 *         shape.push_back(k)
 *         shape.push_back(m)
 *         b = b._reshape(shape)             # <<<<<<<<<<<<<<
 *     c = out
 *     if c._shape.size() != 2 or c._shape[0] != n or c._shape[1] != m:
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->_reshape(__pyx_v_b, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3834
 *         shape.push_back(n)
 *         a = a._reshape(shape)
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(k)
 */
  }

  /* "cupy/core/core.pyx":3839
 *         shape.push_back(m)
 *         b = b._reshape(shape)
 *     c = out             # <<<<<<<<<<<<<<
 *     if c._shape.size() != 2 or c._shape[0] != n or c._shape[1] != m:
 *         c = c.view()
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_out));
  __pyx_v_c = __pyx_v_out;

  /* "cupy/core/core.pyx":3840
 *         b = b._reshape(shape)
 *     c = out
 *     if c._shape.size() != 2 or c._shape[0] != n or c._shape[1] != m:             # <<<<<<<<<<<<<<
 *         c = c.view()
 *         c.shape = (n, m)
 */
  __pyx_t_2 = ((__pyx_v_c->_shape.size() != 2) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_9 = __pyx_t_2;
    goto __pyx_L36_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_c->_shape[0]) != __pyx_v_n) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_9 = __pyx_t_2;
    goto __pyx_L36_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_c->_shape[1]) != __pyx_v_m) != 0);
  __pyx_t_9 = __pyx_t_2;
  __pyx_L36_bool_binop_done:;
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3841
 *     c = out
 *     if c._shape.size() != 2 or c._shape[0] != n or c._shape[1] != m:
 *         c = c.view()             # <<<<<<<<<<<<<<
 *         c.shape = (n, m)
 * 
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_c->__pyx_vtab)->view(__pyx_v_c, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3841, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_c, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":3842
 *     if c._shape.size() != 2 or c._shape[0] != n or c._shape[1] != m:
 *         c = c.view()
 *         c.shape = (n, m)             # <<<<<<<<<<<<<<
 * 
 *     if not use_sgemmEx:
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3842, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3842, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3842, __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_4);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
    __pyx_t_1 = 0;
    __pyx_t_4 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_c), __pyx_n_s_shape, __pyx_t_3) < 0) __PYX_ERR(0, 3842, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3840
 *         b = b._reshape(shape)
 *     c = out
 *     if c._shape.size() != 2 or c._shape[0] != n or c._shape[1] != m:             # <<<<<<<<<<<<<<
 *         c = c.view()
 *         c.shape = (n, m)
 */
  }

  /* "cupy/core/core.pyx":3844
 *         c.shape = (n, m)
 * 
 *     if not use_sgemmEx:             # <<<<<<<<<<<<<<
 *         a = a.astype(dtype, copy=False)
 *         b = b.astype(dtype, copy=False)
 */
  __pyx_t_9 = ((!(__pyx_v_use_sgemmEx != 0)) != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3845
 * 
 *     if not use_sgemmEx:
 *         a = a.astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 *         b = b.astype(dtype, copy=False)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_astype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3845, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3845, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_dtype);
    __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3845, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 3845, __pyx_L1_error)
    __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3845, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3845, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_11));
    __pyx_t_11 = 0;

    /* "cupy/core/core.pyx":3846
 *     if not use_sgemmEx:
 *         a = a.astype(dtype, copy=False)
 *         b = b.astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 * 
 *     # Be careful that cuBLAS uses the FORTRAN-order matrix representation.
 */
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_astype); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3846, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3846, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_dtype);
    __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3846, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 3846, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3846, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3846, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3844
 *         c.shape = (n, m)
 * 
 *     if not use_sgemmEx:             # <<<<<<<<<<<<<<
 *         a = a.astype(dtype, copy=False)
 *         b = b.astype(dtype, copy=False)
 */
  }

  /* "cupy/core/core.pyx":3849
 * 
 *     # Be careful that cuBLAS uses the FORTRAN-order matrix representation.
 *     handle = device.get_cublas_handle()             # <<<<<<<<<<<<<<
 *     # Matrix-Matrix product A^T * B
 *     # c is C-contiguous while cuBLAS assumes F-contiguous inputs, so we
 */
  __pyx_t_12 = __pyx_f_4cupy_4cuda_6device_get_cublas_handle(0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3849, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_12;

  /* "cupy/core/core.pyx":3853
 *     # c is C-contiguous while cuBLAS assumes F-contiguous inputs, so we
 *     # compute C^T = B^T * A here.
 *     a, transa, lda = _mat_to_cublas_contiguous(a, 0)             # <<<<<<<<<<<<<<
 *     b, transb, ldb = _mat_to_cublas_contiguous(b, 1)
 *     if use_sgemmEx:
 */
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(__pyx_v_a, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3853, __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 != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 3853, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_11 = PyTuple_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_11);
    #else
    __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3853, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3853, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3853, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 3853, __pyx_L1_error)
  }
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3853, __pyx_L1_error)
  __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3853, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_11); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3853, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
  __pyx_t_4 = 0;
  __pyx_v_transa = __pyx_t_13;
  __pyx_v_lda = __pyx_t_14;

  /* "cupy/core/core.pyx":3854
 *     # compute C^T = B^T * A here.
 *     a, transa, lda = _mat_to_cublas_contiguous(a, 0)
 *     b, transb, ldb = _mat_to_cublas_contiguous(b, 1)             # <<<<<<<<<<<<<<
 *     if use_sgemmEx:
 *         Ctype = runtime.CUDA_R_16F if c.dtype == 'e' else runtime.CUDA_R_32F
 */
  __pyx_t_3 = __pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(__pyx_v_b, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3854, __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 != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 3854, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3854, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3854, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3854, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 3854, __pyx_L1_error)
  }
  if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 3854, __pyx_L1_error)
  __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3854, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3854, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_11));
  __pyx_t_11 = 0;
  __pyx_v_transb = __pyx_t_14;
  __pyx_v_ldb = __pyx_t_13;

  /* "cupy/core/core.pyx":3855
 *     a, transa, lda = _mat_to_cublas_contiguous(a, 0)
 *     b, transb, ldb = _mat_to_cublas_contiguous(b, 1)
 *     if use_sgemmEx:             # <<<<<<<<<<<<<<
 *         Ctype = runtime.CUDA_R_16F if c.dtype == 'e' else runtime.CUDA_R_32F
 *         if use_tensor_core:
 */
  __pyx_t_9 = (__pyx_v_use_sgemmEx != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3856
 *     b, transb, ldb = _mat_to_cublas_contiguous(b, 1)
 *     if use_sgemmEx:
 *         Ctype = runtime.CUDA_R_16F if c.dtype == 'e' else runtime.CUDA_R_32F             # <<<<<<<<<<<<<<
 *         if use_tensor_core:
 *             one_fp32 = 1
 */
    __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_c->dtype, __pyx_n_s_e, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3856, __pyx_L1_error)
    if (__pyx_t_9) {
      __pyx_t_15 = __pyx_e_4cupy_4cuda_7runtime_CUDA_R_16F;
    } else {
      __pyx_t_15 = __pyx_e_4cupy_4cuda_7runtime_CUDA_R_32F;
    }
    __pyx_v_Ctype = __pyx_t_15;

    /* "cupy/core/core.pyx":3857
 *     if use_sgemmEx:
 *         Ctype = runtime.CUDA_R_16F if c.dtype == 'e' else runtime.CUDA_R_32F
 *         if use_tensor_core:             # <<<<<<<<<<<<<<
 *             one_fp32 = 1
 *             zero_fp32 = 0
 */
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_use_tensor_core); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3857, __pyx_L1_error)
    if (__pyx_t_9) {

      /* "cupy/core/core.pyx":3858
 *         Ctype = runtime.CUDA_R_16F if c.dtype == 'e' else runtime.CUDA_R_32F
 *         if use_tensor_core:
 *             one_fp32 = 1             # <<<<<<<<<<<<<<
 *             zero_fp32 = 0
 *             cublas.setMathMode(handle, cublas.CUBLAS_TENSOR_OP_MATH)
 */
      __pyx_v_one_fp32 = 1.0;

      /* "cupy/core/core.pyx":3859
 *         if use_tensor_core:
 *             one_fp32 = 1
 *             zero_fp32 = 0             # <<<<<<<<<<<<<<
 *             cublas.setMathMode(handle, cublas.CUBLAS_TENSOR_OP_MATH)
 *             cublas.gemmEx(
 */
      __pyx_v_zero_fp32 = 0.0;

      /* "cupy/core/core.pyx":3860
 *             one_fp32 = 1
 *             zero_fp32 = 0
 *             cublas.setMathMode(handle, cublas.CUBLAS_TENSOR_OP_MATH)             # <<<<<<<<<<<<<<
 *             cublas.gemmEx(
 *                 handle, <int>transb, <int> transa, <int>m, <int>n, <int>k,
 */
      __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_setMathMode(__pyx_v_handle, __pyx_e_4cupy_4cuda_6cublas_CUBLAS_TENSOR_OP_MATH, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3860, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":3861
 *             zero_fp32 = 0
 *             cublas.setMathMode(handle, cublas.CUBLAS_TENSOR_OP_MATH)
 *             cublas.gemmEx(             # <<<<<<<<<<<<<<
 *                 handle, <int>transb, <int> transa, <int>m, <int>n, <int>k,
 *                 <size_t>&one_fp32,
 */
      __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_gemmEx(__pyx_v_handle, ((int)__pyx_v_transb), ((int)__pyx_v_transa), ((int)__pyx_v_m), ((int)__pyx_v_n), ((int)__pyx_v_k), ((size_t)(&__pyx_v_one_fp32)), __pyx_v_b->data->ptr, __pyx_e_4cupy_4cuda_7runtime_CUDA_R_16F, ((int)__pyx_v_ldb), __pyx_v_a->data->ptr, __pyx_e_4cupy_4cuda_7runtime_CUDA_R_16F, ((int)__pyx_v_lda), ((size_t)(&__pyx_v_zero_fp32)), __pyx_v_c->data->ptr, __pyx_v_Ctype, ((int)__pyx_v_m), __pyx_e_4cupy_4cuda_7runtime_CUDA_R_32F, __pyx_e_4cupy_4cuda_6cublas_CUBLAS_GEMM_DFALT_TENSOR_OP, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3861, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":3869
 *                 c.data.ptr, Ctype, <int>m,
 *                 runtime.CUDA_R_32F, cublas.CUBLAS_GEMM_DFALT_TENSOR_OP)
 *             cublas.setMathMode(handle, cublas.CUBLAS_DEFAULT_MATH)             # <<<<<<<<<<<<<<
 *         else:
 *             cublas.sgemmEx(
 */
      __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_setMathMode(__pyx_v_handle, __pyx_e_4cupy_4cuda_6cublas_CUBLAS_DEFAULT_MATH, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3869, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":3857
 *     if use_sgemmEx:
 *         Ctype = runtime.CUDA_R_16F if c.dtype == 'e' else runtime.CUDA_R_32F
 *         if use_tensor_core:             # <<<<<<<<<<<<<<
 *             one_fp32 = 1
 *             zero_fp32 = 0
 */
      goto __pyx_L41;
    }

    /* "cupy/core/core.pyx":3871
 *             cublas.setMathMode(handle, cublas.CUBLAS_DEFAULT_MATH)
 *         else:
 *             cublas.sgemmEx(             # <<<<<<<<<<<<<<
 *                 handle, <int>transb, <int> transa, <int>m, <int>n, <int>k, 1,
 *                 b.data.ptr, runtime.CUDA_R_16F, <int>ldb, a.data.ptr,
 */
    /*else*/ {

      /* "cupy/core/core.pyx":3874
 *                 handle, <int>transb, <int> transa, <int>m, <int>n, <int>k, 1,
 *                 b.data.ptr, runtime.CUDA_R_16F, <int>ldb, a.data.ptr,
 *                 runtime.CUDA_R_16F, <int>lda, 0, c.data.ptr, Ctype, <int>m)             # <<<<<<<<<<<<<<
 *     elif dtype == 'f':
 *         cublas.sgemm(
 */
      __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_sgemmEx(__pyx_v_handle, ((int)__pyx_v_transb), ((int)__pyx_v_transa), ((int)__pyx_v_m), ((int)__pyx_v_n), ((int)__pyx_v_k), 1.0, __pyx_v_b->data->ptr, __pyx_e_4cupy_4cuda_7runtime_CUDA_R_16F, ((int)__pyx_v_ldb), __pyx_v_a->data->ptr, __pyx_e_4cupy_4cuda_7runtime_CUDA_R_16F, ((int)__pyx_v_lda), 0.0, __pyx_v_c->data->ptr, __pyx_v_Ctype, ((int)__pyx_v_m), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3871, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_L41:;

    /* "cupy/core/core.pyx":3855
 *     a, transa, lda = _mat_to_cublas_contiguous(a, 0)
 *     b, transb, ldb = _mat_to_cublas_contiguous(b, 1)
 *     if use_sgemmEx:             # <<<<<<<<<<<<<<
 *         Ctype = runtime.CUDA_R_16F if c.dtype == 'e' else runtime.CUDA_R_32F
 *         if use_tensor_core:
 */
    goto __pyx_L40;
  }

  /* "cupy/core/core.pyx":3875
 *                 b.data.ptr, runtime.CUDA_R_16F, <int>ldb, a.data.ptr,
 *                 runtime.CUDA_R_16F, <int>lda, 0, c.data.ptr, Ctype, <int>m)
 *     elif dtype == 'f':             # <<<<<<<<<<<<<<
 *         cublas.sgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int> n, <int> k, 1,
 */
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_f, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3875, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_9 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3876
 *                 runtime.CUDA_R_16F, <int>lda, 0, c.data.ptr, Ctype, <int>m)
 *     elif dtype == 'f':
 *         cublas.sgemm(             # <<<<<<<<<<<<<<
 *             handle, <int>transb, <int>transa, <int>m, <int> n, <int> k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 */
    __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_sgemm(__pyx_v_handle, ((int)__pyx_v_transb), ((int)__pyx_v_transa), ((int)__pyx_v_m), ((int)__pyx_v_n), ((int)__pyx_v_k), 1.0, __pyx_v_b->data->ptr, ((int)__pyx_v_ldb), __pyx_v_a->data->ptr, ((int)__pyx_v_lda), 0.0, __pyx_v_c->data->ptr, ((int)__pyx_v_m), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3876, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3875
 *                 b.data.ptr, runtime.CUDA_R_16F, <int>ldb, a.data.ptr,
 *                 runtime.CUDA_R_16F, <int>lda, 0, c.data.ptr, Ctype, <int>m)
 *     elif dtype == 'f':             # <<<<<<<<<<<<<<
 *         cublas.sgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int> n, <int> k, 1,
 */
    goto __pyx_L40;
  }

  /* "cupy/core/core.pyx":3879
 *             handle, <int>transb, <int>transa, <int>m, <int> n, <int> k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'd':             # <<<<<<<<<<<<<<
 *         cublas.dgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 */
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_d, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3879, __pyx_L1_error)
  __pyx_t_9 = (__pyx_t_2 != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":3880
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'd':
 *         cublas.dgemm(             # <<<<<<<<<<<<<<
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 */
    __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_dgemm(__pyx_v_handle, ((int)__pyx_v_transb), ((int)__pyx_v_transa), ((int)__pyx_v_m), ((int)__pyx_v_n), ((int)__pyx_v_k), 1.0, __pyx_v_b->data->ptr, ((int)__pyx_v_ldb), __pyx_v_a->data->ptr, ((int)__pyx_v_lda), 0.0, __pyx_v_c->data->ptr, ((int)__pyx_v_m), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3880, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3879
 *             handle, <int>transb, <int>transa, <int>m, <int> n, <int> k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'd':             # <<<<<<<<<<<<<<
 *         cublas.dgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 */
    goto __pyx_L40;
  }

  /* "cupy/core/core.pyx":3883
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'F':             # <<<<<<<<<<<<<<
 *         cublas.cgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 */
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_F, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 3883, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_9 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3884
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'F':
 *         cublas.cgemm(             # <<<<<<<<<<<<<<
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 */
    __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_cgemm(__pyx_v_handle, ((int)__pyx_v_transb), ((int)__pyx_v_transa), ((int)__pyx_v_m), ((int)__pyx_v_n), ((int)__pyx_v_k), __pyx_t_float_complex_from_parts(1, 0), __pyx_v_b->data->ptr, ((int)__pyx_v_ldb), __pyx_v_a->data->ptr, ((int)__pyx_v_lda), __pyx_t_float_complex_from_parts(0, 0), __pyx_v_c->data->ptr, ((int)__pyx_v_m), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3884, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3883
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'F':             # <<<<<<<<<<<<<<
 *         cublas.cgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 */
    goto __pyx_L40;
  }

  /* "cupy/core/core.pyx":3887
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'D':             # <<<<<<<<<<<<<<
 *         cublas.zgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 */
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_D, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 3887, __pyx_L1_error)
  __pyx_t_9 = (__pyx_t_2 != 0);
  if (likely(__pyx_t_9)) {

    /* "cupy/core/core.pyx":3888
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'D':
 *         cublas.zgemm(             # <<<<<<<<<<<<<<
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 */
    __pyx_t_3 = __pyx_f_4cupy_4cuda_6cublas_zgemm(__pyx_v_handle, ((int)__pyx_v_transb), ((int)__pyx_v_transa), ((int)__pyx_v_m), ((int)__pyx_v_n), ((int)__pyx_v_k), __pyx_t_double_complex_from_parts(1, 0), __pyx_v_b->data->ptr, ((int)__pyx_v_ldb), __pyx_v_a->data->ptr, ((int)__pyx_v_lda), __pyx_t_double_complex_from_parts(0, 0), __pyx_v_c->data->ptr, ((int)__pyx_v_m), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3888, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3887
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     elif dtype == 'D':             # <<<<<<<<<<<<<<
 *         cublas.zgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 */
    goto __pyx_L40;
  }

  /* "cupy/core/core.pyx":3892
 *             b.data.ptr, <int>ldb, a.data.ptr, <int>lda, 0, c.data.ptr, <int>m)
 *     else:
 *         raise ValueError('Invalid dtype: %s' % str(dtype))             # <<<<<<<<<<<<<<
 * 
 *     if out is not ret:
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3892, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_dtype_s, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3892, __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_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3892, __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(0, 3892, __pyx_L1_error)
  }
  __pyx_L40:;

  /* "cupy/core/core.pyx":3894
 *         raise ValueError('Invalid dtype: %s' % str(dtype))
 * 
 *     if out is not ret:             # <<<<<<<<<<<<<<
 *         elementwise_copy(out, ret)
 *     return ret
 */
  __pyx_t_9 = (__pyx_v_out != __pyx_v_ret);
  __pyx_t_2 = (__pyx_t_9 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":3895
 * 
 *     if out is not ret:
 *         elementwise_copy(out, ret)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3895, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3895, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3895, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_out));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_6, ((PyObject *)__pyx_v_out));
      __Pyx_INCREF(((PyObject *)__pyx_v_ret));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_6, ((PyObject *)__pyx_v_ret));
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":3894
 *         raise ValueError('Invalid dtype: %s' % str(dtype))
 * 
 *     if out is not ret:             # <<<<<<<<<<<<<<
 *         elementwise_copy(out, ret)
 *     return ret
 */
  }

  /* "cupy/core/core.pyx":3896
 *     if out is not ret:
 *         elementwise_copy(out, ret)
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3776
 * 
 * 
 * cpdef ndarray tensordot_core(             # <<<<<<<<<<<<<<
 *         ndarray a, ndarray b, ndarray out, Py_ssize_t n, Py_ssize_t m,
 *         Py_ssize_t k, vector.vector[Py_ssize_t] ret_shape):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core.tensordot_core", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_ret_dtype);
  __Pyx_XDECREF(__pyx_v_use_tensor_core);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XDECREF((PyObject *)__pyx_v_c);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_b);
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_107tensordot_core(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_106tensordot_core[] = "tensordot_core(ndarray a, ndarray b, ndarray out, Py_ssize_t n, Py_ssize_t m, Py_ssize_t k, vector[Py_ssize_t] ret_shape) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_107tensordot_core(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = 0;
  Py_ssize_t __pyx_v_n;
  Py_ssize_t __pyx_v_m;
  Py_ssize_t __pyx_v_k;
  std::vector<Py_ssize_t>  __pyx_v_ret_shape;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tensordot_core (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_b,&__pyx_n_s_out,&__pyx_n_s_n,&__pyx_n_s_m,&__pyx_n_s_k,&__pyx_n_s_ret_shape,0};
    PyObject* values[7] = {0,0,0,0,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  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_a)) != 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_b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tensordot_core", 1, 7, 7, 1); __PYX_ERR(0, 3776, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tensordot_core", 1, 7, 7, 2); __PYX_ERR(0, 3776, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tensordot_core", 1, 7, 7, 3); __PYX_ERR(0, 3776, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tensordot_core", 1, 7, 7, 4); __PYX_ERR(0, 3776, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tensordot_core", 1, 7, 7, 5); __PYX_ERR(0, 3776, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ret_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tensordot_core", 1, 7, 7, 6); __PYX_ERR(0, 3776, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tensordot_core") < 0)) __PYX_ERR(0, 3776, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_b = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_n = __Pyx_PyIndex_AsSsize_t(values[3]); if (unlikely((__pyx_v_n == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3777, __pyx_L3_error)
    __pyx_v_m = __Pyx_PyIndex_AsSsize_t(values[4]); if (unlikely((__pyx_v_m == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3777, __pyx_L3_error)
    __pyx_v_k = __Pyx_PyIndex_AsSsize_t(values[5]); if (unlikely((__pyx_v_k == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3778, __pyx_L3_error)
    __pyx_v_ret_shape = __pyx_convert_vector_from_py_Py_ssize_t(values[6]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3778, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("tensordot_core", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3776, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.tensordot_core", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3777, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(0, 3777, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 3777, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_106tensordot_core(__pyx_self, __pyx_v_a, __pyx_v_b, __pyx_v_out, __pyx_v_n, __pyx_v_m, __pyx_v_k, __pyx_v_ret_shape);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_106tensordot_core(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out, Py_ssize_t __pyx_v_n, Py_ssize_t __pyx_v_m, Py_ssize_t __pyx_v_k, std::vector<Py_ssize_t>  __pyx_v_ret_shape) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("tensordot_core", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_tensordot_core(__pyx_v_a, __pyx_v_b, __pyx_v_out, __pyx_v_n, __pyx_v_m, __pyx_v_k, __pyx_v_ret_shape, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3776, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.tensordot_core", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3900
 * 
 * @cython.profile(False)
 * cpdef inline tuple _mat_to_cublas_contiguous(ndarray a, Py_ssize_t trans):             # <<<<<<<<<<<<<<
 *     assert a.ndim == 2
 *     if a._f_contiguous:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_109_mat_to_cublas_contiguous(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, Py_ssize_t __pyx_v_trans, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_lda = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("_mat_to_cublas_contiguous", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_a);

  /* "cupy/core/core.pyx":3901
 * @cython.profile(False)
 * cpdef inline tuple _mat_to_cublas_contiguous(ndarray a, Py_ssize_t trans):
 *     assert a.ndim == 2             # <<<<<<<<<<<<<<
 *     if a._f_contiguous:
 *         # builtin max function is not used for Cython 0.23
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3901, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3901, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3901, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 3901, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/core/core.pyx":3902
 * cpdef inline tuple _mat_to_cublas_contiguous(ndarray a, Py_ssize_t trans):
 *     assert a.ndim == 2
 *     if a._f_contiguous:             # <<<<<<<<<<<<<<
 *         # builtin max function is not used for Cython 0.23
 *         lda = a._strides[1] // a.itemsize
 */
  __pyx_t_3 = (__pyx_v_a->_f_contiguous != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3904
 *     if a._f_contiguous:
 *         # builtin max function is not used for Cython 0.23
 *         lda = a._strides[1] // a.itemsize             # <<<<<<<<<<<<<<
 *         if lda < a._shape[0]:
 *             lda = a._shape[0]
 */
    __pyx_t_2 = PyInt_FromSsize_t((__pyx_v_a->_strides[1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3904, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3904, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_FloorDivide(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3904, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_lda = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3905
 *         # builtin max function is not used for Cython 0.23
 *         lda = a._strides[1] // a.itemsize
 *         if lda < a._shape[0]:             # <<<<<<<<<<<<<<
 *             lda = a._shape[0]
 *         return a, trans, lda
 */
    __pyx_t_4 = PyInt_FromSsize_t((__pyx_v_a->_shape[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3905, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_lda, __pyx_t_4, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3905, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3905, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":3906
 *         lda = a._strides[1] // a.itemsize
 *         if lda < a._shape[0]:
 *             lda = a._shape[0]             # <<<<<<<<<<<<<<
 *         return a, trans, lda
 *     if not a._c_contiguous:
 */
      __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_a->_shape[0])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3906, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_lda, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":3905
 *         # builtin max function is not used for Cython 0.23
 *         lda = a._strides[1] // a.itemsize
 *         if lda < a._shape[0]:             # <<<<<<<<<<<<<<
 *             lda = a._shape[0]
 *         return a, trans, lda
 */
    }

    /* "cupy/core/core.pyx":3907
 *         if lda < a._shape[0]:
 *             lda = a._shape[0]
 *         return a, trans, lda             # <<<<<<<<<<<<<<
 *     if not a._c_contiguous:
 *         a = a.copy()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_trans); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3907, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3907, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_lda);
    __Pyx_GIVEREF(__pyx_v_lda);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_lda);
    __pyx_t_1 = 0;
    __pyx_r = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3902
 * cpdef inline tuple _mat_to_cublas_contiguous(ndarray a, Py_ssize_t trans):
 *     assert a.ndim == 2
 *     if a._f_contiguous:             # <<<<<<<<<<<<<<
 *         # builtin max function is not used for Cython 0.23
 *         lda = a._strides[1] // a.itemsize
 */
  }

  /* "cupy/core/core.pyx":3908
 *             lda = a._shape[0]
 *         return a, trans, lda
 *     if not a._c_contiguous:             # <<<<<<<<<<<<<<
 *         a = a.copy()
 *     return a, 1 - trans, a._strides[0] // a.itemsize
 */
  __pyx_t_3 = ((!(__pyx_v_a->_c_contiguous != 0)) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":3909
 *         return a, trans, lda
 *     if not a._c_contiguous:
 *         a = a.copy()             # <<<<<<<<<<<<<<
 *     return a, 1 - trans, a._strides[0] // a.itemsize
 * 
 */
    __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->copy(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3909, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":3908
 *             lda = a._shape[0]
 *         return a, trans, lda
 *     if not a._c_contiguous:             # <<<<<<<<<<<<<<
 *         a = a.copy()
 *     return a, 1 - trans, a._strides[0] // a.itemsize
 */
  }

  /* "cupy/core/core.pyx":3910
 *     if not a._c_contiguous:
 *         a = a.copy()
 *     return a, 1 - trans, a._strides[0] // a.itemsize             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyInt_FromSsize_t((1 - __pyx_v_trans)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_a->_strides[0])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyNumber_FloorDivide(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_a));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_a));
  __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_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_r = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3900
 * 
 * @cython.profile(False)
 * cpdef inline tuple _mat_to_cublas_contiguous(ndarray a, Py_ssize_t trans):             # <<<<<<<<<<<<<<
 *     assert a.ndim == 2
 *     if a._f_contiguous:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core._mat_to_cublas_contiguous", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_lda);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_109_mat_to_cublas_contiguous(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_108_mat_to_cublas_contiguous[] = "_mat_to_cublas_contiguous(ndarray a, Py_ssize_t trans) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_109_mat_to_cublas_contiguous(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  Py_ssize_t __pyx_v_trans;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_mat_to_cublas_contiguous (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_trans,0};
    PyObject* values[2] = {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  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_a)) != 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_trans)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_mat_to_cublas_contiguous", 1, 2, 2, 1); __PYX_ERR(0, 3900, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_mat_to_cublas_contiguous") < 0)) __PYX_ERR(0, 3900, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_trans = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_trans == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3900, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_mat_to_cublas_contiguous", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3900, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._mat_to_cublas_contiguous", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3900, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_108_mat_to_cublas_contiguous(__pyx_self, __pyx_v_a, __pyx_v_trans);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_108_mat_to_cublas_contiguous(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, Py_ssize_t __pyx_v_trans) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_mat_to_cublas_contiguous", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(__pyx_v_a, __pyx_v_trans, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3900, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._mat_to_cublas_contiguous", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3914
 * 
 * @cython.profile(False)
 * cpdef inline tuple _to_cublas_vector(ndarray a, Py_ssize_t rundim):             # <<<<<<<<<<<<<<
 *     if a._strides[rundim] < 0:
 *         return a.copy(), 1
 */

static PyObject *__pyx_pw_4cupy_4core_4core_111_to_cublas_vector(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__to_cublas_vector(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, Py_ssize_t __pyx_v_rundim, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("_to_cublas_vector", 0);

  /* "cupy/core/core.pyx":3915
 * @cython.profile(False)
 * cpdef inline tuple _to_cublas_vector(ndarray a, Py_ssize_t rundim):
 *     if a._strides[rundim] < 0:             # <<<<<<<<<<<<<<
 *         return a.copy(), 1
 *     else:
 */
  __pyx_t_1 = (((__pyx_v_a->_strides[__pyx_v_rundim]) < 0) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3916
 * cpdef inline tuple _to_cublas_vector(ndarray a, Py_ssize_t rundim):
 *     if a._strides[rundim] < 0:
 *         return a.copy(), 1             # <<<<<<<<<<<<<<
 *     else:
 *         return a, a._strides[rundim] // a.itemsize
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->copy(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3916, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3916, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __Pyx_INCREF(__pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
    __pyx_t_2 = 0;
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":3915
 * @cython.profile(False)
 * cpdef inline tuple _to_cublas_vector(ndarray a, Py_ssize_t rundim):
 *     if a._strides[rundim] < 0:             # <<<<<<<<<<<<<<
 *         return a.copy(), 1
 *     else:
 */
  }

  /* "cupy/core/core.pyx":3918
 *         return a.copy(), 1
 *     else:
 *         return a, a._strides[rundim] // a.itemsize             # <<<<<<<<<<<<<<
 * 
 * # -----------------------------------------------------------------------------
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_a->_strides[__pyx_v_rundim])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3918, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3918, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyNumber_FloorDivide(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3918, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3918, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_r = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":3914
 * 
 * @cython.profile(False)
 * cpdef inline tuple _to_cublas_vector(ndarray a, Py_ssize_t rundim):             # <<<<<<<<<<<<<<
 *     if a._strides[rundim] < 0:
 *         return a.copy(), 1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core._to_cublas_vector", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_111_to_cublas_vector(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_110_to_cublas_vector[] = "_to_cublas_vector(ndarray a, Py_ssize_t rundim) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_111_to_cublas_vector(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  Py_ssize_t __pyx_v_rundim;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_to_cublas_vector (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_rundim,0};
    PyObject* values[2] = {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  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_a)) != 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_rundim)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_to_cublas_vector", 1, 2, 2, 1); __PYX_ERR(0, 3914, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_to_cublas_vector") < 0)) __PYX_ERR(0, 3914, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_rundim = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_rundim == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 3914, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_to_cublas_vector", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3914, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._to_cublas_vector", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 3914, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_110_to_cublas_vector(__pyx_self, __pyx_v_a, __pyx_v_rundim);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_110_to_cublas_vector(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, Py_ssize_t __pyx_v_rundim) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_to_cublas_vector", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__to_cublas_vector(__pyx_v_a, __pyx_v_rundim, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3914, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._to_cublas_vector", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":3924
 * # -----------------------------------------------------------------------------
 * 
 * cpdef create_comparison(name, op, doc='', require_sortable_dtype=True):             # <<<<<<<<<<<<<<
 * 
 *     if require_sortable_dtype:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_113create_comparison(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_create_comparison(PyObject *__pyx_v_name, PyObject *__pyx_v_op, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_create_comparison *__pyx_optional_args) {
  PyObject *__pyx_v_doc = ((PyObject *)__pyx_kp_s__6);
  PyObject *__pyx_v_require_sortable_dtype = ((PyObject *)Py_True);
  PyObject *__pyx_v_ops = NULL;
  PyObject *__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;
  __Pyx_RefNannySetupContext("create_comparison", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_doc = __pyx_optional_args->doc;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_require_sortable_dtype = __pyx_optional_args->require_sortable_dtype;
      }
    }
  }

  /* "cupy/core/core.pyx":3926
 * cpdef create_comparison(name, op, doc='', require_sortable_dtype=True):
 * 
 *     if require_sortable_dtype:             # <<<<<<<<<<<<<<
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_require_sortable_dtype); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 3926, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":3927
 * 
 *     if require_sortable_dtype:
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',             # <<<<<<<<<<<<<<
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 *     else:
 */
    __Pyx_INCREF(__pyx_tuple__165);
    __pyx_v_ops = __pyx_tuple__165;

    /* "cupy/core/core.pyx":3926
 * cpdef create_comparison(name, op, doc='', require_sortable_dtype=True):
 * 
 *     if require_sortable_dtype:             # <<<<<<<<<<<<<<
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":3930
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 *     else:
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',             # <<<<<<<<<<<<<<
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'FF->?',
 *                'dd->?', 'DD->?')
 */
  /*else*/ {
    __Pyx_INCREF(__pyx_tuple__166);
    __pyx_v_ops = __pyx_tuple__166;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":3933
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'FF->?',
 *                'dd->?', 'DD->?')
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         ops,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3933, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/core.pyx":3934
 *                'dd->?', 'DD->?')
 *     return create_ufunc(
 *         'cupy_' + name,             # <<<<<<<<<<<<<<
 *         ops,
 *         'out0 = in0 %s in1' % op,
 */
  __pyx_t_3 = PyNumber_Add(__pyx_n_s_cupy_2, __pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3934, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/core.pyx":3936
 *         'cupy_' + name,
 *         ops,
 *         'out0 = in0 %s in1' % op,             # <<<<<<<<<<<<<<
 *         doc=doc)
 * 
 */
  __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_out0_in0_s_in1, __pyx_v_op); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3936, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":3933
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'FF->?',
 *                'dd->?', 'DD->?')
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         ops,
 */
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3933, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_ops);
  __Pyx_GIVEREF(__pyx_v_ops);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_ops);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":3937
 *         ops,
 *         'out0 = in0 %s in1' % op,
 *         doc=doc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3937, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_doc, __pyx_v_doc) < 0) __PYX_ERR(0, 3937, __pyx_L1_error)

  /* "cupy/core/core.pyx":3933
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'FF->?',
 *                'dd->?', 'DD->?')
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         ops,
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3933, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":3924
 * # -----------------------------------------------------------------------------
 * 
 * cpdef create_comparison(name, op, doc='', require_sortable_dtype=True):             # <<<<<<<<<<<<<<
 * 
 *     if require_sortable_dtype:
 */

  /* 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("cupy.core.core.create_comparison", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ops);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_113create_comparison(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_112create_comparison[] = "create_comparison(name, op, doc='', require_sortable_dtype=True)";
static PyObject *__pyx_pw_4cupy_4core_4core_113create_comparison(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_v_doc = 0;
  PyObject *__pyx_v_require_sortable_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_comparison (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_op,&__pyx_n_s_doc,&__pyx_n_s_require_sortable_dtype,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = ((PyObject *)__pyx_kp_s__6);
    values[3] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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_name)) != 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_op)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_comparison", 0, 2, 4, 1); __PYX_ERR(0, 3924, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_doc);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_require_sortable_dtype);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_comparison") < 0)) __PYX_ERR(0, 3924, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_name = values[0];
    __pyx_v_op = values[1];
    __pyx_v_doc = values[2];
    __pyx_v_require_sortable_dtype = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_comparison", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3924, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.create_comparison", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_112create_comparison(__pyx_self, __pyx_v_name, __pyx_v_op, __pyx_v_doc, __pyx_v_require_sortable_dtype);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_112create_comparison(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_op, PyObject *__pyx_v_doc, PyObject *__pyx_v_require_sortable_dtype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_create_comparison __pyx_t_2;
  __Pyx_RefNannySetupContext("create_comparison", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.doc = __pyx_v_doc;
  __pyx_t_2.require_sortable_dtype = __pyx_v_require_sortable_dtype;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_v_name, __pyx_v_op, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3924, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.create_comparison", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4050
 * 
 * 
 * cdef create_arithmetic(name, op, boolop, doc):             # <<<<<<<<<<<<<<
 *     return create_ufunc(
 *         'cupy_' + name,
 */

static PyObject *__pyx_f_4cupy_4core_4core_create_arithmetic(PyObject *__pyx_v_name, PyObject *__pyx_v_op, PyObject *__pyx_v_boolop, PyObject *__pyx_v_doc) {
  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;
  __Pyx_RefNannySetupContext("create_arithmetic", 0);

  /* "cupy/core/core.pyx":4051
 * 
 * cdef create_arithmetic(name, op, boolop, doc):
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         (('??->?', 'out0 = in0 %s in1' % boolop),
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":4052
 * cdef create_arithmetic(name, op, boolop, doc):
 *     return create_ufunc(
 *         'cupy_' + name,             # <<<<<<<<<<<<<<
 *         (('??->?', 'out0 = in0 %s in1' % boolop),
 *          'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 */
  __pyx_t_2 = PyNumber_Add(__pyx_n_s_cupy_2, __pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4052, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/core.pyx":4053
 *     return create_ufunc(
 *         'cupy_' + name,
 *         (('??->?', 'out0 = in0 %s in1' % boolop),             # <<<<<<<<<<<<<<
 *          'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 *          'LL->L', 'qq->q', 'QQ->Q', 'ee->e', 'ff->f', 'dd->d', 'FF->F',
 */
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_out0_in0_s_in1, __pyx_v_boolop); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4053, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4053, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_kp_s__105);
  __Pyx_GIVEREF(__pyx_kp_s__105);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_s__105);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4053, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __Pyx_INCREF(__pyx_kp_s_bb_b);
  __Pyx_GIVEREF(__pyx_kp_s_bb_b);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_kp_s_bb_b);
  __Pyx_INCREF(__pyx_kp_s_BB_B);
  __Pyx_GIVEREF(__pyx_kp_s_BB_B);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_s_BB_B);
  __Pyx_INCREF(__pyx_kp_s_hh_h);
  __Pyx_GIVEREF(__pyx_kp_s_hh_h);
  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_kp_s_hh_h);
  __Pyx_INCREF(__pyx_kp_s_HH_H);
  __Pyx_GIVEREF(__pyx_kp_s_HH_H);
  PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_kp_s_HH_H);
  __Pyx_INCREF(__pyx_kp_s_ii_i);
  __Pyx_GIVEREF(__pyx_kp_s_ii_i);
  PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_kp_s_ii_i);
  __Pyx_INCREF(__pyx_kp_s_II_I);
  __Pyx_GIVEREF(__pyx_kp_s_II_I);
  PyTuple_SET_ITEM(__pyx_t_3, 6, __pyx_kp_s_II_I);
  __Pyx_INCREF(__pyx_kp_s_ll_l);
  __Pyx_GIVEREF(__pyx_kp_s_ll_l);
  PyTuple_SET_ITEM(__pyx_t_3, 7, __pyx_kp_s_ll_l);
  __Pyx_INCREF(__pyx_kp_s_LL_L);
  __Pyx_GIVEREF(__pyx_kp_s_LL_L);
  PyTuple_SET_ITEM(__pyx_t_3, 8, __pyx_kp_s_LL_L);
  __Pyx_INCREF(__pyx_kp_s_qq_q);
  __Pyx_GIVEREF(__pyx_kp_s_qq_q);
  PyTuple_SET_ITEM(__pyx_t_3, 9, __pyx_kp_s_qq_q);
  __Pyx_INCREF(__pyx_kp_s_QQ_Q);
  __Pyx_GIVEREF(__pyx_kp_s_QQ_Q);
  PyTuple_SET_ITEM(__pyx_t_3, 10, __pyx_kp_s_QQ_Q);
  __Pyx_INCREF(__pyx_kp_s_ee_e);
  __Pyx_GIVEREF(__pyx_kp_s_ee_e);
  PyTuple_SET_ITEM(__pyx_t_3, 11, __pyx_kp_s_ee_e);
  __Pyx_INCREF(__pyx_kp_s_ff_f);
  __Pyx_GIVEREF(__pyx_kp_s_ff_f);
  PyTuple_SET_ITEM(__pyx_t_3, 12, __pyx_kp_s_ff_f);
  __Pyx_INCREF(__pyx_kp_s_dd_d);
  __Pyx_GIVEREF(__pyx_kp_s_dd_d);
  PyTuple_SET_ITEM(__pyx_t_3, 13, __pyx_kp_s_dd_d);
  __Pyx_INCREF(__pyx_kp_s_FF_F);
  __Pyx_GIVEREF(__pyx_kp_s_FF_F);
  PyTuple_SET_ITEM(__pyx_t_3, 14, __pyx_kp_s_FF_F);
  __Pyx_INCREF(__pyx_kp_s_DD_D);
  __Pyx_GIVEREF(__pyx_kp_s_DD_D);
  PyTuple_SET_ITEM(__pyx_t_3, 15, __pyx_kp_s_DD_D);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":4057
 *          'LL->L', 'qq->q', 'QQ->Q', 'ee->e', 'ff->f', 'dd->d', 'FF->F',
 *          'DD->D'),
 *         'out0 = in0 %s in1' % op,             # <<<<<<<<<<<<<<
 *         doc=doc)
 * 
 */
  __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_out0_in0_s_in1, __pyx_v_op); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4057, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":4051
 * 
 * cdef create_arithmetic(name, op, boolop, doc):
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         (('??->?', 'out0 = in0 %s in1' % boolop),
 */
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":4058
 *          'DD->D'),
 *         'out0 = in0 %s in1' % op,
 *         doc=doc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4058, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_doc, __pyx_v_doc) < 0) __PYX_ERR(0, 4058, __pyx_L1_error)

  /* "cupy/core/core.pyx":4051
 * 
 * cdef create_arithmetic(name, op, boolop, doc):
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         (('??->?', 'out0 = in0 %s in1' % boolop),
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":4050
 * 
 * 
 * cdef create_arithmetic(name, op, boolop, doc):             # <<<<<<<<<<<<<<
 *     return create_ufunc(
 *         'cupy_' + name,
 */

  /* 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_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.create_arithmetic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4284
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                    keepdims=False):
 *     assert a.dtype.kind != 'c', 'Variance for complex numbers is not ' \
 */

static PyObject *__pyx_pw_4cupy_4core_4core_115_var(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__var(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__var *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_ddof = ((PyObject *)__pyx_int_0);

  /* "cupy/core/core.pyx":4285
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,
 *                    keepdims=False):             # <<<<<<<<<<<<<<
 *     assert a.dtype.kind != 'c', 'Variance for complex numbers is not ' \
 *                                 'implemented. Current implemention does not ' \
 */
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_items = NULL;
  PyObject *__pyx_v_ax = NULL;
  PyObject *__pyx_v_alpha = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arrmean = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  long __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("_var", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_dtype = __pyx_optional_args->dtype;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_ddof = __pyx_optional_args->ddof;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_keepdims = __pyx_optional_args->keepdims;
            }
          }
        }
      }
    }
  }
  __Pyx_INCREF(__pyx_v_axis);
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/core.pyx":4286
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,
 *                    keepdims=False):
 *     assert a.dtype.kind != 'c', 'Variance for complex numbers is not ' \             # <<<<<<<<<<<<<<
 *                                 'implemented. Current implemention does not ' \
 *                                 'convert the dtype'
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4286, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_c, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 4286, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_2)) {
      PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Variance_for_complex_numbers_is);
      __PYX_ERR(0, 4286, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/core/core.pyx":4289
 *                                 'implemented. Current implemention does not ' \
 *                                 'convert the dtype'
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):
 */
  __pyx_t_2 = (__pyx_v_axis == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":4290
 *                                 'convert the dtype'
 *     if axis is None:
 *         axis = tuple(range(a.ndim))             # <<<<<<<<<<<<<<
 *     if not isinstance(axis, tuple):
 *         axis = (axis,)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":4289
 *                                 'implemented. Current implemention does not ' \
 *                                 'convert the dtype'
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):
 */
  }

  /* "cupy/core/core.pyx":4291
 *     if axis is None:
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):             # <<<<<<<<<<<<<<
 *         axis = (axis,)
 * 
 */
  __pyx_t_3 = PyTuple_Check(__pyx_v_axis); 
  __pyx_t_2 = ((!(__pyx_t_3 != 0)) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":4292
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):
 *         axis = (axis,)             # <<<<<<<<<<<<<<
 * 
 *     if dtype is None and a.dtype.kind in 'biu':
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4292, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_axis);
    __Pyx_GIVEREF(__pyx_v_axis);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_axis);
    __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":4291
 *     if axis is None:
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):             # <<<<<<<<<<<<<<
 *         axis = (axis,)
 * 
 */
  }

  /* "cupy/core/core.pyx":4294
 *         axis = (axis,)
 * 
 *     if dtype is None and a.dtype.kind in 'biu':             # <<<<<<<<<<<<<<
 *         dtype = 'd'
 * 
 */
  __pyx_t_3 = (__pyx_v_dtype == Py_None);
  __pyx_t_5 = (__pyx_t_3 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_n_s_biu, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 4294, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_5 != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":4295
 * 
 *     if dtype is None and a.dtype.kind in 'biu':
 *         dtype = 'd'             # <<<<<<<<<<<<<<
 * 
 *     shape = a.shape
 */
    __Pyx_INCREF(__pyx_n_s_d);
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_n_s_d);

    /* "cupy/core/core.pyx":4294
 *         axis = (axis,)
 * 
 *     if dtype is None and a.dtype.kind in 'biu':             # <<<<<<<<<<<<<<
 *         dtype = 'd'
 * 
 */
  }

  /* "cupy/core/core.pyx":4297
 *         dtype = 'd'
 * 
 *     shape = a.shape             # <<<<<<<<<<<<<<
 *     items = 1
 *     for ax in axis:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_shape = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4298
 * 
 *     shape = a.shape
 *     items = 1             # <<<<<<<<<<<<<<
 *     for ax in axis:
 *         items *= shape[ax]
 */
  __Pyx_INCREF(__pyx_int_1);
  __pyx_v_items = __pyx_int_1;

  /* "cupy/core/core.pyx":4299
 *     shape = a.shape
 *     items = 1
 *     for ax in axis:             # <<<<<<<<<<<<<<
 *         items *= shape[ax]
 *     alpha = 1. / max(items - ddof, 0)
 */
  if (likely(PyList_CheckExact(__pyx_v_axis)) || PyTuple_CheckExact(__pyx_v_axis)) {
    __pyx_t_1 = __pyx_v_axis; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_axis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4299, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 4299, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4299, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 4299, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4299, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 4299, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_ax, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":4300
 *     items = 1
 *     for ax in axis:
 *         items *= shape[ax]             # <<<<<<<<<<<<<<
 *     alpha = 1. / max(items - ddof, 0)
 *     arrmean = a.mean(axis=axis, dtype=dtype, keepdims=True)
 */
    __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_shape, __pyx_v_ax); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4300, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = PyNumber_InPlaceMultiply(__pyx_v_items, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4300, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":4299
 *     shape = a.shape
 *     items = 1
 *     for ax in axis:             # <<<<<<<<<<<<<<
 *         items *= shape[ax]
 *     alpha = 1. / max(items - ddof, 0)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4301
 *     for ax in axis:
 *         items *= shape[ax]
 *     alpha = 1. / max(items - ddof, 0)             # <<<<<<<<<<<<<<
 *     arrmean = a.mean(axis=axis, dtype=dtype, keepdims=True)
 *     if out is None:
 */
  __pyx_t_9 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_v_items, __pyx_v_ddof); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = PyObject_RichCompare(__pyx_t_4, __pyx_t_1, Py_GT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4301, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 4301, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (__pyx_t_2) {
    __pyx_t_10 = __Pyx_PyInt_From_long(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_8 = __pyx_t_10;
    __pyx_t_10 = 0;
  } else {
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_8 = __pyx_t_1;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyFloat_TrueDivideCObj(__pyx_float_1_, __pyx_t_8, 1., 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_alpha = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4302
 *         items *= shape[ax]
 *     alpha = 1. / max(items - ddof, 0)
 *     arrmean = a.mean(axis=axis, dtype=dtype, keepdims=True)             # <<<<<<<<<<<<<<
 *     if out is None:
 *         return _var_core(a, arrmean, alpha, axis=axis, keepdims=keepdims)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_mean); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 4302, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 4302, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_keepdims, Py_True) < 0) __PYX_ERR(0, 4302, __pyx_L1_error)
  __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 4302, __pyx_L1_error)
  __pyx_v_arrmean = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":4303
 *     alpha = 1. / max(items - ddof, 0)
 *     arrmean = a.mean(axis=axis, dtype=dtype, keepdims=True)
 *     if out is None:             # <<<<<<<<<<<<<<
 *         return _var_core(a, arrmean, alpha, axis=axis, keepdims=keepdims)
 *     else:
 */
  __pyx_t_2 = (__pyx_v_out == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":4304
 *     arrmean = a.mean(axis=axis, dtype=dtype, keepdims=True)
 *     if out is None:
 *         return _var_core(a, arrmean, alpha, axis=axis, keepdims=keepdims)             # <<<<<<<<<<<<<<
 *     else:
 *         return _var_core_out(
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4304, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_v_a));
    __Pyx_INCREF(((PyObject *)__pyx_v_arrmean));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_arrmean));
    PyTuple_SET_ITEM(__pyx_t_10, 1, ((PyObject *)__pyx_v_arrmean));
    __Pyx_INCREF(__pyx_v_alpha);
    __Pyx_GIVEREF(__pyx_v_alpha);
    PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_v_alpha);
    __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4304, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 4304, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 4304, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__var_core, __pyx_t_10, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4304, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 4304, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":4303
 *     alpha = 1. / max(items - ddof, 0)
 *     arrmean = a.mean(axis=axis, dtype=dtype, keepdims=True)
 *     if out is None:             # <<<<<<<<<<<<<<
 *         return _var_core(a, arrmean, alpha, axis=axis, keepdims=keepdims)
 *     else:
 */
  }

  /* "cupy/core/core.pyx":4306
 *         return _var_core(a, arrmean, alpha, axis=axis, keepdims=keepdims)
 *     else:
 *         return _var_core_out(             # <<<<<<<<<<<<<<
 *             a, arrmean, alpha, out, axis=axis, keepdims=keepdims)
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));

    /* "cupy/core/core.pyx":4307
 *     else:
 *         return _var_core_out(
 *             a, arrmean, alpha, out, axis=axis, keepdims=keepdims)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4306, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_a));
    __Pyx_INCREF(((PyObject *)__pyx_v_arrmean));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_arrmean));
    PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_arrmean));
    __Pyx_INCREF(__pyx_v_alpha);
    __Pyx_GIVEREF(__pyx_v_alpha);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_alpha);
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_out);
    __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4307, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 4307, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 4307, __pyx_L1_error)

    /* "cupy/core/core.pyx":4306
 *         return _var_core(a, arrmean, alpha, axis=axis, keepdims=keepdims)
 *     else:
 *         return _var_core_out(             # <<<<<<<<<<<<<<
 *             a, arrmean, alpha, out, axis=axis, keepdims=keepdims)
 * 
 */
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_4core__var_core_out, __pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4306, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 4306, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_10);
    __pyx_t_10 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":4284
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                    keepdims=False):
 *     assert a.dtype.kind != 'c', 'Variance for complex numbers is not ' \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.core.core._var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_ax);
  __Pyx_XDECREF(__pyx_v_alpha);
  __Pyx_XDECREF((PyObject *)__pyx_v_arrmean);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_115_var(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_114_var[] = "_var(ndarray a, axis=None, dtype=None, out=None, ddof=0, keepdims=False) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_115_var(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_ddof = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_var (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_ddof,&__pyx_n_s_keepdims,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)__pyx_int_0);

    /* "cupy/core/core.pyx":4285
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,
 *                    keepdims=False):             # <<<<<<<<<<<<<<
 *     assert a.dtype.kind != 'c', 'Variance for complex numbers is not ' \
 *                                 'implemented. Current implemention does not ' \
 */
    values[5] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          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_ddof);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_var") < 0)) __PYX_ERR(0, 4284, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_axis = values[1];
    __pyx_v_dtype = values[2];
    __pyx_v_out = values[3];
    __pyx_v_ddof = values[4];
    __pyx_v_keepdims = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_var", 0, 1, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4284, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 4284, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_114_var(__pyx_self, __pyx_v_a, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims);

  /* "cupy/core/core.pyx":4284
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray _var(ndarray a, axis=None, dtype=None, out=None, ddof=0,             # <<<<<<<<<<<<<<
 *                    keepdims=False):
 *     assert a.dtype.kind != 'c', 'Variance for complex numbers is not ' \
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_114_var(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_ddof, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__var __pyx_t_2;
  __Pyx_RefNannySetupContext("_var", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 5;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.ddof = __pyx_v_ddof;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__var(__pyx_v_a, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4310
 * 
 * 
 * cpdef _std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False):             # <<<<<<<<<<<<<<
 *     ret = _var(a, axis=axis, dtype=dtype, ddof=ddof, keepdims=keepdims)
 *     return sqrt(ret, dtype=dtype, out=out)
 */

static PyObject *__pyx_pw_4cupy_4core_4core_117_std(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__std(PyObject *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__std *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((PyObject *)Py_None);
  PyObject *__pyx_v_out = ((PyObject *)Py_None);
  PyObject *__pyx_v_ddof = ((PyObject *)__pyx_int_0);
  PyObject *__pyx_v_keepdims = ((PyObject *)Py_False);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = 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;
  __Pyx_RefNannySetupContext("_std", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_dtype = __pyx_optional_args->dtype;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_ddof = __pyx_optional_args->ddof;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_keepdims = __pyx_optional_args->keepdims;
            }
          }
        }
      }
    }
  }

  /* "cupy/core/core.pyx":4311
 * 
 * cpdef _std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False):
 *     ret = _var(a, axis=axis, dtype=dtype, ddof=ddof, keepdims=keepdims)             # <<<<<<<<<<<<<<
 *     return sqrt(ret, dtype=dtype, out=out)
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_var_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_a);
  __Pyx_GIVEREF(__pyx_v_a);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_a);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 4311, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 4311, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_ddof, __pyx_v_ddof) < 0) __PYX_ERR(0, 4311, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) __PYX_ERR(0, 4311, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 4311, __pyx_L1_error)
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":4312
 * cpdef _std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False):
 *     ret = _var(a, axis=axis, dtype=dtype, ddof=ddof, keepdims=keepdims)
 *     return sqrt(ret, dtype=dtype, out=out)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_sqrt); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_ret));
  __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 4312, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 4312, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":4310
 * 
 * 
 * cpdef _std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False):             # <<<<<<<<<<<<<<
 *     ret = _var(a, axis=axis, dtype=dtype, ddof=ddof, keepdims=keepdims)
 *     return sqrt(ret, dtype=dtype, out=out)
 */

  /* 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("cupy.core.core._std", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_117_std(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_116_std[] = "_std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False)";
static PyObject *__pyx_pw_4cupy_4core_4core_117_std(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_ddof = 0;
  PyObject *__pyx_v_keepdims = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_std (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_axis,&__pyx_n_s_dtype,&__pyx_n_s_out,&__pyx_n_s_ddof,&__pyx_n_s_keepdims,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)__pyx_int_0);
    values[5] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          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_ddof);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_keepdims);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_std") < 0)) __PYX_ERR(0, 4310, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = values[0];
    __pyx_v_axis = values[1];
    __pyx_v_dtype = values[2];
    __pyx_v_out = values[3];
    __pyx_v_ddof = values[4];
    __pyx_v_keepdims = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_std", 0, 1, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4310, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._std", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_116_std(__pyx_self, __pyx_v_a, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_116_std(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out, PyObject *__pyx_v_ddof, PyObject *__pyx_v_keepdims) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core__std __pyx_t_2;
  __Pyx_RefNannySetupContext("_std", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 5;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_2.ddof = __pyx_v_ddof;
  __pyx_t_2.keepdims = __pyx_v_keepdims;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__std(__pyx_v_a, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._std", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4341
 * 
 * @util.memoize(for_each_device=True)
 * def _inclusive_scan_kernel(dtype, block_size):             # <<<<<<<<<<<<<<
 *     """return Prefix Sum(Scan) cuda kernel
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_119_inclusive_scan_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_118_inclusive_scan_kernel[] = "_inclusive_scan_kernel(dtype, block_size)\nreturn Prefix Sum(Scan) cuda kernel\n\n    e.g\n    if blocksize * 2 >= len(src)\n    src [1, 2, 3, 4]\n    dst [1, 3, 6, 10]\n\n    if blocksize * 2 < len(src)\n    block_size: 2\n    src [1, 2, 3, 4, 5, 6]\n    dst [1, 3, 6, 10, 5, 11]\n\n    Args:\n        dtype: src, dst array type\n        block_size: block_size\n\n    Returns:\n         cupy.cuda.Function: cuda function\n    ";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_119_inclusive_scan_kernel = {"_inclusive_scan_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_119_inclusive_scan_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_118_inclusive_scan_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_119_inclusive_scan_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_block_size = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_inclusive_scan_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dtype,&__pyx_n_s_block_size,0};
    PyObject* values[2] = {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  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_dtype)) != 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_block_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_inclusive_scan_kernel", 1, 2, 2, 1); __PYX_ERR(0, 4341, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_inclusive_scan_kernel") < 0)) __PYX_ERR(0, 4341, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_dtype = values[0];
    __pyx_v_block_size = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_inclusive_scan_kernel", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4341, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._inclusive_scan_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_118_inclusive_scan_kernel(__pyx_self, __pyx_v_dtype, __pyx_v_block_size);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_118_inclusive_scan_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype, PyObject *__pyx_v_block_size) {
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_source = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_v_module = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_inclusive_scan_kernel", 0);
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/core.pyx":4362
 *     """
 * 
 *     name = "inclusive_scan_kernel"             # <<<<<<<<<<<<<<
 *     dtype = _get_typename(dtype)
 *     source = string.Template("""
 */
  __Pyx_INCREF(__pyx_n_s_inclusive_scan_kernel);
  __pyx_v_name = __pyx_n_s_inclusive_scan_kernel;

  /* "cupy/core/core.pyx":4363
 * 
 *     name = "inclusive_scan_kernel"
 *     dtype = _get_typename(dtype)             # <<<<<<<<<<<<<<
 *     source = string.Template("""
 *     extern "C" __global__ void ${name}(const CArray<${dtype}, 1> src,
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4364
 *     name = "inclusive_scan_kernel"
 *     dtype = _get_typename(dtype)
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *     extern "C" __global__ void ${name}(const CArray<${dtype}, 1> src,
 *         CArray<${dtype}, 1> dst){
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Template); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__167, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":4402
 *         }
 *     }
 *     """).substitute(name=name, dtype=dtype, block_size=block_size)             # <<<<<<<<<<<<<<
 *     module = compile_with_cache(source)
 *     return module.get_function(name)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_substitute); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(0, 4402, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 4402, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_block_size, __pyx_v_block_size) < 0) __PYX_ERR(0, 4402, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_source = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4403
 *     }
 *     """).substitute(name=name, dtype=dtype, block_size=block_size)
 *     module = compile_with_cache(source)             # <<<<<<<<<<<<<<
 *     return module.get_function(name)
 * 
 */
  if (!(likely(PyString_CheckExact(__pyx_v_source))||((__pyx_v_source) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_source)->tp_name), 0))) __PYX_ERR(0, 4403, __pyx_L1_error)
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(((PyObject*)__pyx_v_source), 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_module = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4404
 *     """).substitute(name=name, dtype=dtype, block_size=block_size)
 *     module = compile_with_cache(source)
 *     return module.get_function(name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_name))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(0, 4404, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *)__pyx_v_module->__pyx_vtab)->get_function(__pyx_v_module, ((PyObject*)__pyx_v_name), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":4341
 * 
 * @util.memoize(for_each_device=True)
 * def _inclusive_scan_kernel(dtype, block_size):             # <<<<<<<<<<<<<<
 *     """return Prefix Sum(Scan) cuda kernel
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core._inclusive_scan_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF((PyObject *)__pyx_v_module);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4408
 * 
 * @util.memoize(for_each_device=True)
 * def _add_scan_blocked_sum_kernel(dtype):             # <<<<<<<<<<<<<<
 *     name = "add_scan_blocked_sum_kernel"
 *     dtype = _get_typename(dtype)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_121_add_scan_blocked_sum_kernel(PyObject *__pyx_self, PyObject *__pyx_v_dtype); /*proto*/
static char __pyx_doc_4cupy_4core_4core_120_add_scan_blocked_sum_kernel[] = "_add_scan_blocked_sum_kernel(dtype)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_121_add_scan_blocked_sum_kernel = {"_add_scan_blocked_sum_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_121_add_scan_blocked_sum_kernel, METH_O, __pyx_doc_4cupy_4core_4core_120_add_scan_blocked_sum_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_121_add_scan_blocked_sum_kernel(PyObject *__pyx_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_add_scan_blocked_sum_kernel (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_120_add_scan_blocked_sum_kernel(__pyx_self, ((PyObject *)__pyx_v_dtype));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_120_add_scan_blocked_sum_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_source = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_v_module = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_add_scan_blocked_sum_kernel", 0);
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/core.pyx":4409
 * @util.memoize(for_each_device=True)
 * def _add_scan_blocked_sum_kernel(dtype):
 *     name = "add_scan_blocked_sum_kernel"             # <<<<<<<<<<<<<<
 *     dtype = _get_typename(dtype)
 *     source = string.Template("""
 */
  __Pyx_INCREF(__pyx_n_s_add_scan_blocked_sum_kernel);
  __pyx_v_name = __pyx_n_s_add_scan_blocked_sum_kernel;

  /* "cupy/core/core.pyx":4410
 * def _add_scan_blocked_sum_kernel(dtype):
 *     name = "add_scan_blocked_sum_kernel"
 *     dtype = _get_typename(dtype)             # <<<<<<<<<<<<<<
 *     source = string.Template("""
 *     extern "C" __global__ void ${name}(CArray<${dtype}, 1> src_dst){
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4411
 *     name = "add_scan_blocked_sum_kernel"
 *     dtype = _get_typename(dtype)
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *     extern "C" __global__ void ${name}(CArray<${dtype}, 1> src_dst){
 *         long long n = src_dst.size();
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Template); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__168, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":4422
 *         }
 *     }
 *     """).substitute(name=name, dtype=dtype)             # <<<<<<<<<<<<<<
 *     module = compile_with_cache(source)
 *     return module.get_function(name)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_substitute); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(0, 4422, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 4422, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_source = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4423
 *     }
 *     """).substitute(name=name, dtype=dtype)
 *     module = compile_with_cache(source)             # <<<<<<<<<<<<<<
 *     return module.get_function(name)
 * 
 */
  if (!(likely(PyString_CheckExact(__pyx_v_source))||((__pyx_v_source) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_source)->tp_name), 0))) __PYX_ERR(0, 4423, __pyx_L1_error)
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(((PyObject*)__pyx_v_source), 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_module = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4424
 *     """).substitute(name=name, dtype=dtype)
 *     module = compile_with_cache(source)
 *     return module.get_function(name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_name))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(0, 4424, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *)__pyx_v_module->__pyx_vtab)->get_function(__pyx_v_module, ((PyObject*)__pyx_v_name), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":4408
 * 
 * @util.memoize(for_each_device=True)
 * def _add_scan_blocked_sum_kernel(dtype):             # <<<<<<<<<<<<<<
 *     name = "add_scan_blocked_sum_kernel"
 *     dtype = _get_typename(dtype)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core._add_scan_blocked_sum_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF((PyObject *)__pyx_v_module);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4428
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_1d_kernel(src_dtype, index_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_1d_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_123_nonzero_1d_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_122_nonzero_1d_kernel[] = "_nonzero_1d_kernel(src_dtype, index_dtype)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_123_nonzero_1d_kernel = {"_nonzero_1d_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_123_nonzero_1d_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_122_nonzero_1d_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_123_nonzero_1d_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_src_dtype = 0;
  PyObject *__pyx_v_index_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_nonzero_1d_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_src_dtype,&__pyx_n_s_index_dtype,0};
    PyObject* values[2] = {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  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_src_dtype)) != 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_index_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_nonzero_1d_kernel", 1, 2, 2, 1); __PYX_ERR(0, 4428, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_nonzero_1d_kernel") < 0)) __PYX_ERR(0, 4428, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_src_dtype = values[0];
    __pyx_v_index_dtype = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_nonzero_1d_kernel", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4428, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._nonzero_1d_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_122_nonzero_1d_kernel(__pyx_self, __pyx_v_src_dtype, __pyx_v_index_dtype);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_122_nonzero_1d_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_src_dtype, PyObject *__pyx_v_index_dtype) {
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_source = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_v_module = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_nonzero_1d_kernel", 0);
  __Pyx_INCREF(__pyx_v_src_dtype);
  __Pyx_INCREF(__pyx_v_index_dtype);

  /* "cupy/core/core.pyx":4429
 * @util.memoize(for_each_device=True)
 * def _nonzero_1d_kernel(src_dtype, index_dtype):
 *     name = "nonzero_1d_kernel"             # <<<<<<<<<<<<<<
 *     src_dtype = _get_typename(src_dtype)
 *     index_dtype = _get_typename(index_dtype)
 */
  __Pyx_INCREF(__pyx_n_s_nonzero_1d_kernel_2);
  __pyx_v_name = __pyx_n_s_nonzero_1d_kernel_2;

  /* "cupy/core/core.pyx":4430
 * def _nonzero_1d_kernel(src_dtype, index_dtype):
 *     name = "nonzero_1d_kernel"
 *     src_dtype = _get_typename(src_dtype)             # <<<<<<<<<<<<<<
 *     index_dtype = _get_typename(index_dtype)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_src_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_src_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4431
 *     name = "nonzero_1d_kernel"
 *     src_dtype = _get_typename(src_dtype)
 *     index_dtype = _get_typename(index_dtype)             # <<<<<<<<<<<<<<
 * 
 *     source = string.Template("""
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_index_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_index_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4433
 *     index_dtype = _get_typename(index_dtype)
 * 
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *     extern "C" __global__ void ${name}(const CArray<${src_dtype}, 1> src,
 *         const CArray<${index_dtype}, 1> scaned_index,
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Template); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__169, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":4445
 *         }
 *     }
 *     """).substitute(name=name, src_dtype=src_dtype, index_dtype=index_dtype)             # <<<<<<<<<<<<<<
 *     module = compile_with_cache(source)
 *     return module.get_function(name)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_substitute); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(0, 4445, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_src_dtype, __pyx_v_src_dtype) < 0) __PYX_ERR(0, 4445, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index_dtype, __pyx_v_index_dtype) < 0) __PYX_ERR(0, 4445, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_source = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4446
 *     }
 *     """).substitute(name=name, src_dtype=src_dtype, index_dtype=index_dtype)
 *     module = compile_with_cache(source)             # <<<<<<<<<<<<<<
 *     return module.get_function(name)
 * 
 */
  if (!(likely(PyString_CheckExact(__pyx_v_source))||((__pyx_v_source) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_source)->tp_name), 0))) __PYX_ERR(0, 4446, __pyx_L1_error)
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(((PyObject*)__pyx_v_source), 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_module = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4447
 *     """).substitute(name=name, src_dtype=src_dtype, index_dtype=index_dtype)
 *     module = compile_with_cache(source)
 *     return module.get_function(name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_name))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(0, 4447, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *)__pyx_v_module->__pyx_vtab)->get_function(__pyx_v_module, ((PyObject*)__pyx_v_name), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":4428
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_1d_kernel(src_dtype, index_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_1d_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core._nonzero_1d_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF((PyObject *)__pyx_v_module);
  __Pyx_XDECREF(__pyx_v_src_dtype);
  __Pyx_XDECREF(__pyx_v_index_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4451
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_125_nonzero_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_124_nonzero_kernel[] = "_nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_125_nonzero_kernel = {"_nonzero_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_125_nonzero_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_124_nonzero_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_125_nonzero_kernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_src_dtype = 0;
  PyObject *__pyx_v_src_ndim = 0;
  PyObject *__pyx_v_index_dtype = 0;
  PyObject *__pyx_v_dst_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_nonzero_kernel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_src_dtype,&__pyx_n_s_src_ndim,&__pyx_n_s_index_dtype,&__pyx_n_s_dst_dtype,0};
    PyObject* values[4] = {0,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  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_src_dtype)) != 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_src_ndim)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_nonzero_kernel", 1, 4, 4, 1); __PYX_ERR(0, 4451, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_index_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_nonzero_kernel", 1, 4, 4, 2); __PYX_ERR(0, 4451, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dst_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_nonzero_kernel", 1, 4, 4, 3); __PYX_ERR(0, 4451, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_nonzero_kernel") < 0)) __PYX_ERR(0, 4451, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      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);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_src_dtype = values[0];
    __pyx_v_src_ndim = values[1];
    __pyx_v_index_dtype = values[2];
    __pyx_v_dst_dtype = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_nonzero_kernel", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4451, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._nonzero_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_124_nonzero_kernel(__pyx_self, __pyx_v_src_dtype, __pyx_v_src_ndim, __pyx_v_index_dtype, __pyx_v_dst_dtype);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_124_nonzero_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_src_dtype, PyObject *__pyx_v_src_ndim, PyObject *__pyx_v_index_dtype, PyObject *__pyx_v_dst_dtype) {
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_source = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_v_module = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_nonzero_kernel", 0);
  __Pyx_INCREF(__pyx_v_src_dtype);
  __Pyx_INCREF(__pyx_v_index_dtype);
  __Pyx_INCREF(__pyx_v_dst_dtype);

  /* "cupy/core/core.pyx":4452
 * @util.memoize(for_each_device=True)
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):
 *     name = "nonzero_kernel"             # <<<<<<<<<<<<<<
 *     src_dtype = _get_typename(src_dtype)
 *     index_dtype = _get_typename(index_dtype)
 */
  __Pyx_INCREF(__pyx_n_s_nonzero_kernel_2);
  __pyx_v_name = __pyx_n_s_nonzero_kernel_2;

  /* "cupy/core/core.pyx":4453
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):
 *     name = "nonzero_kernel"
 *     src_dtype = _get_typename(src_dtype)             # <<<<<<<<<<<<<<
 *     index_dtype = _get_typename(index_dtype)
 *     dst_dtype = _get_typename(dst_dtype)
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_src_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4453, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_src_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4454
 *     name = "nonzero_kernel"
 *     src_dtype = _get_typename(src_dtype)
 *     index_dtype = _get_typename(index_dtype)             # <<<<<<<<<<<<<<
 *     dst_dtype = _get_typename(dst_dtype)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_index_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_index_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4455
 *     src_dtype = _get_typename(src_dtype)
 *     index_dtype = _get_typename(index_dtype)
 *     dst_dtype = _get_typename(dst_dtype)             # <<<<<<<<<<<<<<
 * 
 *     source = string.Template("""
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_dst_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_dst_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4457
 *     dst_dtype = _get_typename(dst_dtype)
 * 
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *         extern "C" __global__ void ${name}(const CArray<${src_dtype}, 1> src,
 *             CIndexer<${src_ndim}> shape,
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Template); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__170, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":4478
 *             }
 *         }
 *         """).substitute(name=name, src_dtype=src_dtype,             # <<<<<<<<<<<<<<
 *                         src_ndim=src_ndim, index_dtype=index_dtype,
 *                         dst_dtype=dst_dtype)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_substitute); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(0, 4478, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_src_dtype, __pyx_v_src_dtype) < 0) __PYX_ERR(0, 4478, __pyx_L1_error)

  /* "cupy/core/core.pyx":4479
 *         }
 *         """).substitute(name=name, src_dtype=src_dtype,
 *                         src_ndim=src_ndim, index_dtype=index_dtype,             # <<<<<<<<<<<<<<
 *                         dst_dtype=dst_dtype)
 *     module = compile_with_cache(source)
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_src_ndim, __pyx_v_src_ndim) < 0) __PYX_ERR(0, 4478, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index_dtype, __pyx_v_index_dtype) < 0) __PYX_ERR(0, 4478, __pyx_L1_error)

  /* "cupy/core/core.pyx":4480
 *         """).substitute(name=name, src_dtype=src_dtype,
 *                         src_ndim=src_ndim, index_dtype=index_dtype,
 *                         dst_dtype=dst_dtype)             # <<<<<<<<<<<<<<
 *     module = compile_with_cache(source)
 *     return module.get_function(name)
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dst_dtype, __pyx_v_dst_dtype) < 0) __PYX_ERR(0, 4478, __pyx_L1_error)

  /* "cupy/core/core.pyx":4478
 *             }
 *         }
 *         """).substitute(name=name, src_dtype=src_dtype,             # <<<<<<<<<<<<<<
 *                         src_ndim=src_ndim, index_dtype=index_dtype,
 *                         dst_dtype=dst_dtype)
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_source = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4481
 *                         src_ndim=src_ndim, index_dtype=index_dtype,
 *                         dst_dtype=dst_dtype)
 *     module = compile_with_cache(source)             # <<<<<<<<<<<<<<
 *     return module.get_function(name)
 * 
 */
  if (!(likely(PyString_CheckExact(__pyx_v_source))||((__pyx_v_source) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_source)->tp_name), 0))) __PYX_ERR(0, 4481, __pyx_L1_error)
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(((PyObject*)__pyx_v_source), 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4481, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_module = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4482
 *                         dst_dtype=dst_dtype)
 *     module = compile_with_cache(source)
 *     return module.get_function(name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_name))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(0, 4482, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *)__pyx_v_module->__pyx_vtab)->get_function(__pyx_v_module, ((PyObject*)__pyx_v_name), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4482, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":4451
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core._nonzero_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF((PyObject *)__pyx_v_module);
  __Pyx_XDECREF(__pyx_v_src_dtype);
  __Pyx_XDECREF(__pyx_v_index_dtype);
  __Pyx_XDECREF(__pyx_v_dst_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4485
 * 
 * 
 * cpdef ndarray scan(ndarray a, ndarray out=None):             # <<<<<<<<<<<<<<
 *     """Return the prefix sum(scan) of the elements.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_127scan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_scan(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_scan *__pyx_optional_args) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
  PyObject *__pyx_v_block_size = NULL;
  PyObject *__pyx_v_kern_scan = NULL;
  PyObject *__pyx_v_blocked_sum = NULL;
  PyObject *__pyx_v_kern_add = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_scan __pyx_t_8;
  __Pyx_RefNannySetupContext("scan", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_out = __pyx_optional_args->out;
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_out);

  /* "cupy/core/core.pyx":4497
 * 
 *     """
 *     if a.ndim != 1:             # <<<<<<<<<<<<<<
 *         raise TypeError("Input array should be 1D array.")
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4497, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4497, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 4497, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(__pyx_t_3)) {

    /* "cupy/core/core.pyx":4498
 *     """
 *     if a.ndim != 1:
 *         raise TypeError("Input array should be 1D array.")             # <<<<<<<<<<<<<<
 * 
 *     block_size = 256
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__171, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4498, __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(0, 4498, __pyx_L1_error)

    /* "cupy/core/core.pyx":4497
 * 
 *     """
 *     if a.ndim != 1:             # <<<<<<<<<<<<<<
 *         raise TypeError("Input array should be 1D array.")
 * 
 */
  }

  /* "cupy/core/core.pyx":4500
 *         raise TypeError("Input array should be 1D array.")
 * 
 *     block_size = 256             # <<<<<<<<<<<<<<
 * 
 *     if out is None:
 */
  __Pyx_INCREF(__pyx_int_256);
  __pyx_v_block_size = __pyx_int_256;

  /* "cupy/core/core.pyx":4502
 *     block_size = 256
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(a.shape, dtype=a.dtype)
 *     else:
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_out) == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":4503
 * 
 *     if out is None:
 *         out = ndarray(a.shape, dtype=a.dtype)             # <<<<<<<<<<<<<<
 *     else:
 *         if a.size != out.size:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) __PYX_ERR(0, 4503, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":4502
 *     block_size = 256
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(a.shape, dtype=a.dtype)
 *     else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":4505
 *         out = ndarray(a.shape, dtype=a.dtype)
 *     else:
 *         if a.size != out.size:             # <<<<<<<<<<<<<<
 *             raise ValueError("Provided out is the wrong size")
 * 
 */
  /*else*/ {
    __pyx_t_4 = ((__pyx_v_a->size != __pyx_v_out->size) != 0);
    if (unlikely(__pyx_t_4)) {

      /* "cupy/core/core.pyx":4506
 *     else:
 *         if a.size != out.size:
 *             raise ValueError("Provided out is the wrong size")             # <<<<<<<<<<<<<<
 * 
 *     kern_scan = _inclusive_scan_kernel(a.dtype, block_size)
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__172, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4506, __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(0, 4506, __pyx_L1_error)

      /* "cupy/core/core.pyx":4505
 *         out = ndarray(a.shape, dtype=a.dtype)
 *     else:
 *         if a.size != out.size:             # <<<<<<<<<<<<<<
 *             raise ValueError("Provided out is the wrong size")
 * 
 */
    }
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":4508
 *             raise ValueError("Provided out is the wrong size")
 * 
 *     kern_scan = _inclusive_scan_kernel(a.dtype, block_size)             # <<<<<<<<<<<<<<
 *     kern_scan(grid=((a.size - 1) // (2 * block_size) + 1,),
 *               block=(block_size,),
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_inclusive_scan_kernel_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_a->dtype, __pyx_v_block_size};
    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4508, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_a->dtype, __pyx_v_block_size};
    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4508, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4508, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(__pyx_v_a->dtype);
    __Pyx_GIVEREF(__pyx_v_a->dtype);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_a->dtype);
    __Pyx_INCREF(__pyx_v_block_size);
    __Pyx_GIVEREF(__pyx_v_block_size);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_block_size);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4508, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_kern_scan = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":4509
 * 
 *     kern_scan = _inclusive_scan_kernel(a.dtype, block_size)
 *     kern_scan(grid=((a.size - 1) // (2 * block_size) + 1,),             # <<<<<<<<<<<<<<
 *               block=(block_size,),
 *               args=(a, out),
 */
  __pyx_t_5 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = PyInt_FromSsize_t((__pyx_v_a->size - 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = PyNumber_Multiply(__pyx_int_2, __pyx_v_block_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = PyNumber_FloorDivide(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
  __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_grid, __pyx_t_1) < 0) __PYX_ERR(0, 4509, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4510
 *     kern_scan = _inclusive_scan_kernel(a.dtype, block_size)
 *     kern_scan(grid=((a.size - 1) // (2 * block_size) + 1,),
 *               block=(block_size,),             # <<<<<<<<<<<<<<
 *               args=(a, out),
 *               shared_mem=a.itemsize * block_size * 2)
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_block_size);
  __Pyx_GIVEREF(__pyx_v_block_size);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_block_size);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_block, __pyx_t_1) < 0) __PYX_ERR(0, 4509, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4511
 *     kern_scan(grid=((a.size - 1) // (2 * block_size) + 1,),
 *               block=(block_size,),
 *               args=(a, out),             # <<<<<<<<<<<<<<
 *               shared_mem=a.itemsize * block_size * 2)
 * 
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_a));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_a));
  __Pyx_INCREF(((PyObject *)__pyx_v_out));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_out));
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_args, __pyx_t_1) < 0) __PYX_ERR(0, 4509, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4512
 *               block=(block_size,),
 *               args=(a, out),
 *               shared_mem=a.itemsize * block_size * 2)             # <<<<<<<<<<<<<<
 * 
 *     if (a.size - 1) // (block_size * 2) > 0:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4512, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_v_block_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4512, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Multiply(__pyx_t_7, __pyx_int_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4512, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_shared_mem, __pyx_t_1) < 0) __PYX_ERR(0, 4509, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4509
 * 
 *     kern_scan = _inclusive_scan_kernel(a.dtype, block_size)
 *     kern_scan(grid=((a.size - 1) // (2 * block_size) + 1,),             # <<<<<<<<<<<<<<
 *               block=(block_size,),
 *               args=(a, out),
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_kern_scan, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4514
 *               shared_mem=a.itemsize * block_size * 2)
 * 
 *     if (a.size - 1) // (block_size * 2) > 0:             # <<<<<<<<<<<<<<
 *         blocked_sum = out[block_size * 2 - 1:None:block_size * 2]
 *         scan(blocked_sum, blocked_sum)
 */
  __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_a->size - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyNumber_Multiply(__pyx_v_block_size, __pyx_int_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = PyNumber_FloorDivide(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_7, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 4514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":4515
 * 
 *     if (a.size - 1) // (block_size * 2) > 0:
 *         blocked_sum = out[block_size * 2 - 1:None:block_size * 2]             # <<<<<<<<<<<<<<
 *         scan(blocked_sum, blocked_sum)
 *         kern_add = _add_scan_blocked_sum_kernel(out.dtype)
 */
    __pyx_t_5 = PyNumber_Multiply(__pyx_v_block_size, __pyx_int_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyInt_SubtractObjC(__pyx_t_5, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Multiply(__pyx_v_block_size, __pyx_int_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PySlice_New(__pyx_t_7, Py_None, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_out), __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_blocked_sum = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":4516
 *     if (a.size - 1) // (block_size * 2) > 0:
 *         blocked_sum = out[block_size * 2 - 1:None:block_size * 2]
 *         scan(blocked_sum, blocked_sum)             # <<<<<<<<<<<<<<
 *         kern_add = _add_scan_blocked_sum_kernel(out.dtype)
 *         kern_add(grid=((a.size - 1) // (2 * block_size),),
 */
    if (!(likely(((__pyx_v_blocked_sum) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_blocked_sum, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 4516, __pyx_L1_error)
    if (!(likely(((__pyx_v_blocked_sum) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_blocked_sum, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 4516, __pyx_L1_error)
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_blocked_sum);
    __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core_scan(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_blocked_sum), 0, &__pyx_t_8)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":4517
 *         blocked_sum = out[block_size * 2 - 1:None:block_size * 2]
 *         scan(blocked_sum, blocked_sum)
 *         kern_add = _add_scan_blocked_sum_kernel(out.dtype)             # <<<<<<<<<<<<<<
 *         kern_add(grid=((a.size - 1) // (2 * block_size),),
 *                  block=(2 * block_size - 1,),
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_add_scan_blocked_sum_kernel_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_out->dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4517, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_out->dtype};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4517, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_out->dtype};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4517, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else
      #endif
      {
        __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4517, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_INCREF(__pyx_v_out->dtype);
        __Pyx_GIVEREF(__pyx_v_out->dtype);
        PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_out->dtype);
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4517, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_kern_add = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":4518
 *         scan(blocked_sum, blocked_sum)
 *         kern_add = _add_scan_blocked_sum_kernel(out.dtype)
 *         kern_add(grid=((a.size - 1) // (2 * block_size),),             # <<<<<<<<<<<<<<
 *                  block=(2 * block_size - 1,),
 *                  args=(out,))
 */
    __pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_a->size - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyNumber_Multiply(__pyx_int_2, __pyx_v_block_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = PyNumber_FloorDivide(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7);
    __pyx_t_7 = 0;
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_grid, __pyx_t_2) < 0) __PYX_ERR(0, 4518, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":4519
 *         kern_add = _add_scan_blocked_sum_kernel(out.dtype)
 *         kern_add(grid=((a.size - 1) // (2 * block_size),),
 *                  block=(2 * block_size - 1,),             # <<<<<<<<<<<<<<
 *                  args=(out,))
 *     return out
 */
    __pyx_t_2 = PyNumber_Multiply(__pyx_int_2, __pyx_v_block_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyInt_SubtractObjC(__pyx_t_2, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7);
    __pyx_t_7 = 0;
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_block, __pyx_t_2) < 0) __PYX_ERR(0, 4518, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":4520
 *         kern_add(grid=((a.size - 1) // (2 * block_size),),
 *                  block=(2 * block_size - 1,),
 *                  args=(out,))             # <<<<<<<<<<<<<<
 *     return out
 * 
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4520, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_out));
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_args, __pyx_t_2) < 0) __PYX_ERR(0, 4518, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":4518
 *         scan(blocked_sum, blocked_sum)
 *         kern_add = _add_scan_blocked_sum_kernel(out.dtype)
 *         kern_add(grid=((a.size - 1) // (2 * block_size),),             # <<<<<<<<<<<<<<
 *                  block=(2 * block_size - 1,),
 *                  args=(out,))
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_kern_add, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":4514
 *               shared_mem=a.itemsize * block_size * 2)
 * 
 *     if (a.size - 1) // (block_size * 2) > 0:             # <<<<<<<<<<<<<<
 *         blocked_sum = out[block_size * 2 - 1:None:block_size * 2]
 *         scan(blocked_sum, blocked_sum)
 */
  }

  /* "cupy/core/core.pyx":4521
 *                  block=(2 * block_size - 1,),
 *                  args=(out,))
 *     return out             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_out));
  __pyx_r = __pyx_v_out;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":4485
 * 
 * 
 * cpdef ndarray scan(ndarray a, ndarray out=None):             # <<<<<<<<<<<<<<
 *     """Return the prefix sum(scan) of the elements.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core.scan", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_block_size);
  __Pyx_XDECREF(__pyx_v_kern_scan);
  __Pyx_XDECREF(__pyx_v_blocked_sum);
  __Pyx_XDECREF(__pyx_v_kern_add);
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_127scan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_126scan[] = "scan(ndarray a, ndarray out=None) -> ndarray\nReturn the prefix sum(scan) of the elements.\n\n    Args:\n        a (cupy.ndarray): input array.\n        out (cupy.ndarray): Alternative output array in which to place\n         the result. The same size and same type as the input array(a).\n\n    Returns:\n        cupy.ndarray: A new array holding the result is returned.\n\n    ";
static PyObject *__pyx_pw_4cupy_4core_4core_127scan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("scan (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_out,0};
    PyObject* values[2] = {0,0};
    values[1] = (PyObject *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scan") < 0)) __PYX_ERR(0, 4485, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_out = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("scan", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4485, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.scan", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 4485, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 4485, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_126scan(__pyx_self, __pyx_v_a, __pyx_v_out);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_126scan(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_scan __pyx_t_2;
  __Pyx_RefNannySetupContext("scan", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_scan(__pyx_v_a, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.scan", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":4529
 * 
 * @util.memoize(for_each_device=True)
 * def _partition_kernel(dtype):             # <<<<<<<<<<<<<<
 *     name = 'partition_kernel'
 *     merge_kernel = 'partition_merge_kernel'
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_129_partition_kernel(PyObject *__pyx_self, PyObject *__pyx_v_dtype); /*proto*/
static char __pyx_doc_4cupy_4core_4core_128_partition_kernel[] = "_partition_kernel(dtype)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_129_partition_kernel = {"_partition_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_129_partition_kernel, METH_O, __pyx_doc_4cupy_4core_4core_128_partition_kernel};
static PyObject *__pyx_pw_4cupy_4core_4core_129_partition_kernel(PyObject *__pyx_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_partition_kernel (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_128_partition_kernel(__pyx_self, ((PyObject *)__pyx_v_dtype));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4cupy_4core_4core_128_partition_kernel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_merge_kernel = NULL;
  PyObject *__pyx_v_source = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_v_module = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_partition_kernel", 0);
  __Pyx_INCREF(__pyx_v_dtype);

  /* "cupy/core/core.pyx":4530
 * @util.memoize(for_each_device=True)
 * def _partition_kernel(dtype):
 *     name = 'partition_kernel'             # <<<<<<<<<<<<<<
 *     merge_kernel = 'partition_merge_kernel'
 *     dtype = _get_typename(dtype)
 */
  __Pyx_INCREF(__pyx_n_s_partition_kernel_2);
  __pyx_v_name = __pyx_n_s_partition_kernel_2;

  /* "cupy/core/core.pyx":4531
 * def _partition_kernel(dtype):
 *     name = 'partition_kernel'
 *     merge_kernel = 'partition_merge_kernel'             # <<<<<<<<<<<<<<
 *     dtype = _get_typename(dtype)
 *     source = string.Template('''
 */
  __Pyx_INCREF(__pyx_n_s_partition_merge_kernel);
  __pyx_v_merge_kernel = __pyx_n_s_partition_merge_kernel;

  /* "cupy/core/core.pyx":4532
 *     name = 'partition_kernel'
 *     merge_kernel = 'partition_merge_kernel'
 *     dtype = _get_typename(dtype)             # <<<<<<<<<<<<<<
 *     source = string.Template('''
 *     template<typename T>
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_typename(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4533
 *     merge_kernel = 'partition_merge_kernel'
 *     dtype = _get_typename(dtype)
 *     source = string.Template('''             # <<<<<<<<<<<<<<
 *     template<typename T>
 *     __device__ void bitonic_sort_step(CArray<T, 1> a,
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Template); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__173, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":4636
 *     }
 *     }
 *     ''').substitute(name=name, merge_kernel=merge_kernel, dtype=dtype)             # <<<<<<<<<<<<<<
 *     module = compile_with_cache(source)
 *     return module.get_function(name), module.get_function(merge_kernel)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_substitute); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_name) < 0) __PYX_ERR(0, 4636, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_merge_kernel, __pyx_v_merge_kernel) < 0) __PYX_ERR(0, 4636, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 4636, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_source = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4637
 *     }
 *     ''').substitute(name=name, merge_kernel=merge_kernel, dtype=dtype)
 *     module = compile_with_cache(source)             # <<<<<<<<<<<<<<
 *     return module.get_function(name), module.get_function(merge_kernel)
 */
  if (!(likely(PyString_CheckExact(__pyx_v_source))||((__pyx_v_source) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_source)->tp_name), 0))) __PYX_ERR(0, 4637, __pyx_L1_error)
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_compile_with_cache(((PyObject*)__pyx_v_source), 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4637, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_module = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":4638
 *     ''').substitute(name=name, merge_kernel=merge_kernel, dtype=dtype)
 *     module = compile_with_cache(source)
 *     return module.get_function(name), module.get_function(merge_kernel)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_name))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_name)->tp_name), 0))) __PYX_ERR(0, 4638, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *)__pyx_v_module->__pyx_vtab)->get_function(__pyx_v_module, ((PyObject*)__pyx_v_name), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4638, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(PyString_CheckExact(__pyx_v_merge_kernel))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_merge_kernel)->tp_name), 0))) __PYX_ERR(0, 4638, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4cuda_8function_Module *)__pyx_v_module->__pyx_vtab)->get_function(__pyx_v_module, ((PyObject*)__pyx_v_merge_kernel), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4638, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4638, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_3 = 0;
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":4529
 * 
 * @util.memoize(for_each_device=True)
 * def _partition_kernel(dtype):             # <<<<<<<<<<<<<<
 *     name = 'partition_kernel'
 *     merge_kernel = 'partition_merge_kernel'
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.core.core._partition_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_merge_kernel);
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF((PyObject *)__pyx_v_module);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x6d47339:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_131__pyx_unpickle_Indexer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_130__pyx_unpickle_Indexer[] = "__pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_131__pyx_unpickle_Indexer = {"__pyx_unpickle_Indexer", (PyCFunction)__pyx_pw_4cupy_4core_4core_131__pyx_unpickle_Indexer, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_130__pyx_unpickle_Indexer};
static PyObject *__pyx_pw_4cupy_4core_4core_131__pyx_unpickle_Indexer(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;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Indexer (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_Indexer", 1, 3, 3, 1); __PYX_ERR(4, 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_Indexer", 1, 3, 3, 2); __PYX_ERR(4, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Indexer") < 0)) __PYX_ERR(4, 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(4, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Indexer", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_Indexer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_130__pyx_unpickle_Indexer(__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_4cupy_4core_4core_130__pyx_unpickle_Indexer(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 = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Indexer", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x6d47339:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6d47339 = (shape, size))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x6d47339) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x6d47339:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6d47339 = (shape, size))" % __pyx_checksum)
 *     __pyx_result = Indexer.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x6d47339:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6d47339 = (shape, size))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Indexer.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x6d, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x6d47339:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6d47339 = (shape, size))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6d47339 = (shape, size))" % __pyx_checksum)
 *     __pyx_result = Indexer.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6d47339 = (shape, size))" % __pyx_checksum)
 *     __pyx_result = Indexer.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = Indexer.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __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(4, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4cupy_4core_4core___pyx_unpickle_Indexer__set_state(((struct __pyx_obj_4cupy_4core_4core_Indexer *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x6d47339 = (shape, size))" % __pyx_checksum)
 *     __pyx_result = Indexer.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]
 */
  __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_Indexer(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x6d47339:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_Indexer", __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)":9
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_Indexer__set_state(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __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;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Indexer__set_state", 0);

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __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(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->shape);
  __Pyx_DECREF(__pyx_v___pyx_result->shape);
  __pyx_v___pyx_result->shape = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->size = __pyx_t_2;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(4, 11, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(4, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_2 > 2) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __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(4, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_3 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":12
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __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(4, 12, __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(4, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __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);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]
 *     if len(__pyx_state) > 2 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_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_Indexer__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_ParameterInfo(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x73694c8:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_133__pyx_unpickle_ParameterInfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_132__pyx_unpickle_ParameterInfo[] = "__pyx_unpickle_ParameterInfo(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_133__pyx_unpickle_ParameterInfo = {"__pyx_unpickle_ParameterInfo", (PyCFunction)__pyx_pw_4cupy_4core_4core_133__pyx_unpickle_ParameterInfo, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_132__pyx_unpickle_ParameterInfo};
static PyObject *__pyx_pw_4cupy_4core_4core_133__pyx_unpickle_ParameterInfo(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;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_ParameterInfo (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_ParameterInfo", 1, 3, 3, 1); __PYX_ERR(4, 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_ParameterInfo", 1, 3, 3, 2); __PYX_ERR(4, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_ParameterInfo") < 0)) __PYX_ERR(4, 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(4, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ParameterInfo", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_ParameterInfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_132__pyx_unpickle_ParameterInfo(__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_4cupy_4core_4core_132__pyx_unpickle_ParameterInfo(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 = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ParameterInfo", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_ParameterInfo(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x73694c8:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x73694c8) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_ParameterInfo(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x73694c8:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))" % __pyx_checksum)
 *     __pyx_result = ParameterInfo.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x73694c8:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = ParameterInfo.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x73, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_ParameterInfo(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x73694c8:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))" % __pyx_checksum)
 *     __pyx_result = ParameterInfo.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ParameterInfo__set_state(<ParameterInfo> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4cupy_4core_4core_ParameterInfo), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))" % __pyx_checksum)
 *     __pyx_result = ParameterInfo.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ParameterInfo__set_state(<ParameterInfo> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = ParameterInfo.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ParameterInfo__set_state(<ParameterInfo> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_ParameterInfo__set_state(ParameterInfo __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(4, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4cupy_4core_4core___pyx_unpickle_ParameterInfo__set_state(((struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x73694c8 = (ctype, dtype, is_const, name, raw))" % __pyx_checksum)
 *     __pyx_result = ParameterInfo.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ParameterInfo__set_state(<ParameterInfo> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ParameterInfo__set_state(<ParameterInfo> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_ParameterInfo__set_state(ParameterInfo __pyx_result, tuple __pyx_state):
 *     __pyx_result.ctype = __pyx_state[0]; __pyx_result.dtype = __pyx_state[1]; __pyx_result.is_const = __pyx_state[2]; __pyx_result.name = __pyx_state[3]; __pyx_result.raw = __pyx_state[4]
 */
  __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_ParameterInfo(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x73694c8:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_ParameterInfo", __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)":9
 *         __pyx_unpickle_ParameterInfo__set_state(<ParameterInfo> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ParameterInfo__set_state(ParameterInfo __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.ctype = __pyx_state[0]; __pyx_result.dtype = __pyx_state[1]; __pyx_result.is_const = __pyx_state[2]; __pyx_result.name = __pyx_state[3]; __pyx_result.raw = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_ParameterInfo__set_state(struct __pyx_obj_4cupy_4core_4core_ParameterInfo *__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;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ParameterInfo__set_state", 0);

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_ParameterInfo__set_state(ParameterInfo __pyx_result, tuple __pyx_state):
 *     __pyx_result.ctype = __pyx_state[0]; __pyx_result.dtype = __pyx_state[1]; __pyx_result.is_const = __pyx_state[2]; __pyx_result.name = __pyx_state[3]; __pyx_result.raw = __pyx_state[4]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[5])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __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(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->ctype);
  __Pyx_DECREF(__pyx_v___pyx_result->ctype);
  __pyx_v___pyx_result->ctype = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->dtype);
  __Pyx_DECREF(__pyx_v___pyx_result->dtype);
  __pyx_v___pyx_result->dtype = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->is_const = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->name);
  __Pyx_DECREF(__pyx_v___pyx_result->name);
  __pyx_v___pyx_result->name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->raw = __pyx_t_2;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_ParameterInfo__set_state(ParameterInfo __pyx_result, tuple __pyx_state):
 *     __pyx_result.ctype = __pyx_state[0]; __pyx_result.dtype = __pyx_state[1]; __pyx_result.is_const = __pyx_state[2]; __pyx_result.name = __pyx_state[3]; __pyx_result.raw = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[5])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(4, 11, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(4, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 5) != 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(4, 11, __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)":12
 *     __pyx_result.ctype = __pyx_state[0]; __pyx_result.dtype = __pyx_state[1]; __pyx_result.is_const = __pyx_state[2]; __pyx_result.name = __pyx_state[3]; __pyx_result.raw = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[5])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __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(4, 12, __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(4, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __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);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_ParameterInfo__set_state(ParameterInfo __pyx_result, tuple __pyx_state):
 *     __pyx_result.ctype = __pyx_state[0]; __pyx_result.dtype = __pyx_state[1]; __pyx_result.is_const = __pyx_state[2]; __pyx_result.name = __pyx_state[3]; __pyx_result.raw = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[5])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_ParameterInfo__set_state(<ParameterInfo> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ParameterInfo__set_state(ParameterInfo __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.ctype = __pyx_state[0]; __pyx_result.dtype = __pyx_state[1]; __pyx_result.is_const = __pyx_state[2]; __pyx_result.name = __pyx_state[3]; __pyx_result.raw = __pyx_state[4]
 *     if len(__pyx_state) > 5 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_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_ParameterInfo__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_ElementwiseKernel(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x7d8b293:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_135__pyx_unpickle_ElementwiseKernel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_134__pyx_unpickle_ElementwiseKernel[] = "__pyx_unpickle_ElementwiseKernel(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_135__pyx_unpickle_ElementwiseKernel = {"__pyx_unpickle_ElementwiseKernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_135__pyx_unpickle_ElementwiseKernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_134__pyx_unpickle_ElementwiseKernel};
static PyObject *__pyx_pw_4cupy_4core_4core_135__pyx_unpickle_ElementwiseKernel(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;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_ElementwiseKernel (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_ElementwiseKernel", 1, 3, 3, 1); __PYX_ERR(4, 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_ElementwiseKernel", 1, 3, 3, 2); __PYX_ERR(4, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_ElementwiseKernel") < 0)) __PYX_ERR(4, 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(4, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ElementwiseKernel", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_ElementwiseKernel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_134__pyx_unpickle_ElementwiseKernel(__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_4cupy_4core_4core_134__pyx_unpickle_ElementwiseKernel(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 = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ElementwiseKernel", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_ElementwiseKernel(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x7d8b293:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x7d8b293) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_ElementwiseKernel(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x7d8b293:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))" % __pyx_checksum)
 *     __pyx_result = ElementwiseKernel.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x7d8b293:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = ElementwiseKernel.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x7d, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_ElementwiseKernel(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x7d8b293:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))" % __pyx_checksum)
 *     __pyx_result = ElementwiseKernel.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))" % __pyx_checksum)
 *     __pyx_result = ElementwiseKernel.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = ElementwiseKernel.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __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(4, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4cupy_4core_4core___pyx_unpickle_ElementwiseKernel__set_state(((struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x7d8b293 = (in_params, kwargs, name, nargs, nin, nout, operation, out_params, params, preamble, reduce_dims))" % __pyx_checksum)
 *     __pyx_result = ElementwiseKernel.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]
 */
  __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_ElementwiseKernel(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x7d8b293:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_ElementwiseKernel", __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)":9
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_ElementwiseKernel__set_state(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __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;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ElementwiseKernel__set_state", 0);

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[11])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __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(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->in_params);
  __Pyx_DECREF(__pyx_v___pyx_result->in_params);
  __pyx_v___pyx_result->in_params = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->kwargs);
  __Pyx_DECREF(__pyx_v___pyx_result->kwargs);
  __pyx_v___pyx_result->kwargs = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->name);
  __Pyx_DECREF(__pyx_v___pyx_result->name);
  __pyx_v___pyx_result->name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->nargs = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->nin = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->nout = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->operation);
  __Pyx_DECREF(__pyx_v___pyx_result->operation);
  __pyx_v___pyx_result->operation = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->out_params);
  __Pyx_DECREF(__pyx_v___pyx_result->out_params);
  __pyx_v___pyx_result->out_params = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->params);
  __Pyx_DECREF(__pyx_v___pyx_result->params);
  __pyx_v___pyx_result->params = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->preamble);
  __Pyx_DECREF(__pyx_v___pyx_result->preamble);
  __pyx_v___pyx_result->preamble = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 10, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->reduce_dims = __pyx_t_3;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[11])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(4, 11, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(4, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_2 > 11) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __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(4, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_3 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":12
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[11])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __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(4, 12, __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(4, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 11, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __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);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[11])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]
 *     if len(__pyx_state) > 11 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_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_ElementwiseKernel__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_broadcast(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x0537f67:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_137__pyx_unpickle_broadcast(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_136__pyx_unpickle_broadcast[] = "__pyx_unpickle_broadcast(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_4cupy_4core_4core_137__pyx_unpickle_broadcast = {"__pyx_unpickle_broadcast", (PyCFunction)__pyx_pw_4cupy_4core_4core_137__pyx_unpickle_broadcast, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_136__pyx_unpickle_broadcast};
static PyObject *__pyx_pw_4cupy_4core_4core_137__pyx_unpickle_broadcast(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;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_broadcast (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_broadcast", 1, 3, 3, 1); __PYX_ERR(4, 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_broadcast", 1, 3, 3, 2); __PYX_ERR(4, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_broadcast") < 0)) __PYX_ERR(4, 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(4, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_broadcast", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_broadcast", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_136__pyx_unpickle_broadcast(__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_4cupy_4core_4core_136__pyx_unpickle_broadcast(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 = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_broadcast", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_broadcast(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x0537f67:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x0537f67) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_broadcast(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x0537f67:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))" % __pyx_checksum)
 *     __pyx_result = broadcast.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0x0537f67:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = broadcast.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x05, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_broadcast(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0x0537f67:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))" % __pyx_checksum)
 *     __pyx_result = broadcast.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_broadcast__set_state(<broadcast> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))" % __pyx_checksum)
 *     __pyx_result = broadcast.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_broadcast__set_state(<broadcast> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = broadcast.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_broadcast__set_state(<broadcast> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_broadcast__set_state(broadcast __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(4, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4cupy_4core_4core___pyx_unpickle_broadcast__set_state(((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x0537f67 = (nd, shape, size, values))" % __pyx_checksum)
 *     __pyx_result = broadcast.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_broadcast__set_state(<broadcast> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_broadcast__set_state(<broadcast> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_broadcast__set_state(broadcast __pyx_result, tuple __pyx_state):
 *     __pyx_result.nd = __pyx_state[0]; __pyx_result.shape = __pyx_state[1]; __pyx_result.size = __pyx_state[2]; __pyx_result.values = __pyx_state[3]
 */
  __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_broadcast(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x0537f67:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_broadcast", __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)":9
 *         __pyx_unpickle_broadcast__set_state(<broadcast> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_broadcast__set_state(broadcast __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.nd = __pyx_state[0]; __pyx_result.shape = __pyx_state[1]; __pyx_result.size = __pyx_state[2]; __pyx_result.values = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4cupy_4core_4core___pyx_unpickle_broadcast__set_state(struct __pyx_obj_4cupy_4core_4core_broadcast *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __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;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_broadcast__set_state", 0);

  /* "(tree fragment)":10
 *     return __pyx_result
 * cdef __pyx_unpickle_broadcast__set_state(broadcast __pyx_result, tuple __pyx_state):
 *     __pyx_result.nd = __pyx_state[0]; __pyx_result.shape = __pyx_state[1]; __pyx_result.size = __pyx_state[2]; __pyx_result.values = __pyx_state[3]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __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(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->nd = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->shape);
  __Pyx_DECREF(__pyx_v___pyx_result->shape);
  __pyx_v___pyx_result->shape = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->size = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 10, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(4, 10, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->values);
  __Pyx_DECREF(__pyx_v___pyx_result->values);
  __pyx_v___pyx_result->values = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":11
 * cdef __pyx_unpickle_broadcast__set_state(broadcast __pyx_result, tuple __pyx_state):
 *     __pyx_result.nd = __pyx_state[0]; __pyx_result.shape = __pyx_state[1]; __pyx_result.size = __pyx_state[2]; __pyx_result.values = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(4, 11, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(4, 11, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_2 > 4) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __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(4, 11, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_3 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":12
 *     __pyx_result.nd = __pyx_state[0]; __pyx_result.shape = __pyx_state[1]; __pyx_result.size = __pyx_state[2]; __pyx_result.values = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[4])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __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(4, 12, __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(4, 12, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 12, __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);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * cdef __pyx_unpickle_broadcast__set_state(broadcast __pyx_result, tuple __pyx_state):
 *     __pyx_result.nd = __pyx_state[0]; __pyx_result.shape = __pyx_state[1]; __pyx_result.size = __pyx_state[2]; __pyx_result.values = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  }

  /* "(tree fragment)":9
 *         __pyx_unpickle_broadcast__set_state(<broadcast> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_broadcast__set_state(broadcast __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.nd = __pyx_state[0]; __pyx_result.shape = __pyx_state[1]; __pyx_result.size = __pyx_state[2]; __pyx_result.values = __pyx_state[3]
 *     if len(__pyx_state) > 4 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_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.core.core.__pyx_unpickle_broadcast__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "vector.from_py":45
 * 
 * @cname("__pyx_convert_vector_from_py_Py_ssize_t")
 * cdef vector[X] __pyx_convert_vector_from_py_Py_ssize_t(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef vector[X] v
 *     for item in o:
 */

static std::vector<Py_ssize_t>  __pyx_convert_vector_from_py_Py_ssize_t(PyObject *__pyx_v_o) {
  std::vector<Py_ssize_t>  __pyx_v_v;
  PyObject *__pyx_v_item = NULL;
  std::vector<Py_ssize_t>  __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  __Pyx_RefNannySetupContext("__pyx_convert_vector_from_py_Py_ssize_t", 0);

  /* "vector.from_py":47
 * cdef vector[X] __pyx_convert_vector_from_py_Py_ssize_t(object o) except *:
 *     cdef vector[X] v
 *     for item in o:             # <<<<<<<<<<<<<<
 *         v.push_back(<X>item)
 *     return v
 */
  if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) {
    __pyx_t_1 = __pyx_v_o; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 47, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 47, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(4, 47, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 47, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(4, 47, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 47, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(4, 47, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "vector.from_py":48
 *     cdef vector[X] v
 *     for item in o:
 *         v.push_back(<X>item)             # <<<<<<<<<<<<<<
 *     return v
 * 
 */
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_item); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 48, __pyx_L1_error)
    __pyx_v_v.push_back(((Py_ssize_t)__pyx_t_5));

    /* "vector.from_py":47
 * cdef vector[X] __pyx_convert_vector_from_py_Py_ssize_t(object o) except *:
 *     cdef vector[X] v
 *     for item in o:             # <<<<<<<<<<<<<<
 *         v.push_back(<X>item)
 *     return v
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "vector.from_py":49
 *     for item in o:
 *         v.push_back(<X>item)
 *     return v             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_v;
  goto __pyx_L0;

  /* "vector.from_py":45
 * 
 * @cname("__pyx_convert_vector_from_py_Py_ssize_t")
 * cdef vector[X] __pyx_convert_vector_from_py_Py_ssize_t(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef vector[X] v
 *     for item in o:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("vector.from_py.__pyx_convert_vector_from_py_Py_ssize_t", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static std::vector<size_t>  __pyx_convert_vector_from_py_size_t(PyObject *__pyx_v_o) {
  std::vector<size_t>  __pyx_v_v;
  PyObject *__pyx_v_item = NULL;
  std::vector<size_t>  __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  __Pyx_RefNannySetupContext("__pyx_convert_vector_from_py_size_t", 0);

  /* "vector.from_py":47
 * cdef vector[X] __pyx_convert_vector_from_py_size_t(object o) except *:
 *     cdef vector[X] v
 *     for item in o:             # <<<<<<<<<<<<<<
 *         v.push_back(<X>item)
 *     return v
 */
  if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) {
    __pyx_t_1 = __pyx_v_o; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 47, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 47, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(4, 47, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 47, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(4, 47, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 47, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(4, 47, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "vector.from_py":48
 *     cdef vector[X] v
 *     for item in o:
 *         v.push_back(<X>item)             # <<<<<<<<<<<<<<
 *     return v
 * 
 */
    __pyx_t_5 = __Pyx_PyInt_As_size_t(__pyx_v_item); if (unlikely((__pyx_t_5 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 48, __pyx_L1_error)
    __pyx_v_v.push_back(((size_t)__pyx_t_5));

    /* "vector.from_py":47
 * cdef vector[X] __pyx_convert_vector_from_py_size_t(object o) except *:
 *     cdef vector[X] v
 *     for item in o:             # <<<<<<<<<<<<<<
 *         v.push_back(<X>item)
 *     return v
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "vector.from_py":49
 *     for item in o:
 *         v.push_back(<X>item)
 *     return v             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_v;
  goto __pyx_L0;

  /* "vector.from_py":45
 * 
 * @cname("__pyx_convert_vector_from_py_size_t")
 * cdef vector[X] __pyx_convert_vector_from_py_size_t(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef vector[X] v
 *     for item in o:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("vector.from_py.__pyx_convert_vector_from_py_size_t", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "vector.to_py":60
 * 
 * @cname("__pyx_convert_vector_to_py_Py_ssize_t")
 * cdef object __pyx_convert_vector_to_py_Py_ssize_t(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [v[i] for i in range(v.size())]
 * 
 */

static PyObject *__pyx_convert_vector_to_py_Py_ssize_t(const std::vector<Py_ssize_t>  &__pyx_v_v) {
  size_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__pyx_convert_vector_to_py_Py_ssize_t", 0);

  /* "vector.to_py":61
 * @cname("__pyx_convert_vector_to_py_Py_ssize_t")
 * cdef object __pyx_convert_vector_to_py_Py_ssize_t(vector[X]& v):
 *     return [v[i] for i in range(v.size())]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_v_v.size();
  __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;
    __pyx_t_5 = PyInt_FromSsize_t((__pyx_v_v[__pyx_v_i])); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(4, 61, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "vector.to_py":60
 * 
 * @cname("__pyx_convert_vector_to_py_Py_ssize_t")
 * cdef object __pyx_convert_vector_to_py_Py_ssize_t(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [v[i] for i in range(v.size())]
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("vector.to_py.__pyx_convert_vector_to_py_Py_ssize_t", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_convert_vector_to_py_size_t(const std::vector<size_t>  &__pyx_v_v) {
  size_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__pyx_convert_vector_to_py_size_t", 0);

  /* "vector.to_py":61
 * @cname("__pyx_convert_vector_to_py_size_t")
 * cdef object __pyx_convert_vector_to_py_size_t(vector[X]& v):
 *     return [v[i] for i in range(v.size())]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_v_v.size();
  __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;
    __pyx_t_5 = __Pyx_PyInt_FromSize_t((__pyx_v_v[__pyx_v_i])); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(4, 61, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "vector.to_py":60
 * 
 * @cname("__pyx_convert_vector_to_py_size_t")
 * cdef object __pyx_convert_vector_to_py_size_t(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [v[i] for i in range(v.size())]
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("vector.to_py.__pyx_convert_vector_to_py_size_t", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":121
 *         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_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(4, 121, __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(4, 121, __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(4, 121, __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(4, 121, __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(4, 122, __pyx_L3_error)
    } else {

      /* "View.MemoryView":122
 * 
 *     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(4, 121, __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(4, 121, __pyx_L1_error)
  if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) {
    PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(4, 121, __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":121
 *         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;
  char *__pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  Py_ssize_t __pyx_t_11;
  __Pyx_RefNannySetupContext("__cinit__", 0);
  __Pyx_INCREF(__pyx_v_format);

  /* "View.MemoryView":128
 *         cdef PyObject **p
 * 
 *         self.ndim = <int> 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(4, 128, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(4, 128, __pyx_L1_error)
  __pyx_v_self->ndim = ((int)__pyx_t_1);

  /* "View.MemoryView":129
 * 
 *         self.ndim = <int> len(shape)
 *         self.itemsize = itemsize             # <<<<<<<<<<<<<<
 * 
 *         if not self.ndim:
 */
  __pyx_v_self->itemsize = __pyx_v_itemsize;

  /* "View.MemoryView":131
 *         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":132
 * 
 *         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__174, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 132, __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(4, 132, __pyx_L1_error)

    /* "View.MemoryView":131
 *         self.itemsize = itemsize
 * 
 *         if not self.ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError("Empty shape tuple for cython.array")
 * 
 */
  }

  /* "View.MemoryView":134
 *             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":135
 * 
 *         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__175, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 135, __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(4, 135, __pyx_L1_error)

    /* "View.MemoryView":134
 *             raise ValueError("Empty shape tuple for cython.array")
 * 
 *         if itemsize <= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("itemsize <= 0 for cython.array")
 * 
 */
  }

  /* "View.MemoryView":137
 *             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":138
 * 
 *         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_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__176, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "View.MemoryView":137
 *             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":139
 *         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(4, 139, __pyx_L1_error)
  __pyx_t_5 = __pyx_v_format;
  __Pyx_INCREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_GOTREF(__pyx_v_self->_format);
  __Pyx_DECREF(__pyx_v_self->_format);
  __pyx_v_self->_format = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "View.MemoryView":140
 *             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(4, 140, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->_format); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(4, 140, __pyx_L1_error)
  __pyx_v_self->format = __pyx_t_6;

  /* "View.MemoryView":143
 * 
 * 
 *         self._shape = <Py_ssize_t *> 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":144
 * 
 *         self._shape = <Py_ssize_t *> 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":146
 *         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":147
 * 
 *         if not self._shape:
 *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__177, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 147, __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(4, 147, __pyx_L1_error)

    /* "View.MemoryView":146
 *         self._strides = self._shape + self.ndim
 * 
 *         if not self._shape:             # <<<<<<<<<<<<<<
 *             raise MemoryError("unable to allocate shape and strides.")
 * 
 */
  }

  /* "View.MemoryView":150
 * 
 * 
 *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
 *             if dim <= 0:
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 */
  __pyx_t_7 = 0;
  __pyx_t_5 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(4, 150, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 150, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(4, 150, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_dim = __pyx_t_8;
    __pyx_v_idx = __pyx_t_7;
    __pyx_t_7 = (__pyx_t_7 + 1);

    /* "View.MemoryView":151
 * 
 *         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":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_3 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
      __pyx_t_3 = 0;
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __PYX_ERR(4, 152, __pyx_L1_error)

      /* "View.MemoryView":151
 * 
 *         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":153
 *             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":150
 * 
 * 
 *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
 *             if dim <= 0:
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "View.MemoryView":156
 * 
 *         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(4, 156, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "View.MemoryView":157
 *         cdef char order
 *         if mode == 'fortran':
 *             order = b'F'             # <<<<<<<<<<<<<<
 *             self.mode = u'fortran'
 *         elif mode == 'c':
 */
    __pyx_v_order = 'F';

    /* "View.MemoryView":158
 *         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":156
 * 
 *         cdef char order
 *         if mode == 'fortran':             # <<<<<<<<<<<<<<
 *             order = b'F'
 *             self.mode = u'fortran'
 */
    goto __pyx_L10;
  }

  /* "View.MemoryView":159
 *             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(4, 159, __pyx_L1_error)
  if (likely(__pyx_t_4)) {

    /* "View.MemoryView":160
 *             self.mode = u'fortran'
 *         elif mode == 'c':
 *             order = b'C'             # <<<<<<<<<<<<<<
 *             self.mode = u'c'
 *         else:
 */
    __pyx_v_order = 'C';

    /* "View.MemoryView":161
 *         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":159
 *             order = b'F'
 *             self.mode = u'fortran'
 *         elif mode == 'c':             # <<<<<<<<<<<<<<
 *             order = b'C'
 *             self.mode = u'c'
 */
    goto __pyx_L10;
  }

  /* "View.MemoryView":163
 *             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_5 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_v_mode); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 163, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 163, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_10, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __PYX_ERR(4, 163, __pyx_L1_error)
  }
  __pyx_L10:;

  /* "View.MemoryView":165
 *             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":168
 *                                              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":169
 * 
 *         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(4, 169, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 169, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_v_self->dtype_is_object = __pyx_t_4;

  /* "View.MemoryView":170
 *         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":173
 * 
 * 
 *             self.data = <char *>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":174
 * 
 *             self.data = <char *>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":175
 *             self.data = <char *>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__178, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(4, 175, __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(4, 175, __pyx_L1_error)

      /* "View.MemoryView":174
 * 
 *             self.data = <char *>malloc(self.len)
 *             if not self.data:             # <<<<<<<<<<<<<<
 *                 raise MemoryError("unable to allocate array data.")
 * 
 */
    }

    /* "View.MemoryView":177
 *                 raise MemoryError("unable to allocate array data.")
 * 
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 p = <PyObject **> 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":178
 * 
 *             if self.dtype_is_object:
 *                 p = <PyObject **> self.data             # <<<<<<<<<<<<<<
 *                 for i in range(self.len / itemsize):
 *                     p[i] = Py_None
 */
      __pyx_v_p = ((PyObject **)__pyx_v_self->data);

      /* "View.MemoryView":179
 *             if self.dtype_is_object:
 *                 p = <PyObject **> 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(4, 179, __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(4, 179, __pyx_L1_error)
      }
      __pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize);
      __pyx_t_8 = __pyx_t_1;
      for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_8; __pyx_t_11+=1) {
        __pyx_v_i = __pyx_t_11;

        /* "View.MemoryView":180
 *                 p = <PyObject **> 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":181
 *                 for i in range(self.len / itemsize):
 *                     p[i] = Py_None
 *                     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
 * 
 *     @cname('getbuffer')
 */
        Py_INCREF(Py_None);
      }

      /* "View.MemoryView":177
 *                 raise MemoryError("unable to allocate array data.")
 * 
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 p = <PyObject **> self.data
 *                 for i in range(self.len / itemsize):
 */
    }

    /* "View.MemoryView":170
 *         self.free_data = allocate_buffer
 *         self.dtype_is_object = format == b'O'
 *         if allocate_buffer:             # <<<<<<<<<<<<<<
 * 
 * 
 */
  }

  /* "View.MemoryView":121
 *         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_9);
  __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":184
 * 
 *     @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;
  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":185
 *     @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":186
 *     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(4, 186, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":187
 *         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":186
 *     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":188
 *         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(4, 188, __pyx_L1_error)
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":189
 *             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":188
 *         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":190
 *         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":191
 *             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__179, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 191, __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(4, 191, __pyx_L1_error)

    /* "View.MemoryView":190
 *         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":192
 *         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":193
 *             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":194
 *         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":195
 *         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":196
 *         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":197
 *         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":198
 *         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":199
 *         info.suboffsets = NULL
 *         info.itemsize = self.itemsize
 *         info.readonly = 0             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_FORMAT:
 */
  __pyx_v_info->readonly = 0;

  /* "View.MemoryView":201
 *         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":202
 * 
 *         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":201
 *         info.readonly = 0
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             info.format = self.format
 *         else:
 */
    goto __pyx_L5;
  }

  /* "View.MemoryView":204
 *             info.format = self.format
 *         else:
 *             info.format = NULL             # <<<<<<<<<<<<<<
 * 
 *         info.obj = self
 */
  /*else*/ {
    __pyx_v_info->format = NULL;
  }
  __pyx_L5:;

  /* "View.MemoryView":206
 *             info.format = NULL
 * 
 *         info.obj = self             # <<<<<<<<<<<<<<
 * 
 *     __pyx_getbuffer = capsule(<void *> &__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":184
 * 
 *     @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":210
 *     __pyx_getbuffer = capsule(<void *> &__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":211
 * 
 *     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":212
 *     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":211
 * 
 *     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":213
 *         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":214
 *             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":215
 *         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":214
 *             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":217
 *                 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":213
 *         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":218
 *                                           self._strides, self.ndim, False)
 *             free(self.data)
 *         PyObject_Free(self._shape)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  PyObject_Free(__pyx_v_self->_shape);

  /* "View.MemoryView":210
 *     __pyx_getbuffer = capsule(<void *> &__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":221
 * 
 *     @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;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":222
 *     @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(4, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":221
 * 
 *     @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":225
 * 
 *     @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;
  __Pyx_RefNannySetupContext("get_memview", 0);

  /* "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)
 * 
 */
  __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE);

  /* "View.MemoryView":227
 *     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(4, 227, __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(4, 227, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 227, __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(4, 227, __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":225
 * 
 *     @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":229
 *         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":230
 * 
 *     def __len__(self):
 *         return self._shape[0]             # <<<<<<<<<<<<<<
 * 
 *     def __getattr__(self, attr):
 */
  __pyx_r = (__pyx_v_self->_shape[0]);
  goto __pyx_L0;

  /* "View.MemoryView":229
 *         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":232
 *         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;
  __Pyx_RefNannySetupContext("__getattr__", 0);

  /* "View.MemoryView":233
 * 
 *     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(4, 233, __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(4, 233, __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":232
 *         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":235
 *         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;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "View.MemoryView":236
 * 
 *     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(4, 236, __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(4, 236, __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":235
 *         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":238
 *         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;
  __Pyx_RefNannySetupContext("__setitem__", 0);

  /* "View.MemoryView":239
 * 
 *     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(4, 239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(4, 239, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "View.MemoryView":238
 *         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;
  __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__180, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 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(4, 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;
  __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__181, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 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(4, 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":243
 * 
 * @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;
  __Pyx_RefNannySetupContext("array_cwrapper", 0);

  /* "View.MemoryView":247
 *     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":248
 * 
 *     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(4, 248, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 248, __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(4, 248, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 248, __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(4, 248, __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":247
 *     cdef array result
 * 
 *     if buf == NULL:             # <<<<<<<<<<<<<<
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))
 *     else:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":250
 *         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(4, 250, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 250, __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(4, 250, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 250, __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":251
 *     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(4, 251, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(4, 251, __pyx_L1_error)

    /* "View.MemoryView":250
 *         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(4, 250, __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":252
 *         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":254
 *         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":243
 * 
 * @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":280
 * 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_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(4, 280, __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(4, 280, __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":281
 *     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":280
 * 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":282
 *     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":283
 *         self.name = name
 *     def __repr__(self):
 *         return self.name             # <<<<<<<<<<<<<<
 * 
 * cdef generic = Enum("<strided and direct or indirect>")
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->name);
  __pyx_r = __pyx_v_self->name;
  goto __pyx_L0;

  /* "View.MemoryView":282
 *     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 bint use_setstate
 *     state = (self.name,)
 */

/* 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) {
  int __pyx_v_use_setstate;
  PyObject *__pyx_v_state = NULL;
  PyObject *__pyx_v__dict = NULL;
  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;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     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(4, 3, __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)":4
 *     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(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":5
 *     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)":6
 *     _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(4, 6, __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(4, 6, __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)":7
 *     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)":5
 *     state = (self.name,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":9
 *         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)":10
 *     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)":11
 *         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_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 11, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 11, __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(4, 11, __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)":10
 *     else:
 *         use_setstate = self.name is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
 *     else:
 */
  }

  /* "(tree fragment)":13
 *         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_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 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(__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(4, 13, __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 bint use_setstate
 *     state = (self.name,)
 */

  /* 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)":14
 *     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;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":15
 *         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(4, 15, __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(4, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":14
 *     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":297
 * 
 * @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 = <Py_intptr_t> 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":299
 * cdef void *align_pointer(void *memory, size_t alignment) nogil:
 *     "Align pointer memory on a given boundary"
 *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory             # <<<<<<<<<<<<<<
 *     cdef size_t offset
 * 
 */
  __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory);

  /* "View.MemoryView":303
 * 
 *     with cython.cdivision(True):
 *         offset = aligned_p % alignment             # <<<<<<<<<<<<<<
 * 
 *     if offset > 0:
 */
  __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment);

  /* "View.MemoryView":305
 *         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":306
 * 
 *     if offset > 0:
 *         aligned_p += alignment - offset             # <<<<<<<<<<<<<<
 * 
 *     return <void *> aligned_p
 */
    __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset));

    /* "View.MemoryView":305
 *         offset = aligned_p % alignment
 * 
 *     if offset > 0:             # <<<<<<<<<<<<<<
 *         aligned_p += alignment - offset
 * 
 */
  }

  /* "View.MemoryView":308
 *         aligned_p += alignment - offset
 * 
 *     return <void *> aligned_p             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = ((void *)__pyx_v_aligned_p);
  goto __pyx_L0;

  /* "View.MemoryView":297
 * 
 * @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 = <Py_intptr_t> memory
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":344
 *     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_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(4, 344, __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(4, 344, __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(4, 344, __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(4, 344, __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(4, 344, __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;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "View.MemoryView":345
 * 
 *     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":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_GetBuffer(obj, &self.view, flags)
 */
  __pyx_v_self->flags = __pyx_v_flags;

  /* "View.MemoryView":347
 *         self.obj = obj
 *         self.flags = flags
 *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> 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":348
 *         self.flags = flags
 *         if type(self) is memoryview or obj is not None:
 *             __Pyx_GetBuffer(obj, &self.view, flags)             # <<<<<<<<<<<<<<
 *             if <PyObject *> 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(4, 348, __pyx_L1_error)

    /* "View.MemoryView":349
 *         if type(self) is memoryview or obj is not None:
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> 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":350
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> 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":351
 *             if <PyObject *> 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":349
 *         if type(self) is memoryview or obj is not None:
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
 *                 (<__pyx_buffer *> &self.view).obj = Py_None
 *                 Py_INCREF(Py_None)
 */
    }

    /* "View.MemoryView":347
 *         self.obj = obj
 *         self.flags = flags
 *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:
 */
  }

  /* "View.MemoryView":354
 * 
 *         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":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
 *         if self.lock is NULL:
 */
    __pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);

    /* "View.MemoryView":356
 *         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":354
 * 
 *         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":357
 *             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":358
 *             __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":359
 *         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":360
 *             self.lock = PyThread_allocate_lock()
 *             if self.lock is NULL:
 *                 raise MemoryError             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_FORMAT:
 */
      PyErr_NoMemory(); __PYX_ERR(4, 360, __pyx_L1_error)

      /* "View.MemoryView":359
 *         if self.lock is NULL:
 *             self.lock = PyThread_allocate_lock()
 *             if self.lock is NULL:             # <<<<<<<<<<<<<<
 *                 raise MemoryError
 * 
 */
    }

    /* "View.MemoryView":357
 *             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":362
 *                 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":363
 * 
 *         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":362
 *                 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":365
 *             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":367
 *             self.dtype_is_object = dtype_is_object
 * 
 *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(             # <<<<<<<<<<<<<<
 *                   <void *> &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":369
 *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
 *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
 *         self.typeinfo = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(memoryview self):
 */
  __pyx_v_self->typeinfo = NULL;

  /* "View.MemoryView":344
 *     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":371
 *         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":372
 * 
 *     def __dealloc__(memoryview self):
 *         if self.obj is not None:             # <<<<<<<<<<<<<<
 *             __Pyx_ReleaseBuffer(&self.view)
 * 
 */
  __pyx_t_1 = (__pyx_v_self->obj != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":373
 *     def __dealloc__(memoryview self):
 *         if self.obj is not None:
 *             __Pyx_ReleaseBuffer(&self.view)             # <<<<<<<<<<<<<<
 * 
 *         cdef int i
 */
    __Pyx_ReleaseBuffer((&__pyx_v_self->view));

    /* "View.MemoryView":372
 * 
 *     def __dealloc__(memoryview self):
 *         if self.obj is not None:             # <<<<<<<<<<<<<<
 *             __Pyx_ReleaseBuffer(&self.view)
 * 
 */
  }

  /* "View.MemoryView":377
 *         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":378
 *         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":379
 *         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":380
 *             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":381
 *                 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":383
 *                     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":382
 *                     __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":381
 *                 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":384
 *                         __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":379
 *         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":386
 *                     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":377
 *         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":371
 *         self.typeinfo = NULL
 * 
 *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
 *         if self.obj is not None:
 *             __Pyx_ReleaseBuffer(&self.view)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":388
 *                 PyThread_free_lock(self.lock)
 * 
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t dim
 *         cdef char *itemp = <char *> 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;
  __Pyx_RefNannySetupContext("get_item_pointer", 0);

  /* "View.MemoryView":390
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
 *         cdef Py_ssize_t dim
 *         cdef char *itemp = <char *> self.view.buf             # <<<<<<<<<<<<<<
 * 
 *         for dim, idx in enumerate(index):
 */
  __pyx_v_itemp = ((char *)__pyx_v_self->view.buf);

  /* "View.MemoryView":392
 *         cdef char *itemp = <char *> 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(4, 392, __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(4, 392, __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(4, 392, __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(4, 392, __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(4, 392, __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(4, 392, __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(4, 392, __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":393
 * 
 *         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(4, 393, __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(4, 393, __pyx_L1_error)
    __pyx_v_itemp = __pyx_t_7;

    /* "View.MemoryView":392
 *         cdef char *itemp = <char *> 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":395
 *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
 * 
 *         return itemp             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_itemp;
  goto __pyx_L0;

  /* "View.MemoryView":388
 *                 PyThread_free_lock(self.lock)
 * 
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t dim
 *         cdef char *itemp = <char *> 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":398
 * 
 * 
 *     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;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "View.MemoryView":399
 * 
 *     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":400
 *     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":399
 * 
 *     def __getitem__(memoryview self, object index):
 *         if index is Ellipsis:             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  }

  /* "View.MemoryView":402
 *             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(4, 402, __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(4, 402, __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(4, 402, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 402, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(4, 402, __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":405
 * 
 *         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(4, 405, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "View.MemoryView":406
 *         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(4, 406, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "View.MemoryView":405
 * 
 *         cdef char *itemp
 *         if have_slices:             # <<<<<<<<<<<<<<
 *             return memview_slice(self, indices)
 *         else:
 */
  }

  /* "View.MemoryView":408
 *             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(4, 408, __pyx_L1_error)
    __pyx_v_itemp = __pyx_t_6;

    /* "View.MemoryView":409
 *         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(4, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "View.MemoryView":398
 * 
 * 
 *     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":411
 *             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;
  __Pyx_RefNannySetupContext("__setitem__", 0);
  __Pyx_INCREF(__pyx_v_index);

  /* "View.MemoryView":412
 * 
 *     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":413
 *     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__182, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 413, __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(4, 413, __pyx_L1_error)

    /* "View.MemoryView":412
 * 
 *     def __setitem__(memoryview self, object index, object value):
 *         if self.view.readonly:             # <<<<<<<<<<<<<<
 *             raise TypeError("Cannot assign to read-only memoryview")
 * 
 */
  }

  /* "View.MemoryView":415
 *             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(4, 415, __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(4, 415, __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(4, 415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(4, 415, __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":417
 *         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(4, 417, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "View.MemoryView":418
 * 
 *         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(4, 418, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_obj = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "View.MemoryView":419
 *         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(4, 419, __pyx_L1_error)
    if (__pyx_t_1) {

      /* "View.MemoryView":420
 *             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(4, 420, __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(4, 420, __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":419
 *         if have_slices:
 *             obj = self.is_slice(value)
 *             if obj:             # <<<<<<<<<<<<<<
 *                 self.setitem_slice_assignment(self[index], obj)
 *             else:
 */
      goto __pyx_L5;
    }

    /* "View.MemoryView":422
 *                 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(4, 422, __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(4, 422, __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(4, 422, __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":417
 *         have_slices, index = _unellipsify(index, self.view.ndim)
 * 
 *         if have_slices:             # <<<<<<<<<<<<<<
 *             obj = self.is_slice(value)
 *             if obj:
 */
    goto __pyx_L4;
  }

  /* "View.MemoryView":424
 *                 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(4, 424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L4:;

  /* "View.MemoryView":411
 *             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":426
 *             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;
  __Pyx_RefNannySetupContext("is_slice", 0);
  __Pyx_INCREF(__pyx_v_obj);

  /* "View.MemoryView":427
 * 
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
 *             try:
 *                 obj = memoryview(obj, self.flags|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":428
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):
 *             try:             # <<<<<<<<<<<<<<
 *                 obj = memoryview(obj, self.flags|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":429
 *         if not isinstance(obj, memoryview):
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
 *                                  self.dtype_is_object)
 *             except TypeError:
 */
        __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_self->flags | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 429, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);

        /* "View.MemoryView":430
 *             try:
 *                 obj = memoryview(obj, self.flags|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(4, 430, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);

        /* "View.MemoryView":429
 *         if not isinstance(obj, memoryview):
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
 *                                  self.dtype_is_object)
 *             except TypeError:
 */
        __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 429, __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(4, 429, __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":428
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):
 *             try:             # <<<<<<<<<<<<<<
 *                 obj = memoryview(obj, self.flags|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_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "View.MemoryView":431
 *                 obj = memoryview(obj, self.flags|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(4, 431, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GOTREF(__pyx_t_6);

        /* "View.MemoryView":432
 *                                  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":428
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):
 *             try:             # <<<<<<<<<<<<<<
 *                 obj = memoryview(obj, self.flags|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":427
 * 
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 */
  }

  /* "View.MemoryView":434
 *                 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":426
 *             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":436
 *         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
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("setitem_slice_assignment", 0);

  /* "View.MemoryView":440
 *         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(4, 440, __pyx_L1_error)

  /* "View.MemoryView":441
 * 
 *         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(4, 441, __pyx_L1_error)

  /* "View.MemoryView":442
 *         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_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 442, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(4, 442, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "View.MemoryView":440
 *         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_4 = __pyx_memoryview_copy_contents((__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_src), (&__pyx_v_src_slice))[0]), (__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_dst), (&__pyx_v_dst_slice))[0]), __pyx_t_2, __pyx_t_3, __pyx_v_self->dtype_is_object); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(4, 440, __pyx_L1_error)

  /* "View.MemoryView":436
 *         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_1);
  __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":444
 *                                  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
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  char const *__pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  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;
  __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0);

  /* "View.MemoryView":446
 *     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":451
 *         cdef __Pyx_memviewslice *dst_slice
 *         cdef __Pyx_memviewslice tmp_slice
 *         dst_slice = get_slice_from_memview(dst, &tmp_slice)             # <<<<<<<<<<<<<<
 * 
 *         if <size_t>self.view.itemsize > sizeof(array):
 */
  __pyx_v_dst_slice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_dst, (&__pyx_v_tmp_slice));

  /* "View.MemoryView":453
 *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
 * 
 *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:
 */
  __pyx_t_1 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":454
 * 
 *         if <size_t>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":455
 *         if <size_t>self.view.itemsize > sizeof(array):
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:             # <<<<<<<<<<<<<<
 *                 raise MemoryError
 *             item = tmp
 */
    __pyx_t_1 = ((__pyx_v_tmp == NULL) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "View.MemoryView":456
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:
 *                 raise MemoryError             # <<<<<<<<<<<<<<
 *             item = tmp
 *         else:
 */
      PyErr_NoMemory(); __PYX_ERR(4, 456, __pyx_L1_error)

      /* "View.MemoryView":455
 *         if <size_t>self.view.itemsize > sizeof(array):
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:             # <<<<<<<<<<<<<<
 *                 raise MemoryError
 *             item = tmp
 */
    }

    /* "View.MemoryView":457
 *             if tmp == NULL:
 *                 raise MemoryError
 *             item = tmp             # <<<<<<<<<<<<<<
 *         else:
 *             item = <void *> array
 */
    __pyx_v_item = __pyx_v_tmp;

    /* "View.MemoryView":453
 *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
 * 
 *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":459
 *             item = tmp
 *         else:
 *             item = <void *> array             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  /*else*/ {
    __pyx_v_item = ((void *)__pyx_v_array);
  }
  __pyx_L3:;

  /* "View.MemoryView":461
 *             item = <void *> array
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if self.dtype_is_object:
 *                 (<PyObject **> item)[0] = <PyObject *> value
 */
  /*try:*/ {

    /* "View.MemoryView":462
 * 
 *         try:
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 (<PyObject **> item)[0] = <PyObject *> value
 *             else:
 */
    __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":463
 *         try:
 *             if self.dtype_is_object:
 *                 (<PyObject **> item)[0] = <PyObject *> value             # <<<<<<<<<<<<<<
 *             else:
 *                 self.assign_item_from_object(<char *> item, value)
 */
      (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value);

      /* "View.MemoryView":462
 * 
 *         try:
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 (<PyObject **> item)[0] = <PyObject *> value
 *             else:
 */
      goto __pyx_L8;
    }

    /* "View.MemoryView":465
 *                 (<PyObject **> item)[0] = <PyObject *> value
 *             else:
 *                 self.assign_item_from_object(<char *> item, value)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    /*else*/ {
      __pyx_t_2 = ((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_2)) __PYX_ERR(4, 465, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __pyx_L8:;

    /* "View.MemoryView":469
 * 
 * 
 *             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_1 = ((__pyx_v_self->view.suboffsets != NULL) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":470
 * 
 *             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_2 = assert_direct_dimensions(__pyx_v_self->view.suboffsets, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 470, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "View.MemoryView":469
 * 
 * 
 *             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":471
 *             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":474
 *                                 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_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_6);
      __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_t_3 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_5 = __pyx_filename;
      {
        PyMem_Free(__pyx_v_tmp);
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_5;
      goto __pyx_L1_error;
    }
    __pyx_L7:;
  }

  /* "View.MemoryView":444
 *                                  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_2);
  __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":476
 *             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;
  __Pyx_RefNannySetupContext("setitem_indexed", 0);

  /* "View.MemoryView":477
 * 
 *     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(4, 477, __pyx_L1_error)
  __pyx_v_itemp = __pyx_t_1;

  /* "View.MemoryView":478
 *     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(4, 478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "View.MemoryView":476
 *             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":480
 *         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;
  __Pyx_RefNannySetupContext("convert_item_to_object", 0);

  /* "View.MemoryView":483
 *         """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(4, 483, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_struct = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "View.MemoryView":486
 *         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(4, 486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_bytesitem = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":487
 * 
 *         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":488
 *         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(4, 488, __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(4, 488, __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(4, 488, __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(4, 488, __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(4, 488, __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(4, 488, __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":487
 * 
 *         bytesitem = itemp[:self.view.itemsize]
 *         try:             # <<<<<<<<<<<<<<
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:
 */
    }

    /* "View.MemoryView":492
 *             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":493
 *         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(4, 493, __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":492
 *             raise ValueError("Unable to convert item to object")
 *         else:
 *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
 *                 return result[0]
 *             return result
 */
      }

      /* "View.MemoryView":494
 *             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_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "View.MemoryView":489
 *         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(4, 489, __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(4, 489, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_1);

      /* "View.MemoryView":490
 *             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__183, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 490, __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(4, 490, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "View.MemoryView":487
 * 
 *         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":480
 *         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":496
 *             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;
  __Pyx_RefNannySetupContext("assign_item_from_object", 0);

  /* "View.MemoryView":499
 *         """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(4, 499, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_struct = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "View.MemoryView":504
 *         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":505
 * 
 *         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(4, 505, __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(4, 505, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 505, __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(4, 505, __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(4, 505, __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(4, 505, __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(4, 505, __pyx_L1_error)
    __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "View.MemoryView":504
 *         cdef Py_ssize_t i
 * 
 *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
 *             bytesvalue = struct.pack(self.view.format, *value)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":507
 *             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(4, 507, __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(4, 507, __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(4, 507, __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(4, 507, __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(4, 507, __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(4, 507, __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(4, 507, __pyx_L1_error)
    __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "View.MemoryView":509
 *             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(4, 509, __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":510
 * 
 *         for i, c in enumerate(bytesvalue):
 *             itemp[i] = c             # <<<<<<<<<<<<<<
 * 
 *     @cname('getbuffer')
 */
    __pyx_v_i = __pyx_t_9;

    /* "View.MemoryView":509
 *             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":510
 * 
 *         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":496
 *             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":513
 * 
 *     @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;
  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":514
 *     @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":515
 *     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_STRIDES:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__184, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 515, __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(4, 515, __pyx_L1_error)

    /* "View.MemoryView":514
 *     @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":517
 *             raise ValueError("Cannot create writable memory view from read-only memoryview")
 * 
 *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
 *             info.shape = self.view.shape
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":518
 * 
 *         if flags & PyBUF_STRIDES:
 *             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":517
 *             raise ValueError("Cannot create writable memory view from read-only memoryview")
 * 
 *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
 *             info.shape = self.view.shape
 *         else:
 */
    goto __pyx_L6;
  }

  /* "View.MemoryView":520
 *             info.shape = self.view.shape
 *         else:
 *             info.shape = NULL             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_STRIDES:
 */
  /*else*/ {
    __pyx_v_info->shape = NULL;
  }
  __pyx_L6:;

  /* "View.MemoryView":522
 *             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":523
 * 
 *         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":522
 *             info.shape = NULL
 * 
 *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
 *             info.strides = self.view.strides
 *         else:
 */
    goto __pyx_L7;
  }

  /* "View.MemoryView":525
 *             info.strides = self.view.strides
 *         else:
 *             info.strides = NULL             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_INDIRECT:
 */
  /*else*/ {
    __pyx_v_info->strides = NULL;
  }
  __pyx_L7:;

  /* "View.MemoryView":527
 *             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":528
 * 
 *         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":527
 *             info.strides = NULL
 * 
 *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
 *             info.suboffsets = self.view.suboffsets
 *         else:
 */
    goto __pyx_L8;
  }

  /* "View.MemoryView":530
 *             info.suboffsets = self.view.suboffsets
 *         else:
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_FORMAT:
 */
  /*else*/ {
    __pyx_v_info->suboffsets = NULL;
  }
  __pyx_L8:;

  /* "View.MemoryView":532
 *             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":533
 * 
 *         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":532
 *             info.suboffsets = NULL
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             info.format = self.view.format
 *         else:
 */
    goto __pyx_L9;
  }

  /* "View.MemoryView":535
 *             info.format = self.view.format
 *         else:
 *             info.format = NULL             # <<<<<<<<<<<<<<
 * 
 *         info.buf = self.view.buf
 */
  /*else*/ {
    __pyx_v_info->format = NULL;
  }
  __pyx_L9:;

  /* "View.MemoryView":537
 *             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":538
 * 
 *         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":539
 *         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":540
 *         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":541
 *         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":542
 *         info.len = self.view.len
 *         info.readonly = self.view.readonly
 *         info.obj = self             # <<<<<<<<<<<<<<
 * 
 *     __pyx_getbuffer = capsule(<void *> &__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":513
 * 
 *     @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":548
 * 
 *     @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;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":549
 *     @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(4, 549, __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(4, 549, __pyx_L1_error)
  __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":550
 *     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(4, 550, __pyx_L1_error)

  /* "View.MemoryView":551
 *         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":548
 * 
 *     @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":554
 * 
 *     @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":555
 *     @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":554
 * 
 *     @property
 *     def base(self):             # <<<<<<<<<<<<<<
 *         return self.obj
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":558
 * 
 *     @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;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":559
 *     @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(4, 559, __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(4, 559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(4, 559, __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(4, 559, __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":558
 * 
 *     @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":562
 * 
 *     @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;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":563
 *     @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":565
 *         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__185, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 565, __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(4, 565, __pyx_L1_error)

    /* "View.MemoryView":563
 *     @property
 *     def strides(self):
 *         if self.view.strides == NULL:             # <<<<<<<<<<<<<<
 * 
 *             raise ValueError("Buffer view does not expose strides")
 */
  }

  /* "View.MemoryView":567
 *             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(4, 567, __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(4, 567, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(4, 567, __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(4, 567, __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":562
 * 
 *     @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":570
 * 
 *     @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;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":571
 *     @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":572
 *     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(4, 572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__186, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 572, __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":571
 *     @property
 *     def suboffsets(self):
 *         if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
 *             return (-1,) * self.view.ndim
 * 
 */
  }

  /* "View.MemoryView":574
 *             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(4, 574, __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(4, 574, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(4, 574, __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(4, 574, __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":570
 * 
 *     @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":577
 * 
 *     @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;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":578
 *     @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(4, 578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":577
 * 
 *     @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":581
 * 
 *     @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;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":582
 *     @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(4, 582, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":581
 * 
 *     @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":585
 * 
 *     @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;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":586
 *     @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(4, 586, __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(4, 586, __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(4, 586, __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":585
 * 
 *     @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":589
 * 
 *     @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;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":590
 *     @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":591
 *     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":593
 *             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(4, 593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "View.MemoryView":594
 * 
 *             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(4, 594, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6);
      __pyx_t_6 = 0;
    }

    /* "View.MemoryView":596
 *                 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":590
 *     @property
 *     def size(self):
 *         if self._size is None:             # <<<<<<<<<<<<<<
 *             result = 1
 * 
 */
  }

  /* "View.MemoryView":598
 *             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":589
 * 
 *     @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":600
 *         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":601
 * 
 *     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":602
 *     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":601
 * 
 *     def __len__(self):
 *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
 *             return self.view.shape[0]
 * 
 */
  }

  /* "View.MemoryView":604
 *             return self.view.shape[0]
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "View.MemoryView":600
 *         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":606
 *         return 0
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r at 0x%x>" % (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;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "View.MemoryView":607
 * 
 *     def __repr__(self):
 *         return "<MemoryView of %r at 0x%x>" % (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(4, 607, __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(4, 607, __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(4, 607, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "View.MemoryView":608
 *     def __repr__(self):
 *         return "<MemoryView of %r at 0x%x>" % (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(4, 608, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "View.MemoryView":607
 * 
 *     def __repr__(self):
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
 *                                                id(self))
 * 
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 607, __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(4, 607, __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":606
 *         return 0
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r at 0x%x>" % (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":610
 *                                                id(self))
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r object>" % (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;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "View.MemoryView":611
 * 
 *     def __str__(self):
 *         return "<MemoryView of %r object>" % (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(4, 611, __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(4, 611, __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(4, 611, __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(4, 611, __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(4, 611, __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":610
 *                                                id(self))
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r object>" % (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":614
 * 
 * 
 *     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
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("is_c_contig", 0);

  /* "View.MemoryView":617
 *         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_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp));

  /* "View.MemoryView":618
 *         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_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'C', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 618, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":614
 * 
 * 
 *     def is_c_contig(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __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":620
 *         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
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("is_f_contig", 0);

  /* "View.MemoryView":623
 *         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_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp));

  /* "View.MemoryView":624
 *         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_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'F', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 624, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":620
 *         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_1);
  __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":626
 *         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;
  __Pyx_RefNannySetupContext("copy", 0);

  /* "View.MemoryView":628
 *     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":630
 *         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":631
 * 
 *         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(4, 631, __pyx_L1_error)
  __pyx_v_mslice = __pyx_t_1;

  /* "View.MemoryView":636
 *                                    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(4, 636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":626
 *         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":638
 *         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;
  __Pyx_RefNannySetupContext("copy_fortran", 0);

  /* "View.MemoryView":640
 *     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":642
 *         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":643
 * 
 *         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(4, 643, __pyx_L1_error)
  __pyx_v_dst = __pyx_t_1;

  /* "View.MemoryView":648
 *                                 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(4, 648, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":638
 *         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;
  __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__187, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 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(4, 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;
  __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__188, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 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(4, 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":652
 * 
 * @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;
  __Pyx_RefNannySetupContext("memoryview_cwrapper", 0);

  /* "View.MemoryView":653
 * @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(4, 653, __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(4, 653, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 653, __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(4, 653, __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":654
 * 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":655
 *     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":652
 * 
 * @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":658
 * 
 * @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":659
 * @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":658
 * 
 * @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":661
 *     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;
  __Pyx_RefNannySetupContext("_unellipsify", 0);

  /* "View.MemoryView":666
 *     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":667
 *     """
 *     if not isinstance(index, tuple):
 *         tup = (index,)             # <<<<<<<<<<<<<<
 *     else:
 *         tup = index
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 667, __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":666
 *     full slices.
 *     """
 *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
 *         tup = (index,)
 *     else:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":669
 *         tup = (index,)
 *     else:
 *         tup = index             # <<<<<<<<<<<<<<
 * 
 *     result = []
 */
  /*else*/ {
    __Pyx_INCREF(__pyx_v_index);
    __pyx_v_tup = __pyx_v_index;
  }
  __pyx_L3:;

  /* "View.MemoryView":671
 *         tup = index
 * 
 *     result = []             # <<<<<<<<<<<<<<
 *     have_slices = False
 *     seen_ellipsis = False
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 671, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_result = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "View.MemoryView":672
 * 
 *     result = []
 *     have_slices = False             # <<<<<<<<<<<<<<
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):
 */
  __pyx_v_have_slices = 0;

  /* "View.MemoryView":673
 *     result = []
 *     have_slices = False
 *     seen_ellipsis = False             # <<<<<<<<<<<<<<
 *     for idx, item in enumerate(tup):
 *         if item is Ellipsis:
 */
  __pyx_v_seen_ellipsis = 0;

  /* "View.MemoryView":674
 *     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(4, 674, __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(4, 674, __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(4, 674, __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(4, 674, __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(4, 674, __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(4, 674, __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(4, 674, __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); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 674, __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":675
 *     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":676
 *     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":677
 *         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(4, 677, __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(4, 677, __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__189);
            __Pyx_GIVEREF(__pyx_slice__189);
            PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__189);
          }
        }
        __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(4, 677, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "View.MemoryView":678
 *             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":676
 *     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":680
 *                 seen_ellipsis = True
 *             else:
 *                 result.append(slice(None))             # <<<<<<<<<<<<<<
 *             have_slices = True
 *         else:
 */
      /*else*/ {
        __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__190); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(4, 680, __pyx_L1_error)
      }
      __pyx_L7:;

      /* "View.MemoryView":681
 *             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":675
 *     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":683
 *             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":684
 *         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_Format(__pyx_kp_s_Cannot_index_with_type_s, ((PyObject *)Py_TYPE(__pyx_v_item))); if (unlikely(!__pyx_t_7)) __PYX_ERR(4, 684, __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(4, 684, __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(4, 684, __pyx_L1_error)

        /* "View.MemoryView":683
 *             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":686
 *                 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":687
 * 
 *             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(4, 687, __pyx_L1_error)
    }
    __pyx_L6:;

    /* "View.MemoryView":674
 *     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":689
 *             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(4, 689, __pyx_L1_error)
  __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5);

  /* "View.MemoryView":690
 * 
 *     nslices = ndim - len(result)
 *     if nslices:             # <<<<<<<<<<<<<<
 *         result.extend([slice(None)] * nslices)
 * 
 */
  __pyx_t_1 = (__pyx_v_nslices != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":691
 *     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(4, 691, __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__191);
        __Pyx_GIVEREF(__pyx_slice__191);
        PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__191);
      }
    }
    __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(4, 691, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "View.MemoryView":690
 * 
 *     nslices = ndim - len(result)
 *     if nslices:             # <<<<<<<<<<<<<<
 *         result.extend([slice(None)] * nslices)
 * 
 */
  }

  /* "View.MemoryView":693
 *         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(4, 693, __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(4, 693, __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(4, 693, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(4, 693, __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":661
 *     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":695
 *     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;
  __Pyx_RefNannySetupContext("assert_direct_dimensions", 0);

  /* "View.MemoryView":696
 * 
 * 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":697
 * 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":698
 *     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__192, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 698, __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(4, 698, __pyx_L1_error)

      /* "View.MemoryView":697
 * 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":695
 *     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":705
 * 
 * @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;
  __Pyx_RefNannySetupContext("memview_slice", 0);

  /* "View.MemoryView":706
 * @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":713
 * 
 * 
 *     memset(&dst, 0, sizeof(dst))             # <<<<<<<<<<<<<<
 * 
 *     cdef _memoryviewslice memviewsliceobj
 */
  (void)(memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst))));

  /* "View.MemoryView":717
 *     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(4, 717, __pyx_L1_error)
    }
  }
  #endif

  /* "View.MemoryView":719
 *     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":720
 * 
 *     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(4, 720, __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":721
 *     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":719
 *     assert memview.view.ndim > 0
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         memviewsliceobj = memview
 *         p_src = &memviewsliceobj.from_slice
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":723
 *         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":724
 *     else:
 *         slice_copy(memview, &src)
 *         p_src = &src             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_p_src = (&__pyx_v_src);
  }
  __pyx_L3:;

  /* "View.MemoryView":730
 * 
 * 
 *     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":731
 * 
 *     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":736
 * 
 * 
 *     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":737
 * 
 *     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":741
 *     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(4, 741, __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(4, 741, __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(4, 741, __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(4, 741, __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(4, 741, __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(4, 741, __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(4, 741, __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":742
 * 
 *     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":746
 *                 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(4, 746, __pyx_L1_error)

      /* "View.MemoryView":743
 *     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(4, 743, __pyx_L1_error)

      /* "View.MemoryView":742
 * 
 *     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":749
 *                 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":750
 *                 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":751
 *         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":752
 *             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":753
 *             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":749
 *                 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":755
 *             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(4, 755, __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(4, 755, __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(4, 755, __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":756
 *         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(4, 756, __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(4, 756, __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(4, 756, __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":757
 *             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(4, 757, __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(4, 757, __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(4, 757, __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":759
 *             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(4, 759, __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":760
 * 
 *             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(4, 760, __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":761
 *             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(4, 761, __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":763
 *             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(4, 763, __pyx_L1_error)

      /* "View.MemoryView":769
 *                 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":741
 *     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":771
 *             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":772
 * 
 *     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":773
 *     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(4, 773, __pyx_L1_error) }

    /* "View.MemoryView":774
 *         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(4, 774, __pyx_L1_error) }

    /* "View.MemoryView":772
 * 
 *     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(4, 772, __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(4, 772, __pyx_L1_error)
    __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "View.MemoryView":771
 *             new_ndim += 1
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         return memoryview_fromslice(dst, new_ndim,
 *                                     memviewsliceobj.to_object_func,
 */
  }

  /* "View.MemoryView":777
 *                                     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":778
 *     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(4, 777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "View.MemoryView":777
 *                                     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(4, 777, __pyx_L1_error)
    __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "View.MemoryView":705
 * 
 * @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":802
 * 
 * @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;

  /* "View.MemoryView":822
 *     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":824
 *     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":825
 * 
 *         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":824
 *     if not is_slice:
 * 
 *         if start < 0:             # <<<<<<<<<<<<<<
 *             start += shape
 *         if not 0 <= start < shape:
 */
    }

    /* "View.MemoryView":826
 *         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":827
 *             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(4, 827, __pyx_L1_error)

      /* "View.MemoryView":826
 *         if start < 0:
 *             start += shape
 *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
 *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
 *     else:
 */
    }

    /* "View.MemoryView":822
 *     cdef bint negative_step
 * 
 *     if not is_slice:             # <<<<<<<<<<<<<<
 * 
 *         if start < 0:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":830
 *     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":832
 *         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":833
 * 
 *         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(4, 833, __pyx_L1_error)

      /* "View.MemoryView":832
 *         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":836
 * 
 * 
 *         if have_start:             # <<<<<<<<<<<<<<
 *             if start < 0:
 *                 start += shape
 */
    __pyx_t_2 = (__pyx_v_have_start != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":837
 * 
 *         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":838
 *         if have_start:
 *             if start < 0:
 *                 start += shape             # <<<<<<<<<<<<<<
 *                 if start < 0:
 *                     start = 0
 */
        __pyx_v_start = (__pyx_v_start + __pyx_v_shape);

        /* "View.MemoryView":839
 *             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":840
 *                 start += shape
 *                 if start < 0:
 *                     start = 0             # <<<<<<<<<<<<<<
 *             elif start >= shape:
 *                 if negative_step:
 */
          __pyx_v_start = 0;

          /* "View.MemoryView":839
 *             if start < 0:
 *                 start += shape
 *                 if start < 0:             # <<<<<<<<<<<<<<
 *                     start = 0
 *             elif start >= shape:
 */
        }

        /* "View.MemoryView":837
 * 
 *         if have_start:
 *             if start < 0:             # <<<<<<<<<<<<<<
 *                 start += shape
 *                 if start < 0:
 */
        goto __pyx_L12;
      }

      /* "View.MemoryView":841
 *                 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":842
 *                     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":843
 *             elif start >= shape:
 *                 if negative_step:
 *                     start = shape - 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     start = shape
 */
          __pyx_v_start = (__pyx_v_shape - 1);

          /* "View.MemoryView":842
 *                     start = 0
 *             elif start >= shape:
 *                 if negative_step:             # <<<<<<<<<<<<<<
 *                     start = shape - 1
 *                 else:
 */
          goto __pyx_L14;
        }

        /* "View.MemoryView":845
 *                     start = shape - 1
 *                 else:
 *                     start = shape             # <<<<<<<<<<<<<<
 *         else:
 *             if negative_step:
 */
        /*else*/ {
          __pyx_v_start = __pyx_v_shape;
        }
        __pyx_L14:;

        /* "View.MemoryView":841
 *                 if start < 0:
 *                     start = 0
 *             elif start >= shape:             # <<<<<<<<<<<<<<
 *                 if negative_step:
 *                     start = shape - 1
 */
      }
      __pyx_L12:;

      /* "View.MemoryView":836
 * 
 * 
 *         if have_start:             # <<<<<<<<<<<<<<
 *             if start < 0:
 *                 start += shape
 */
      goto __pyx_L11;
    }

    /* "View.MemoryView":847
 *                     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":848
 *         else:
 *             if negative_step:
 *                 start = shape - 1             # <<<<<<<<<<<<<<
 *             else:
 *                 start = 0
 */
        __pyx_v_start = (__pyx_v_shape - 1);

        /* "View.MemoryView":847
 *                     start = shape
 *         else:
 *             if negative_step:             # <<<<<<<<<<<<<<
 *                 start = shape - 1
 *             else:
 */
        goto __pyx_L15;
      }

      /* "View.MemoryView":850
 *                 start = shape - 1
 *             else:
 *                 start = 0             # <<<<<<<<<<<<<<
 * 
 *         if have_stop:
 */
      /*else*/ {
        __pyx_v_start = 0;
      }
      __pyx_L15:;
    }
    __pyx_L11:;

    /* "View.MemoryView":852
 *                 start = 0
 * 
 *         if have_stop:             # <<<<<<<<<<<<<<
 *             if stop < 0:
 *                 stop += shape
 */
    __pyx_t_2 = (__pyx_v_have_stop != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":853
 * 
 *         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":854
 *         if have_stop:
 *             if stop < 0:
 *                 stop += shape             # <<<<<<<<<<<<<<
 *                 if stop < 0:
 *                     stop = 0
 */
        __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape);

        /* "View.MemoryView":855
 *             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":856
 *                 stop += shape
 *                 if stop < 0:
 *                     stop = 0             # <<<<<<<<<<<<<<
 *             elif stop > shape:
 *                 stop = shape
 */
          __pyx_v_stop = 0;

          /* "View.MemoryView":855
 *             if stop < 0:
 *                 stop += shape
 *                 if stop < 0:             # <<<<<<<<<<<<<<
 *                     stop = 0
 *             elif stop > shape:
 */
        }

        /* "View.MemoryView":853
 * 
 *         if have_stop:
 *             if stop < 0:             # <<<<<<<<<<<<<<
 *                 stop += shape
 *                 if stop < 0:
 */
        goto __pyx_L17;
      }

      /* "View.MemoryView":857
 *                 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":858
 *                     stop = 0
 *             elif stop > shape:
 *                 stop = shape             # <<<<<<<<<<<<<<
 *         else:
 *             if negative_step:
 */
        __pyx_v_stop = __pyx_v_shape;

        /* "View.MemoryView":857
 *                 if stop < 0:
 *                     stop = 0
 *             elif stop > shape:             # <<<<<<<<<<<<<<
 *                 stop = shape
 *         else:
 */
      }
      __pyx_L17:;

      /* "View.MemoryView":852
 *                 start = 0
 * 
 *         if have_stop:             # <<<<<<<<<<<<<<
 *             if stop < 0:
 *                 stop += shape
 */
      goto __pyx_L16;
    }

    /* "View.MemoryView":860
 *                 stop = shape
 *         else:
 *             if negative_step:             # <<<<<<<<<<<<<<
 *                 stop = -1
 *             else:
 */
    /*else*/ {
      __pyx_t_2 = (__pyx_v_negative_step != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":861
 *         else:
 *             if negative_step:
 *                 stop = -1             # <<<<<<<<<<<<<<
 *             else:
 *                 stop = shape
 */
        __pyx_v_stop = -1L;

        /* "View.MemoryView":860
 *                 stop = shape
 *         else:
 *             if negative_step:             # <<<<<<<<<<<<<<
 *                 stop = -1
 *             else:
 */
        goto __pyx_L19;
      }

      /* "View.MemoryView":863
 *                 stop = -1
 *             else:
 *                 stop = shape             # <<<<<<<<<<<<<<
 * 
 *         if not have_step:
 */
      /*else*/ {
        __pyx_v_stop = __pyx_v_shape;
      }
      __pyx_L19:;
    }
    __pyx_L16:;

    /* "View.MemoryView":865
 *                 stop = shape
 * 
 *         if not have_step:             # <<<<<<<<<<<<<<
 *             step = 1
 * 
 */
    __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":866
 * 
 *         if not have_step:
 *             step = 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_step = 1;

      /* "View.MemoryView":865
 *                 stop = shape
 * 
 *         if not have_step:             # <<<<<<<<<<<<<<
 *             step = 1
 * 
 */
    }

    /* "View.MemoryView":870
 * 
 *         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":872
 *             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":873
 * 
 *             if (stop - start) - step * new_shape:
 *                 new_shape += 1             # <<<<<<<<<<<<<<
 * 
 *         if new_shape < 0:
 */
      __pyx_v_new_shape = (__pyx_v_new_shape + 1);

      /* "View.MemoryView":872
 *             new_shape = (stop - start) // step
 * 
 *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
 *                 new_shape += 1
 * 
 */
    }

    /* "View.MemoryView":875
 *                 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":876
 * 
 *         if new_shape < 0:
 *             new_shape = 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_new_shape = 0;

      /* "View.MemoryView":875
 *                 new_shape += 1
 * 
 *         if new_shape < 0:             # <<<<<<<<<<<<<<
 *             new_shape = 0
 * 
 */
    }

    /* "View.MemoryView":879
 * 
 * 
 *         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":880
 * 
 *         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":881
 *         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":884
 * 
 * 
 *     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":885
 * 
 *     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":884
 * 
 * 
 *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
 *         dst.data += start * stride
 *     else:
 */
    goto __pyx_L23;
  }

  /* "View.MemoryView":887
 *         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":889
 *         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":890
 * 
 *     if suboffset >= 0:
 *         if not is_slice:             # <<<<<<<<<<<<<<
 *             if new_ndim == 0:
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 */
    __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":891
 *     if suboffset >= 0:
 *         if not is_slice:
 *             if new_ndim == 0:             # <<<<<<<<<<<<<<
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 *             else:
 */
      __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":892
 *         if not is_slice:
 *             if new_ndim == 0:
 *                 dst.data = (<char **> 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":891
 *     if suboffset >= 0:
 *         if not is_slice:
 *             if new_ndim == 0:             # <<<<<<<<<<<<<<
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 *             else:
 */
        goto __pyx_L26;
      }

      /* "View.MemoryView":894
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 *             else:
 *                 _err_dim(IndexError, "All dimensions preceding dimension %d "             # <<<<<<<<<<<<<<
 *                                      "must be indexed and not sliced", dim)
 *         else:
 */
      /*else*/ {

        /* "View.MemoryView":895
 *             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(4, 894, __pyx_L1_error)
      }
      __pyx_L26:;

      /* "View.MemoryView":890
 * 
 *     if suboffset >= 0:
 *         if not is_slice:             # <<<<<<<<<<<<<<
 *             if new_ndim == 0:
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 */
      goto __pyx_L25;
    }

    /* "View.MemoryView":897
 *                                      "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":889
 *         dst.suboffsets[suboffset_dim[0]] += start * stride
 * 
 *     if suboffset >= 0:             # <<<<<<<<<<<<<<
 *         if not is_slice:
 *             if new_ndim == 0:
 */
  }

  /* "View.MemoryView":899
 *             suboffset_dim[0] = new_ndim
 * 
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "View.MemoryView":802
 * 
 * @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":905
 * 
 * @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;
  __Pyx_RefNannySetupContext("pybuffer_index", 0);

  /* "View.MemoryView":907
 * 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":908
 *                           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":911
 *     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":912
 * 
 *     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(4, 912, __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(4, 912, __pyx_L1_error)
    }
    __pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize);

    /* "View.MemoryView":913
 *     if view.ndim == 0:
 *         shape = view.len / itemsize
 *         stride = itemsize             # <<<<<<<<<<<<<<
 *     else:
 *         shape = view.shape[dim]
 */
    __pyx_v_stride = __pyx_v_itemsize;

    /* "View.MemoryView":911
 *     cdef char *resultp
 * 
 *     if view.ndim == 0:             # <<<<<<<<<<<<<<
 *         shape = view.len / itemsize
 *         stride = itemsize
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":915
 *         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":916
 *     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":917
 *         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":918
 *         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":917
 *         shape = view.shape[dim]
 *         stride = view.strides[dim]
 *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
 *             suboffset = view.suboffsets[dim]
 * 
 */
    }
  }
  __pyx_L3:;

  /* "View.MemoryView":920
 *             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":921
 * 
 *     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":922
 *     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":923
 *         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(4, 923, __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(4, 923, __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(4, 923, __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(4, 923, __pyx_L1_error)

      /* "View.MemoryView":922
 *     if index < 0:
 *         index += view.shape[dim]
 *         if index < 0:             # <<<<<<<<<<<<<<
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 */
    }

    /* "View.MemoryView":920
 *             suboffset = view.suboffsets[dim]
 * 
 *     if index < 0:             # <<<<<<<<<<<<<<
 *         index += view.shape[dim]
 *         if index < 0:
 */
  }

  /* "View.MemoryView":925
 *             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":926
 * 
 *     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(4, 926, __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(4, 926, __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(4, 926, __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(4, 926, __pyx_L1_error)

    /* "View.MemoryView":925
 *             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":928
 *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 *     resultp = bufp + index * stride             # <<<<<<<<<<<<<<
 *     if suboffset >= 0:
 *         resultp = (<char **> resultp)[0] + suboffset
 */
  __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride));

  /* "View.MemoryView":929
 * 
 *     resultp = bufp + index * stride
 *     if suboffset >= 0:             # <<<<<<<<<<<<<<
 *         resultp = (<char **> resultp)[0] + suboffset
 * 
 */
  __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":930
 *     resultp = bufp + index * stride
 *     if suboffset >= 0:
 *         resultp = (<char **> resultp)[0] + suboffset             # <<<<<<<<<<<<<<
 * 
 *     return resultp
 */
    __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset);

    /* "View.MemoryView":929
 * 
 *     resultp = bufp + index * stride
 *     if suboffset >= 0:             # <<<<<<<<<<<<<<
 *         resultp = (<char **> resultp)[0] + suboffset
 * 
 */
  }

  /* "View.MemoryView":932
 *         resultp = (<char **> resultp)[0] + suboffset
 * 
 *     return resultp             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_resultp;
  goto __pyx_L0;

  /* "View.MemoryView":905
 * 
 * @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":938
 * 
 * @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;

  /* "View.MemoryView":939
 * @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":941
 *     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":942
 * 
 *     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":946
 * 
 *     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":947
 *     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":948
 *     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":949
 *         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":951
 *         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":952
 * 
 *         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(4, 952, __pyx_L1_error)

      /* "View.MemoryView":951
 *         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":954
 *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
 * 
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "View.MemoryView":938
 * 
 * @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":971
 *     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":972
 * 
 *     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":971
 *     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":974
 *         __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;
  __Pyx_RefNannySetupContext("convert_item_to_object", 0);

  /* "View.MemoryView":975
 * 
 *     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":976
 *     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(4, 976, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "View.MemoryView":975
 * 
 *     cdef convert_item_to_object(self, char *itemp):
 *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
 *             return self.to_object_func(itemp)
 *         else:
 */
  }

  /* "View.MemoryView":978
 *             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(4, 978, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "View.MemoryView":974
 *         __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":980
 *             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;
  __Pyx_RefNannySetupContext("assign_item_from_object", 0);

  /* "View.MemoryView":981
 * 
 *     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":982
 *     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(4, 982, __pyx_L1_error)

    /* "View.MemoryView":981
 * 
 *     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":984
 *             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(4, 984, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "View.MemoryView":980
 *             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":987
 * 
 *     @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":988
 *     @property
 *     def base(self):
 *         return self.from_object             # <<<<<<<<<<<<<<
 * 
 *     __pyx_getbuffer = capsule(<void *> &__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":987
 * 
 *     @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;
  __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__193, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 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(4, 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;
  __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__194, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 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(4, 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":994
 * 
 * @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;
  __Pyx_RefNannySetupContext("memoryview_fromslice", 0);

  /* "View.MemoryView":1002
 *     cdef _memoryviewslice result
 * 
 *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1003
 * 
 *     if <PyObject *> memviewslice.memview == Py_None:
 *         return None             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "View.MemoryView":1002
 *     cdef _memoryviewslice result
 * 
 *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  }

  /* "View.MemoryView":1008
 * 
 * 
 *     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(4, 1008, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 1008, __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(4, 1008, __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":1010
 *     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":1011
 * 
 *     result.from_slice = memviewslice
 *     __PYX_INC_MEMVIEW(&memviewslice, 1)             # <<<<<<<<<<<<<<
 * 
 *     result.from_object = (<memoryview> memviewslice.memview).base
 */
  __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1);

  /* "View.MemoryView":1013
 *     __PYX_INC_MEMVIEW(&memviewslice, 1)
 * 
 *     result.from_object = (<memoryview> 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(4, 1013, __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":1014
 * 
 *     result.from_object = (<memoryview> 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":1016
 *     result.typeinfo = memviewslice.memview.typeinfo
 * 
 *     result.view = memviewslice.memview.view             # <<<<<<<<<<<<<<
 *     result.view.buf = <void *> 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":1017
 * 
 *     result.view = memviewslice.memview.view
 *     result.view.buf = <void *> 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":1018
 *     result.view = memviewslice.memview.view
 *     result.view.buf = <void *> 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":1019
 *     result.view.buf = <void *> 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":1020
 *     result.view.ndim = ndim
 *     (<__pyx_buffer *> &result.view).obj = Py_None
 *     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
 * 
 *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
 */
  Py_INCREF(Py_None);

  /* "View.MemoryView":1022
 *     Py_INCREF(Py_None)
 * 
 *     if (<memoryview>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":1023
 * 
 *     if (<memoryview>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":1022
 *     Py_INCREF(Py_None)
 * 
 *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
 *         result.flags = PyBUF_RECORDS
 *     else:
 */
    goto __pyx_L4;
  }

  /* "View.MemoryView":1025
 *         result.flags = PyBUF_RECORDS
 *     else:
 *         result.flags = PyBUF_RECORDS_RO             # <<<<<<<<<<<<<<
 * 
 *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
 */
  /*else*/ {
    __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS_RO;
  }
  __pyx_L4:;

  /* "View.MemoryView":1027
 *         result.flags = PyBUF_RECORDS_RO
 * 
 *     result.view.shape = <Py_ssize_t *> result.from_slice.shape             # <<<<<<<<<<<<<<
 *     result.view.strides = <Py_ssize_t *> result.from_slice.strides
 * 
 */
  __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape);

  /* "View.MemoryView":1028
 * 
 *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
 *     result.view.strides = <Py_ssize_t *> result.from_slice.strides             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides);

  /* "View.MemoryView":1031
 * 
 * 
 *     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":1032
 * 
 *     result.view.suboffsets = NULL
 *     for suboffset in result.from_slice.suboffsets[:ndim]:             # <<<<<<<<<<<<<<
 *         if suboffset >= 0:
 *             result.view.suboffsets = <Py_ssize_t *> 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":1033
 *     result.view.suboffsets = NULL
 *     for suboffset in result.from_slice.suboffsets[:ndim]:
 *         if suboffset >= 0:             # <<<<<<<<<<<<<<
 *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
 *             break
 */
    __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":1034
 *     for suboffset in result.from_slice.suboffsets[:ndim]:
 *         if suboffset >= 0:
 *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets             # <<<<<<<<<<<<<<
 *             break
 * 
 */
      __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets);

      /* "View.MemoryView":1035
 *         if suboffset >= 0:
 *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
 *             break             # <<<<<<<<<<<<<<
 * 
 *     result.view.len = result.view.itemsize
 */
      goto __pyx_L6_break;

      /* "View.MemoryView":1033
 *     result.view.suboffsets = NULL
 *     for suboffset in result.from_slice.suboffsets[:ndim]:
 *         if suboffset >= 0:             # <<<<<<<<<<<<<<
 *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
 *             break
 */
    }
  }
  __pyx_L6_break:;

  /* "View.MemoryView":1037
 *             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":1038
 * 
 *     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(4, 1038, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "View.MemoryView":1039
 *     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(4, 1039, __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(4, 1039, __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(4, 1039, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
  }

  /* "View.MemoryView":1041
 *         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":1042
 * 
 *     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":1044
 *     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":994
 * 
 * @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":1047
 * 
 * @cname('__pyx_memoryview_get_slice_from_memoryview')
 * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
 *                                                    __Pyx_memviewslice *mslice):
 *     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;
  __Pyx_RefNannySetupContext("get_slice_from_memview", 0);

  /* "View.MemoryView":1050
 *                                                    __Pyx_memviewslice *mslice):
 *     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":1051
 *     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(4, 1051, __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":1052
 *     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":1050
 *                                                    __Pyx_memviewslice *mslice):
 *     cdef _memoryviewslice obj
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         obj = memview
 *         return &obj.from_slice
 */
  }

  /* "View.MemoryView":1054
 *         return &obj.from_slice
 *     else:
 *         slice_copy(memview, mslice)             # <<<<<<<<<<<<<<
 *         return mslice
 * 
 */
  /*else*/ {
    __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice);

    /* "View.MemoryView":1055
 *     else:
 *         slice_copy(memview, mslice)
 *         return mslice             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_slice_copy')
 */
    __pyx_r = __pyx_v_mslice;
    goto __pyx_L0;
  }

  /* "View.MemoryView":1047
 * 
 * @cname('__pyx_memoryview_get_slice_from_memoryview')
 * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
 *                                                    __Pyx_memviewslice *mslice):
 *     cdef _memoryviewslice obj
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_obj);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":1058
 * 
 * @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":1062
 *     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":1063
 * 
 *     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":1064
 *     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":1066
 *     suboffsets = memview.view.suboffsets
 * 
 *     dst.memview = <__pyx_memoryview *> memview             # <<<<<<<<<<<<<<
 *     dst.data = <char *> memview.view.buf
 * 
 */
  __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview);

  /* "View.MemoryView":1067
 * 
 *     dst.memview = <__pyx_memoryview *> memview
 *     dst.data = <char *> memview.view.buf             # <<<<<<<<<<<<<<
 * 
 *     for dim in range(memview.view.ndim):
 */
  __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf);

  /* "View.MemoryView":1069
 *     dst.data = <char *> 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":1070
 * 
 *     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":1071
 *     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":1072
 *         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":1058
 * 
 * @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":1075
 * 
 * @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;
  __Pyx_RefNannySetupContext("memoryview_copy", 0);

  /* "View.MemoryView":1078
 *     "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":1079
 *     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(4, 1079, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":1075
 * 
 * @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":1082
 * 
 * @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;
  __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0);

  /* "View.MemoryView":1089
 *     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":1090
 * 
 *     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":1091
 *     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":1089
 *     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":1093
 *         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":1094
 *     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":1096
 *         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":1098
 *     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(4, 1096, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":1082
 * 
 * @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":1104
 * 
 * 
 * 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":1105
 * 
 * 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":1106
 * 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":1105
 * 
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
 *     if arg < 0:             # <<<<<<<<<<<<<<
 *         return -arg
 *     else:
 */
  }

  /* "View.MemoryView":1108
 *         return -arg
 *     else:
 *         return arg             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_get_best_slice_order')
 */
  /*else*/ {
    __pyx_r = __pyx_v_arg;
    goto __pyx_L0;
  }

  /* "View.MemoryView":1104
 * 
 * 
 * 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":1111
 * 
 * @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":1116
 *     """
 *     cdef int i
 *     cdef Py_ssize_t c_stride = 0             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t f_stride = 0
 * 
 */
  __pyx_v_c_stride = 0;

  /* "View.MemoryView":1117
 *     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":1119
 *     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":1120
 * 
 *     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":1121
 *     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":1122
 *         if mslice.shape[i] > 1:
 *             c_stride = mslice.strides[i]
 *             break             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
      goto __pyx_L4_break;

      /* "View.MemoryView":1120
 * 
 *     for i in range(ndim - 1, -1, -1):
 *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
 *             c_stride = mslice.strides[i]
 *             break
 */
    }
  }
  __pyx_L4_break:;

  /* "View.MemoryView":1124
 *             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":1125
 * 
 *     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":1126
 *     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":1127
 *         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":1125
 * 
 *     for i in range(ndim):
 *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
 *             f_stride = mslice.strides[i]
 *             break
 */
    }
  }
  __pyx_L7_break:;

  /* "View.MemoryView":1129
 *             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":1130
 * 
 *     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":1129
 *             break
 * 
 *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
 *         return 'C'
 *     else:
 */
  }

  /* "View.MemoryView":1132
 *         return 'C'
 *     else:
 *         return 'F'             # <<<<<<<<<<<<<<
 * 
 * @cython.cdivision(True)
 */
  /*else*/ {
    __pyx_r = 'F';
    goto __pyx_L0;
  }

  /* "View.MemoryView":1111
 * 
 * @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":1135
 * 
 * @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":1142
 * 
 *     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":1143
 *     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":1144
 *     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":1145
 *     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":1147
 *     cdef Py_ssize_t dst_stride = dst_strides[0]
 * 
 *     if ndim == 1:             # <<<<<<<<<<<<<<
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 */
  __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1148
 * 
 *     if ndim == 1:
 *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
 *            <size_t> src_stride == itemsize == <size_t> 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":1149
 *     if ndim == 1:
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> 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":1148
 * 
 *     if ndim == 1:
 *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 */
    if (__pyx_t_1) {

      /* "View.MemoryView":1150
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> 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":1148
 * 
 *     if ndim == 1:
 *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 */
      goto __pyx_L4;
    }

    /* "View.MemoryView":1152
 *            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":1153
 *        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":1154
 *            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":1155
 *                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":1147
 *     cdef Py_ssize_t dst_stride = dst_strides[0]
 * 
 *     if ndim == 1:             # <<<<<<<<<<<<<<
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":1157
 *                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":1158
 *     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":1162
 *                                      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":1163
 *                                      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":1135
 * 
 * @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":1165
 *             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":1168
 *                                   __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":1165
 *             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":1172
 * 
 * @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 int i
 */

static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) {
  int __pyx_v_i;
  Py_ssize_t __pyx_v_size;
  Py_ssize_t __pyx_r;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;

  /* "View.MemoryView":1175
 *     "Return the size of the memory occupied by the slice in number of bytes"
 *     cdef int i
 *     cdef Py_ssize_t size = src.memview.view.itemsize             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
  __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
  __pyx_v_size = __pyx_t_1;

  /* "View.MemoryView":1177
 *     cdef Py_ssize_t size = src.memview.view.itemsize
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         size *= src.shape[i]
 * 
 */
  __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_i = __pyx_t_4;

    /* "View.MemoryView":1178
 * 
 *     for i in range(ndim):
 *         size *= src.shape[i]             # <<<<<<<<<<<<<<
 * 
 *     return size
 */
    __pyx_v_size = (__pyx_v_size * (__pyx_v_src->shape[__pyx_v_i]));
  }

  /* "View.MemoryView":1180
 *         size *= src.shape[i]
 * 
 *     return size             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_fill_contig_strides_array')
 */
  __pyx_r = __pyx_v_size;
  goto __pyx_L0;

  /* "View.MemoryView":1172
 * 
 * @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 int i
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1183
 * 
 * @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":1192
 *     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":1193
 * 
 *     if order == 'F':
 *         for idx in range(ndim):             # <<<<<<<<<<<<<<
 *             strides[idx] = stride
 *             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":1194
 *     if order == 'F':
 *         for idx in range(ndim):
 *             strides[idx] = stride             # <<<<<<<<<<<<<<
 *             stride = stride * shape[idx]
 *     else:
 */
      (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;

      /* "View.MemoryView":1195
 *         for idx in range(ndim):
 *             strides[idx] = stride
 *             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":1192
 *     cdef int idx
 * 
 *     if order == 'F':             # <<<<<<<<<<<<<<
 *         for idx in range(ndim):
 *             strides[idx] = stride
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":1197
 *             stride = stride * shape[idx]
 *     else:
 *         for idx in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
 *             strides[idx] = stride
 *             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":1198
 *     else:
 *         for idx in range(ndim - 1, -1, -1):
 *             strides[idx] = stride             # <<<<<<<<<<<<<<
 *             stride = stride * shape[idx]
 * 
 */
      (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;

      /* "View.MemoryView":1199
 *         for idx in range(ndim - 1, -1, -1):
 *             strides[idx] = stride
 *             stride = stride * shape[idx]             # <<<<<<<<<<<<<<
 * 
 *     return stride
 */
      __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
    }
  }
  __pyx_L3:;

  /* "View.MemoryView":1201
 *             stride = stride * shape[idx]
 * 
 *     return stride             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_copy_data_to_temp')
 */
  __pyx_r = __pyx_v_stride;
  goto __pyx_L0;

  /* "View.MemoryView":1183
 * 
 * @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":1204
 * 
 * @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;

  /* "View.MemoryView":1215
 *     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":1216
 * 
 *     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":1218
 *     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":1219
 * 
 *     result = malloc(size)
 *     if not result:             # <<<<<<<<<<<<<<
 *         _err(MemoryError, NULL)
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1220
 *     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(4, 1220, __pyx_L1_error)

    /* "View.MemoryView":1219
 * 
 *     result = malloc(size)
 *     if not result:             # <<<<<<<<<<<<<<
 *         _err(MemoryError, NULL)
 * 
 */
  }

  /* "View.MemoryView":1223
 * 
 * 
 *     tmpslice.data = <char *> result             # <<<<<<<<<<<<<<
 *     tmpslice.memview = src.memview
 *     for i in range(ndim):
 */
  __pyx_v_tmpslice->data = ((char *)__pyx_v_result);

  /* "View.MemoryView":1224
 * 
 *     tmpslice.data = <char *> 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":1225
 *     tmpslice.data = <char *> 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":1226
 *     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":1227
 *     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":1229
 *         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":1233
 * 
 * 
 *     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":1234
 * 
 *     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":1235
 *     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":1234
 * 
 *     for i in range(ndim):
 *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
 *             tmpslice.strides[i] = 0
 * 
 */
    }
  }

  /* "View.MemoryView":1237
 *             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":1238
 * 
 *     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":1237
 *             tmpslice.strides[i] = 0
 * 
 *     if slice_is_contig(src[0], order, ndim):             # <<<<<<<<<<<<<<
 *         memcpy(result, src.data, size)
 *     else:
 */
    goto __pyx_L9;
  }

  /* "View.MemoryView":1240
 *         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":1242
 *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "View.MemoryView":1204
 * 
 * @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":1247
 * 
 * @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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_err_extents", 0);

  /* "View.MemoryView":1250
 *                              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(4, 1250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 1250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 1250, __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":1249
 * 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(4, 1249, __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(4, 1249, __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(4, 1249, __pyx_L1_error)

  /* "View.MemoryView":1247
 * 
 * @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":1253
 * 
 * @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;
  PyObject *__pyx_t_5 = NULL;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_err_dim", 0);
  __Pyx_INCREF(__pyx_v_error);

  /* "View.MemoryView":1254
 * @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(4, 1254, __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(4, 1254, __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(4, 1254, __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);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1254, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1254, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1254, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 1254, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1254, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __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(4, 1254, __pyx_L1_error)

  /* "View.MemoryView":1253
 * 
 * @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_XDECREF(__pyx_t_5);
  __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":1257
 * 
 * @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;
  PyObject *__pyx_t_6 = NULL;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_err", 0);
  __Pyx_INCREF(__pyx_v_error);

  /* "View.MemoryView":1258
 * @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":1259
 * 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(4, 1259, __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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1259, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1259, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1259, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 1259, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 1259, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __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(4, 1259, __pyx_L1_error)

    /* "View.MemoryView":1258
 * @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":1261
 *         raise error(msg.decode('ascii'))
 *     else:
 *         raise error             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_copy_contents')
 */
  /*else*/ {
    __Pyx_Raise(__pyx_v_error, 0, 0, 0);
    __PYX_ERR(4, 1261, __pyx_L1_error)
  }

  /* "View.MemoryView":1257
 * 
 * @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_XDECREF(__pyx_t_6);
  __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":1264
 * 
 * @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;

  /* "View.MemoryView":1272
 *     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":1273
 *     """
 *     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":1275
 *     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":1276
 *     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":1277
 *     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":1280
 *     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":1281
 * 
 *     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":1280
 *     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":1282
 *     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":1283
 *         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":1282
 *     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":1285
 *         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":1287
 *     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":1288
 * 
 *     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":1289
 *     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":1290
 *         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":1291
 *             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":1289
 *     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":1293
 *                 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(4, 1293, __pyx_L1_error)
      }
      __pyx_L7:;

      /* "View.MemoryView":1288
 * 
 *     for i in range(ndim):
 *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
 *             if src.shape[i] == 1:
 *                 broadcasting = True
 */
    }

    /* "View.MemoryView":1295
 *                 _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":1296
 * 
 *         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(4, 1296, __pyx_L1_error)

      /* "View.MemoryView":1295
 *                 _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":1298
 *             _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":1300
 *     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":1301
 * 
 *         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":1300
 *     if slices_overlap(&src, &dst, ndim, itemsize):
 * 
 *         if not slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
 *             order = get_best_order(&dst, ndim)
 * 
 */
    }

    /* "View.MemoryView":1303
 *             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(4, 1303, __pyx_L1_error)
    __pyx_v_tmpdata = __pyx_t_7;

    /* "View.MemoryView":1304
 * 
 *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
 *         src = tmp             # <<<<<<<<<<<<<<
 * 
 *     if not broadcasting:
 */
    __pyx_v_src = __pyx_v_tmp;

    /* "View.MemoryView":1298
 *             _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":1306
 *         src = tmp
 * 
 *     if not broadcasting:             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1309
 * 
 * 
 *         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":1310
 * 
 *         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":1309
 * 
 * 
 *         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":1311
 *         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":1312
 *             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":1311
 *         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":1314
 *             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":1316
 *         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":1317
 * 
 *             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":1318
 *             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":1319
 *             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":1320
 *             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":1314
 *             direct_copy = slice_is_contig(dst, 'F', ndim)
 * 
 *         if direct_copy:             # <<<<<<<<<<<<<<
 * 
 *             refcount_copying(&dst, dtype_is_object, ndim, False)
 */
    }

    /* "View.MemoryView":1306
 *         src = tmp
 * 
 *     if not broadcasting:             # <<<<<<<<<<<<<<
 * 
 * 
 */
  }

  /* "View.MemoryView":1322
 *             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":1325
 * 
 * 
 *         transpose_memslice(&src)             # <<<<<<<<<<<<<<
 *         transpose_memslice(&dst)
 * 
 */
    __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(4, 1325, __pyx_L1_error)

    /* "View.MemoryView":1326
 * 
 *         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(4, 1326, __pyx_L1_error)

    /* "View.MemoryView":1322
 *             return 0
 * 
 *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
 * 
 * 
 */
  }

  /* "View.MemoryView":1328
 *         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":1329
 * 
 *     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":1330
 *     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":1332
 *     refcount_copying(&dst, dtype_is_object, ndim, True)
 * 
 *     free(tmpdata)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
  free(__pyx_v_tmpdata);

  /* "View.MemoryView":1333
 * 
 *     free(tmpdata)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_broadcast_leading')
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "View.MemoryView":1264
 * 
 * @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":1336
 * 
 * @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":1340
 *                             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":1342
 *     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":1343
 * 
 *     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":1344
 *     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":1345
 *         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":1347
 *         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":1348
 * 
 *     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":1349
 *     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":1350
 *         mslice.shape[i] = 1
 *         mslice.strides[i] = mslice.strides[0]
 *         mslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
 * 
 * 
 */
    (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L;
  }

  /* "View.MemoryView":1336
 * 
 * @cname('__pyx_memoryview_broadcast_leading')
 * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
 *                             int ndim,
 *                             int ndim_other) nogil:
 */

  /* function exit code */
}

/* "View.MemoryView":1358
 * 
 * @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":1362
 * 
 * 
 *     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":1363
 * 
 *     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":1362
 * 
 * 
 *     if dtype_is_object:             # <<<<<<<<<<<<<<
 *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
 *                                            dst.strides, ndim, inc)
 */
  }

  /* "View.MemoryView":1358
 * 
 * @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":1367
 * 
 * @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":1370
 *                                              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":1367
 * 
 * @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":1373
 * 
 * @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":1377
 *     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":1378
 * 
 *     for i in range(shape[0]):
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             if inc:
 *                 Py_INCREF((<PyObject **> data)[0])
 */
    __pyx_t_4 = ((__pyx_v_ndim == 1) != 0);
    if (__pyx_t_4) {

      /* "View.MemoryView":1379
 *     for i in range(shape[0]):
 *         if ndim == 1:
 *             if inc:             # <<<<<<<<<<<<<<
 *                 Py_INCREF((<PyObject **> data)[0])
 *             else:
 */
      __pyx_t_4 = (__pyx_v_inc != 0);
      if (__pyx_t_4) {

        /* "View.MemoryView":1380
 *         if ndim == 1:
 *             if inc:
 *                 Py_INCREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
 *             else:
 *                 Py_DECREF((<PyObject **> data)[0])
 */
        Py_INCREF((((PyObject **)__pyx_v_data)[0]));

        /* "View.MemoryView":1379
 *     for i in range(shape[0]):
 *         if ndim == 1:
 *             if inc:             # <<<<<<<<<<<<<<
 *                 Py_INCREF((<PyObject **> data)[0])
 *             else:
 */
        goto __pyx_L6;
      }

      /* "View.MemoryView":1382
 *                 Py_INCREF((<PyObject **> data)[0])
 *             else:
 *                 Py_DECREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
 *         else:
 *             refcount_objects_in_slice(data, shape + 1, strides + 1,
 */
      /*else*/ {
        Py_DECREF((((PyObject **)__pyx_v_data)[0]));
      }
      __pyx_L6:;

      /* "View.MemoryView":1378
 * 
 *     for i in range(shape[0]):
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             if inc:
 *                 Py_INCREF((<PyObject **> data)[0])
 */
      goto __pyx_L5;
    }

    /* "View.MemoryView":1384
 *                 Py_DECREF((<PyObject **> data)[0])
 *         else:
 *             refcount_objects_in_slice(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
 *                                       ndim - 1, inc)
 * 
 */
    /*else*/ {

      /* "View.MemoryView":1385
 *         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":1387
 *                                       ndim - 1, inc)
 * 
 *         data += strides[0]             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0]));
  }

  /* "View.MemoryView":1373
 * 
 * @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":1393
 * 
 * @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":1396
 *                               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":1397
 *                               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":1399
 *     _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":1393
 * 
 * @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":1403
 * 
 * @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":1407
 *                               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":1408
 *     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":1410
 *     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":1411
 * 
 *     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":1412
 *     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":1413
 *         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":1410
 *     cdef Py_ssize_t extent = shape[0]
 * 
 *     if ndim == 1:             # <<<<<<<<<<<<<<
 *         for i in range(extent):
 *             memcpy(data, item, itemsize)
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":1415
 *             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":1416
 *     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":1418
 *             _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":1403
 * 
 * @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):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xb068931:
 *         from pickle import PickleError as __pyx_PickleError
 */

/* 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)__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;
  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(4, 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(4, 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(4, 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(4, 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(4, 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 = NULL;
  PyObject *__pyx_v___pyx_result = NULL;
  PyObject *__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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Enum", 0);

  /* "(tree fragment)":2
 * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xb068931:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xb068931) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":3
 * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xb068931:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
 *     __pyx_result = Enum.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 3, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":4
 *     if __pyx_checksum != 0xb068931:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Enum.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 4, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 4, __pyx_L1_error)

    /* "(tree fragment)":2
 * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):
 *     if __pyx_checksum != 0xb068931:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":5
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
 *     __pyx_result = Enum.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_MemviewEnum_type), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v___pyx_type);
      __Pyx_GIVEREF(__pyx_v___pyx_type);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
 *     __pyx_result = Enum.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":7
 *     __pyx_result = Enum.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Enum__set_state(<Enum> __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(4, 7, __pyx_L1_error)
    __pyx_t_3 = __pyx_unpickle_Enum__set_state(((struct __pyx_MemviewEnum_obj *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 7, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
 *     __pyx_result = Enum.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":8
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Enum__set_state(<Enum> __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):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xb068931:
 *         from pickle import PickleError as __pyx_PickleError
 */

  /* 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_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)":9
 *         __pyx_unpickle_Enum__set_state(<Enum> __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;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Enum__set_state", 0);

  /* "(tree fragment)":10
 *     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(4, 10, __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(4, 10, __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)":11
 * 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(4, 11, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(4, 11, __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(4, 11, __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)":12
 *     __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(4, 12, __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(4, 12, __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(4, 12, __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(4, 12, __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);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_7)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":11
 * 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)":9
 *         __pyx_unpickle_Enum__set_state(<Enum> __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_XDECREF(__pyx_t_9);
  __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_4cupy_4core_4core_ndarray __pyx_vtable_4cupy_4core_4core_ndarray;

static PyObject *__pyx_tp_new_4cupy_4core_4core_ndarray(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *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_obj_4cupy_4core_4core_ndarray *)o);
  p->__pyx_vtab = __pyx_vtabptr_4cupy_4core_4core_ndarray;
  new((void*)&(p->_shape)) std::vector<Py_ssize_t> ();
  new((void*)&(p->_strides)) std::vector<Py_ssize_t> ();
  p->dtype = Py_None; Py_INCREF(Py_None);
  p->data = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)Py_None); Py_INCREF(Py_None);
  p->base = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core_ndarray(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *p = (struct __pyx_obj_4cupy_4core_4core_ndarray *)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);
  if (p->__weakref__) PyObject_ClearWeakRefs(o);
  __Pyx_call_destructor(p->_shape);
  __Pyx_call_destructor(p->_strides);
  Py_CLEAR(p->dtype);
  Py_CLEAR(p->data);
  Py_CLEAR(p->base);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4cupy_4core_4core_ndarray(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core_ndarray *p = (struct __pyx_obj_4cupy_4core_4core_ndarray *)o;
  if (p->dtype) {
    e = (*v)(p->dtype, a); if (e) return e;
  }
  if (p->data) {
    e = (*v)(((PyObject *)p->data), a); if (e) return e;
  }
  if (p->base) {
    e = (*v)(((PyObject *)p->base), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core_ndarray(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core_ndarray *p = (struct __pyx_obj_4cupy_4core_4core_ndarray *)o;
  tmp = ((PyObject*)p->dtype);
  p->dtype = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->data);
  p->data = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->base);
  p->base = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_4cupy_4core_4core_ndarray(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_4cupy_4core_4core_ndarray(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pw_4cupy_4core_4core_7ndarray_161__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_4cupy_4core_4core_7ndarray_flags(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_5flags_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_shape(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_5shape_1__get__(o);
}

static int __pyx_setprop_4cupy_4core_4core_7ndarray_shape(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_4core_4core_7ndarray_5shape_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_strides(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_7strides_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_ndim(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_4ndim_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_itemsize(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_8itemsize_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_nbytes(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_6nbytes_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_T(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_1T_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_cstruct(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_7cstruct_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_real(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_4real_1__get__(o);
}

static int __pyx_setprop_4cupy_4core_4core_7ndarray_real(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_4core_4core_7ndarray_4real_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_imag(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_4imag_1__get__(o);
}

static int __pyx_setprop_4cupy_4core_4core_7ndarray_imag(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_4core_4core_7ndarray_4imag_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_device(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_6device_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_4size_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray__shape(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_6_shape_1__get__(o);
}

static int __pyx_setprop_4cupy_4core_4core_7ndarray__shape(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_4core_4core_7ndarray_6_shape_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray__strides(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_8_strides_1__get__(o);
}

static int __pyx_setprop_4cupy_4core_4core_7ndarray__strides(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_4core_4core_7ndarray_8_strides_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray__c_contiguous(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_13_c_contiguous_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray__f_contiguous(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_13_f_contiguous_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_dtype(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_5dtype_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_data(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_4data_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7ndarray_base(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_4base_1__get__(o);
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_ndarray[] = {
  {"tolist", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_3tolist, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_2tolist},
  {"tofile", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_5tofile, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_4tofile},
  {"dump", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_7dump, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_6dump},
  {"dumps", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_9dumps, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_8dumps},
  {"astype", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_11astype, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_10astype},
  {"copy", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_13copy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_12copy},
  {"view", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_15view, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_14view},
  {"fill", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_17fill, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_16fill},
  {"_reshape", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_19_reshape, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_18_reshape},
  {"reshape", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_21reshape, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_20reshape},
  {"_transpose", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_23_transpose, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_22_transpose},
  {"transpose", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_25transpose, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_24transpose},
  {"swapaxes", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_27swapaxes, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_26swapaxes},
  {"flatten", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_29flatten, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_28flatten},
  {"ravel", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_31ravel, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_30ravel},
  {"squeeze", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_33squeeze, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_32squeeze},
  {"take", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_35take, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_34take},
  {"repeat", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_37repeat, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_36repeat},
  {"choose", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_39choose, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_38choose},
  {"sort", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_41sort, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_40sort},
  {"argsort", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_43argsort, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_42argsort},
  {"partition", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_45partition, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_44partition},
  {"argpartition", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_47argpartition, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_46argpartition},
  {"nonzero", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_49nonzero, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_48nonzero},
  {"diagonal", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_51diagonal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_50diagonal},
  {"max", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_53max, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_52max},
  {"argmax", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_55argmax, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_54argmax},
  {"min", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_57min, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_56min},
  {"argmin", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_59argmin, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_58argmin},
  {"clip", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_61clip, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_60clip},
  {"trace", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_63trace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_62trace},
  {"sum", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_65sum, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_64sum},
  {"mean", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_67mean, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_66mean},
  {"var", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_69var, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_68var},
  {"std", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_71std, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_70std},
  {"prod", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_73prod, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_72prod},
  {"all", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_75all, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_74all},
  {"any", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_77any, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_76any},
  {"conj", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_147conj, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_146conj},
  {"__copy__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_149__copy__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_148__copy__},
  {"__deepcopy__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_151__deepcopy__, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_150__deepcopy__},
  {"__reduce__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_153__reduce__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_152__reduce__},
  {"__array__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_155__array__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_154__array__},
  {"scatter_add", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_163scatter_add, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_162scatter_add},
  {"__complex__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_171__complex__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_170__complex__},
  {"dot", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_181dot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_180dot},
  {"get", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_183get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_182get},
  {"set", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_185set, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_184set},
  {"reduced_view", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_187reduced_view, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_186reduced_view},
  {"_update_c_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_189_update_c_contiguity, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_188_update_c_contiguity},
  {"_update_f_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_191_update_f_contiguity, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_190_update_f_contiguity},
  {"_update_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_193_update_contiguity, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_192_update_contiguity},
  {"_set_shape_and_strides", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_195_set_shape_and_strides, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_194_set_shape_and_strides},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_4core_4core_ndarray[] = {
  {(char *)"flags", __pyx_getprop_4cupy_4core_4core_7ndarray_flags, 0, (char *)"Object containing memory-layout information.\n\n        It only contains ``c_contiguous``, ``f_contiguous``, and ``owndata``\n        attributes. All of these are read-only. Accessing by indexes is also\n        supported.\n\n        .. seealso:: :attr:`numpy.ndarray.flags`\n\n        ", 0},
  {(char *)"shape", __pyx_getprop_4cupy_4core_4core_7ndarray_shape, __pyx_setprop_4cupy_4core_4core_7ndarray_shape, (char *)"Lengths of axes.\n\n        Setter of this property involves reshaping without copy. If the array\n        cannot be reshaped without copy, it raises an exception.\n\n        .. seealso: :attr:`numpy.ndarray.shape`\n\n        ", 0},
  {(char *)"strides", __pyx_getprop_4cupy_4core_4core_7ndarray_strides, 0, (char *)"Strides of axes in bytes.\n\n        .. seealso:: :attr:`numpy.ndarray.strides`\n\n        ", 0},
  {(char *)"ndim", __pyx_getprop_4cupy_4core_4core_7ndarray_ndim, 0, (char *)"Number of dimensions.\n\n        ``a.ndim`` is equivalent to ``len(a.shape)``.\n\n        .. seealso:: :attr:`numpy.ndarray.ndim`\n\n        ", 0},
  {(char *)"itemsize", __pyx_getprop_4cupy_4core_4core_7ndarray_itemsize, 0, (char *)"Size of each element in bytes.\n\n        .. seealso:: :attr:`numpy.ndarray.itemsize`\n\n        ", 0},
  {(char *)"nbytes", __pyx_getprop_4cupy_4core_4core_7ndarray_nbytes, 0, (char *)"Size of whole elements in bytes.\n\n        It does not count skips between elements.\n\n        .. seealso:: :attr:`numpy.ndarray.nbytes`\n\n        ", 0},
  {(char *)"T", __pyx_getprop_4cupy_4core_4core_7ndarray_T, 0, (char *)"Shape-reversed view of the array.\n\n        If ndim < 2, then this is just a reference to the array itself.\n\n        ", 0},
  {(char *)"cstruct", __pyx_getprop_4cupy_4core_4core_7ndarray_cstruct, 0, (char *)"C representation of the array.\n\n        This property is used for sending an array to CUDA kernels. The type of\n        returned C structure is different for different dtypes and ndims. The\n        definition of C type is written in ``cupy/carray.cuh``.\n\n        ", 0},
  {(char *)"real", __pyx_getprop_4cupy_4core_4core_7ndarray_real, __pyx_setprop_4cupy_4core_4core_7ndarray_real, (char *)0, 0},
  {(char *)"imag", __pyx_getprop_4cupy_4core_4core_7ndarray_imag, __pyx_setprop_4cupy_4core_4core_7ndarray_imag, (char *)0, 0},
  {(char *)"device", __pyx_getprop_4cupy_4core_4core_7ndarray_device, 0, (char *)"CUDA device on which this array resides.", 0},
  {(char *)"size", __pyx_getprop_4cupy_4core_4core_7ndarray_size, 0, (char *)0, 0},
  {(char *)"_shape", __pyx_getprop_4cupy_4core_4core_7ndarray__shape, __pyx_setprop_4cupy_4core_4core_7ndarray__shape, (char *)"_shape: 'vector[Py_ssize_t]'", 0},
  {(char *)"_strides", __pyx_getprop_4cupy_4core_4core_7ndarray__strides, __pyx_setprop_4cupy_4core_4core_7ndarray__strides, (char *)"_strides: 'vector[Py_ssize_t]'", 0},
  {(char *)"_c_contiguous", __pyx_getprop_4cupy_4core_4core_7ndarray__c_contiguous, 0, (char *)0, 0},
  {(char *)"_f_contiguous", __pyx_getprop_4cupy_4core_4core_7ndarray__f_contiguous, 0, (char *)0, 0},
  {(char *)"dtype", __pyx_getprop_4cupy_4core_4core_7ndarray_dtype, 0, (char *)0, 0},
  {(char *)"data", __pyx_getprop_4cupy_4core_4core_7ndarray_data, 0, (char *)0, 0},
  {(char *)"base", __pyx_getprop_4cupy_4core_4core_7ndarray_base, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ndarray = {
  __pyx_pw_4cupy_4core_4core_7ndarray_91__add__, /*nb_add*/
  __pyx_pw_4cupy_4core_4core_7ndarray_93__sub__, /*nb_subtract*/
  __pyx_pw_4cupy_4core_4core_7ndarray_95__mul__, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  __pyx_pw_4cupy_4core_4core_7ndarray_99__div__, /*nb_divide*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_105__mod__, /*nb_remainder*/
  __pyx_pw_4cupy_4core_4core_7ndarray_107__divmod__, /*nb_divmod*/
  __pyx_pw_4cupy_4core_4core_7ndarray_109__pow__, /*nb_power*/
  __pyx_pw_4cupy_4core_4core_7ndarray_83__neg__, /*nb_negative*/
  __pyx_pw_4cupy_4core_4core_7ndarray_85__pos__, /*nb_positive*/
  __pyx_pw_4cupy_4core_4core_7ndarray_87__abs__, /*nb_absolute*/
  __pyx_pw_4cupy_4core_4core_7ndarray_81__nonzero__, /*nb_nonzero*/
  __pyx_pw_4cupy_4core_4core_7ndarray_89__invert__, /*nb_invert*/
  __pyx_pw_4cupy_4core_4core_7ndarray_111__lshift__, /*nb_lshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_113__rshift__, /*nb_rshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_115__and__, /*nb_and*/
  __pyx_pw_4cupy_4core_4core_7ndarray_119__xor__, /*nb_xor*/
  __pyx_pw_4cupy_4core_4core_7ndarray_117__or__, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_165__int__, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  __pyx_pw_4cupy_4core_4core_7ndarray_167__long__, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_169__float__, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  __pyx_pw_4cupy_4core_4core_7ndarray_173__oct__, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  __pyx_pw_4cupy_4core_4core_7ndarray_175__hex__, /*nb_hex*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_121__iadd__, /*nb_inplace_add*/
  __pyx_pw_4cupy_4core_4core_7ndarray_123__isub__, /*nb_inplace_subtract*/
  __pyx_pw_4cupy_4core_4core_7ndarray_125__imul__, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  __pyx_pw_4cupy_4core_4core_7ndarray_127__idiv__, /*nb_inplace_divide*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_133__imod__, /*nb_inplace_remainder*/
  __pyx_pw_4cupy_4core_4core_7ndarray_135__ipow__, /*nb_inplace_power*/
  __pyx_pw_4cupy_4core_4core_7ndarray_137__ilshift__, /*nb_inplace_lshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_139__irshift__, /*nb_inplace_rshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_141__iand__, /*nb_inplace_and*/
  __pyx_pw_4cupy_4core_4core_7ndarray_145__ixor__, /*nb_inplace_xor*/
  __pyx_pw_4cupy_4core_4core_7ndarray_143__ior__, /*nb_inplace_or*/
  __pyx_pw_4cupy_4core_4core_7ndarray_103__floordiv__, /*nb_floor_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_101__truediv__, /*nb_true_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_131__ifloordiv__, /*nb_inplace_floor_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_129__itruediv__, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  __pyx_pw_4cupy_4core_4core_7ndarray_97__matmul__, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_ndarray = {
  __pyx_pw_4cupy_4core_4core_7ndarray_157__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_4cupy_4core_4core_ndarray, /*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_ndarray = {
  __pyx_pw_4cupy_4core_4core_7ndarray_157__len__, /*mp_length*/
  __pyx_pw_4cupy_4core_4core_7ndarray_159__getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_4cupy_4core_4core_ndarray, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_4cupy_4core_4core_ndarray = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.ndarray", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core_ndarray), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core_ndarray, /*tp_dealloc*/
  0, /*tp_print*/
  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_pw_4cupy_4core_4core_7ndarray_177__repr__, /*tp_repr*/
  &__pyx_tp_as_number_ndarray, /*tp_as_number*/
  &__pyx_tp_as_sequence_ndarray, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ndarray, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_4cupy_4core_4core_7ndarray_179__str__, /*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*/
  "ndarray(shape, dtype=float, memptr=None, order='C')\nMulti-dimensional array on a CUDA device.\n\n    This class implements a subset of methods of :class:`numpy.ndarray`.\n    The difference is that this class allocates the array content on the\n    current GPU device.\n\n    Args:\n        shape (tuple of ints): Length of axes.\n        dtype: Data type. It must be an argument of :class:`numpy.dtype`.\n        memptr (cupy.cuda.MemoryPointer): Pointer to the array content head.\n        order ({'C', 'F'}): Row-major (C-style) or column-major\n            (Fortran-style) order.\n\n    Attributes:\n        base (None or cupy.ndarray): Base array from which this array is\n            created as a view.\n        data (cupy.cuda.MemoryPointer): Pointer to the array content head.\n        ~ndarray.dtype(numpy.dtype): Dtype object of element type.\n\n            .. seealso::\n               `Data type objects (dtype)                <https://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html>`_\n        ~ndarray.size (int): Number of elements this array holds.\n\n            This is equivalent to product over the shape tuple.\n\n            .. seealso:: :attr:`numpy.ndarray.size`\n\n\n    ", /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core_ndarray, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core_ndarray, /*tp_clear*/
  __pyx_pw_4cupy_4core_4core_7ndarray_79__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_4core_4core_ndarray, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4cupy_4core_4core_ndarray, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_4core_4core_7ndarray_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core_ndarray, /*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
};
static struct __pyx_vtabstruct_4cupy_4core_4core_Indexer __pyx_vtable_4cupy_4core_4core_Indexer;

static PyObject *__pyx_tp_new_4cupy_4core_4core_Indexer(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4cupy_4core_4core_Indexer *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_obj_4cupy_4core_4core_Indexer *)o);
  p->__pyx_vtab = __pyx_vtabptr_4cupy_4core_4core_Indexer;
  p->shape = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core_Indexer(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core_Indexer *p = (struct __pyx_obj_4cupy_4core_4core_Indexer *)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->shape);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4cupy_4core_4core_Indexer(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core_Indexer *p = (struct __pyx_obj_4cupy_4core_4core_Indexer *)o;
  if (p->shape) {
    e = (*v)(p->shape, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core_Indexer(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core_Indexer *p = (struct __pyx_obj_4cupy_4core_4core_Indexer *)o;
  tmp = ((PyObject*)p->shape);
  p->shape = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7Indexer_ndim(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7Indexer_4ndim_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7Indexer_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7Indexer_4size_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_7Indexer_shape(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7Indexer_5shape_1__get__(o);
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_Indexer[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7Indexer_3__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7Indexer_2__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7Indexer_5__setstate_cython__, METH_O, __pyx_doc_4cupy_4core_4core_7Indexer_4__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_4core_4core_Indexer[] = {
  {(char *)"ndim", __pyx_getprop_4cupy_4core_4core_7Indexer_ndim, 0, (char *)0, 0},
  {(char *)"size", __pyx_getprop_4cupy_4core_4core_7Indexer_size, 0, (char *)0, 0},
  {(char *)"shape", __pyx_getprop_4cupy_4core_4core_7Indexer_shape, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_4core_4core_Indexer = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.Indexer", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core_Indexer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core_Indexer, /*tp_dealloc*/
  0, /*tp_print*/
  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*/
  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*/
  "Indexer(tuple shape)", /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core_Indexer, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core_Indexer, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_4core_4core_Indexer, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4cupy_4core_4core_Indexer, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_4core_4core_7Indexer_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core_Indexer, /*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
};

static PyObject *__pyx_tp_new_4cupy_4core_4core_CArray(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_4cupy_4cuda_8function_CPointer->tp_new(t, a, k);
  if (unlikely(!o)) return 0;
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core_CArray(PyObject *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
  if (likely(__pyx_ptype_4cupy_4cuda_8function_CPointer)) __pyx_ptype_4cupy_4cuda_8function_CPointer->tp_dealloc(o); else __Pyx_call_next_tp_dealloc(o, __pyx_tp_dealloc_4cupy_4core_4core_CArray);
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_CArray[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_6CArray_3__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_6CArray_2__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_6CArray_5__setstate_cython__, METH_O, __pyx_doc_4cupy_4core_4core_6CArray_4__setstate_cython__},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_4core_4core_CArray = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.CArray", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core_CArray), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core_CArray, /*tp_dealloc*/
  0, /*tp_print*/
  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*/
  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, /*tp_flags*/
  "CArray(ndarray arr)", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_4core_4core_CArray, /*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_pw_4cupy_4core_4core_6CArray_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core_CArray, /*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
};

static PyObject *__pyx_tp_new_4cupy_4core_4core_CIndexer(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_4cupy_4cuda_8function_CPointer->tp_new(t, a, k);
  if (unlikely(!o)) return 0;
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core_CIndexer(PyObject *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
  if (likely(__pyx_ptype_4cupy_4cuda_8function_CPointer)) __pyx_ptype_4cupy_4cuda_8function_CPointer->tp_dealloc(o); else __Pyx_call_next_tp_dealloc(o, __pyx_tp_dealloc_4cupy_4core_4core_CIndexer);
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_CIndexer[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_8CIndexer_3__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_8CIndexer_2__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_8CIndexer_5__setstate_cython__, METH_O, __pyx_doc_4cupy_4core_4core_8CIndexer_4__setstate_cython__},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_4core_4core_CIndexer = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.CIndexer", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core_CIndexer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core_CIndexer, /*tp_dealloc*/
  0, /*tp_print*/
  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*/
  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, /*tp_flags*/
  "CIndexer(Py_ssize_t size, tuple shape)", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_4core_4core_CIndexer, /*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_pw_4cupy_4core_4core_8CIndexer_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core_CIndexer, /*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
};

static PyObject *__pyx_tp_new_4cupy_4core_4core_ParameterInfo(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *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_obj_4cupy_4core_4core_ParameterInfo *)o);
  p->name = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->dtype = Py_None; Py_INCREF(Py_None);
  p->ctype = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core_ParameterInfo(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *p = (struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)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_CLEAR(p->dtype);
  Py_CLEAR(p->ctype);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4cupy_4core_4core_ParameterInfo(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *p = (struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)o;
  if (p->dtype) {
    e = (*v)(p->dtype, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core_ParameterInfo(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core_ParameterInfo *p = (struct __pyx_obj_4cupy_4core_4core_ParameterInfo *)o;
  tmp = ((PyObject*)p->dtype);
  p->dtype = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4cupy_4core_4core_13ParameterInfo_name(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_13ParameterInfo_4name_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_13ParameterInfo_dtype(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_13ParameterInfo_5dtype_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_13ParameterInfo_ctype(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_13ParameterInfo_5ctype_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_13ParameterInfo_raw(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_13ParameterInfo_3raw_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_13ParameterInfo_is_const(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_13ParameterInfo_8is_const_1__get__(o);
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_ParameterInfo[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_13ParameterInfo_3__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_13ParameterInfo_2__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_13ParameterInfo_5__setstate_cython__, METH_O, __pyx_doc_4cupy_4core_4core_13ParameterInfo_4__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_4core_4core_ParameterInfo[] = {
  {(char *)"name", __pyx_getprop_4cupy_4core_4core_13ParameterInfo_name, 0, (char *)0, 0},
  {(char *)"dtype", __pyx_getprop_4cupy_4core_4core_13ParameterInfo_dtype, 0, (char *)0, 0},
  {(char *)"ctype", __pyx_getprop_4cupy_4core_4core_13ParameterInfo_ctype, 0, (char *)0, 0},
  {(char *)"raw", __pyx_getprop_4cupy_4core_4core_13ParameterInfo_raw, 0, (char *)0, 0},
  {(char *)"is_const", __pyx_getprop_4cupy_4core_4core_13ParameterInfo_is_const, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_4core_4core_ParameterInfo = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.ParameterInfo", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core_ParameterInfo), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core_ParameterInfo, /*tp_dealloc*/
  0, /*tp_print*/
  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*/
  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*/
  "ParameterInfo(str param, bool is_const)", /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core_ParameterInfo, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core_ParameterInfo, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_4core_4core_ParameterInfo, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4cupy_4core_4core_ParameterInfo, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_4core_4core_13ParameterInfo_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core_ParameterInfo, /*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
};

static PyObject *__pyx_tp_new_4cupy_4core_4core_ElementwiseKernel(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *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_obj_4cupy_4core_4core_ElementwiseKernel *)o);
  p->in_params = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->out_params = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->params = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->operation = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->name = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->preamble = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->kwargs = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core_ElementwiseKernel(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *p = (struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)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->in_params);
  Py_CLEAR(p->out_params);
  Py_CLEAR(p->params);
  Py_CLEAR(p->operation);
  Py_CLEAR(p->name);
  Py_CLEAR(p->preamble);
  Py_CLEAR(p->kwargs);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4cupy_4core_4core_ElementwiseKernel(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *p = (struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)o;
  if (p->in_params) {
    e = (*v)(p->in_params, a); if (e) return e;
  }
  if (p->out_params) {
    e = (*v)(p->out_params, a); if (e) return e;
  }
  if (p->params) {
    e = (*v)(p->params, a); if (e) return e;
  }
  if (p->kwargs) {
    e = (*v)(p->kwargs, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core_ElementwiseKernel(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *p = (struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel *)o;
  tmp = ((PyObject*)p->in_params);
  p->in_params = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->out_params);
  p->out_params = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->params);
  p->params = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->kwargs);
  p->kwargs = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_in_params(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_9in_params_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_out_params(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_10out_params_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nin(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_3nin_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nout(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_4nout_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nargs(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_5nargs_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_params(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_6params_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_operation(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_9operation_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_name(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_4name_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_reduce_dims(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_11reduce_dims_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_preamble(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_8preamble_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_kwargs(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_6kwargs_1__get__(o);
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_ElementwiseKernel[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_5__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_17ElementwiseKernel_4__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_17ElementwiseKernel_7__setstate_cython__, METH_O, __pyx_doc_4cupy_4core_4core_17ElementwiseKernel_6__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_4core_4core_ElementwiseKernel[] = {
  {(char *)"in_params", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_in_params, 0, (char *)0, 0},
  {(char *)"out_params", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_out_params, 0, (char *)0, 0},
  {(char *)"nin", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nin, 0, (char *)0, 0},
  {(char *)"nout", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nout, 0, (char *)0, 0},
  {(char *)"nargs", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nargs, 0, (char *)0, 0},
  {(char *)"params", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_params, 0, (char *)0, 0},
  {(char *)"operation", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_operation, 0, (char *)0, 0},
  {(char *)"name", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_name, 0, (char *)0, 0},
  {(char *)"reduce_dims", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_reduce_dims, 0, (char *)0, 0},
  {(char *)"preamble", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_preamble, 0, (char *)0, 0},
  {(char *)"kwargs", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_kwargs, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_4core_4core_ElementwiseKernel = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.ElementwiseKernel", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core_ElementwiseKernel), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core_ElementwiseKernel, /*tp_dealloc*/
  0, /*tp_print*/
  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*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_3__call__, /*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*/
  "ElementwiseKernel(in_params, out_params, operation, name='kernel', reduce_dims=True, preamble='', **kwargs)\nUser-defined elementwise kernel.\n\n    This class can be used to define an elementwise kernel with or without\n    broadcasting.\n\n    The kernel is compiled at an invocation of the\n    :meth:`~ElementwiseKernel.__call__` method,\n    which is cached for each device.\n    The compiled binary is also cached into a file under the\n    ``$HOME/.cupy/kernel_cache/`` directory with a hashed file name. The cached\n    binary is reused by other processes.\n\n    Args:\n        in_params (str): Input argument list.\n        out_params (str): Output argument list.\n        operation (str): The body in the loop written in CUDA-C/C++.\n        name (str): Name of the kernel function. It should be set for\n            readability of the performance profiling.\n        reduce_dims (bool): If ``False``, the shapes of array arguments are\n            kept within the kernel invocation. The shapes are reduced\n            (i.e., the arrays are reshaped without copy to the minimum\n            dimension) by default. It may make the kernel fast by reducing the\n            index calculations.\n        options (list): Options passed to the ``nvcc`` command.\n        preamble (str): Fragment of the CUDA-C/C++ code that is inserted at the\n            top of the cu file.\n        loop_prep (str): Fragment of the CUDA-C/C++ code that is inserted at\n            the top of the kernel function definition and above the ``for``\n            loop.\n        after_loop (str): Fragment of the CUDA-C/C++ code that is inserted at\n            the bottom of the kernel function definition.\n\n    ", /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core_ElementwiseKernel, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core_ElementwiseKernel, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_4core_4core_ElementwiseKernel, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4cupy_4core_4core_ElementwiseKernel, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_4core_4core_17ElementwiseKernel_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core_ElementwiseKernel, /*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
};

static PyObject *__pyx_tp_new_4cupy_4core_4core_broadcast(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4cupy_4core_4core_broadcast *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_obj_4cupy_4core_4core_broadcast *)o);
  p->values = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->shape = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core_broadcast(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core_broadcast *p = (struct __pyx_obj_4cupy_4core_4core_broadcast *)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->values);
  Py_CLEAR(p->shape);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4cupy_4core_4core_broadcast(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core_broadcast *p = (struct __pyx_obj_4cupy_4core_4core_broadcast *)o;
  if (p->values) {
    e = (*v)(p->values, a); if (e) return e;
  }
  if (p->shape) {
    e = (*v)(p->shape, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core_broadcast(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core_broadcast *p = (struct __pyx_obj_4cupy_4core_4core_broadcast *)o;
  tmp = ((PyObject*)p->values);
  p->values = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->shape);
  p->shape = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4cupy_4core_4core_9broadcast_values(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_9broadcast_6values_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_9broadcast_shape(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_9broadcast_5shape_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_9broadcast_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_9broadcast_4size_1__get__(o);
}

static PyObject *__pyx_getprop_4cupy_4core_4core_9broadcast_nd(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_9broadcast_2nd_1__get__(o);
}

static PyMethodDef __pyx_methods_4cupy_4core_4core_broadcast[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_9broadcast_3__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_9broadcast_2__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_4core_4core_9broadcast_5__setstate_cython__, METH_O, __pyx_doc_4cupy_4core_4core_9broadcast_4__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_4core_4core_broadcast[] = {
  {(char *)"values", __pyx_getprop_4cupy_4core_4core_9broadcast_values, 0, (char *)0, 0},
  {(char *)"shape", __pyx_getprop_4cupy_4core_4core_9broadcast_shape, 0, (char *)0, 0},
  {(char *)"size", __pyx_getprop_4cupy_4core_4core_9broadcast_size, 0, (char *)0, 0},
  {(char *)"nd", __pyx_getprop_4cupy_4core_4core_9broadcast_nd, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_4core_4core_broadcast = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.broadcast", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core_broadcast), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core_broadcast, /*tp_dealloc*/
  0, /*tp_print*/
  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*/
  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*/
  "broadcast(*arrays)\nObject that performs broadcasting.\n\n    CuPy actually uses this class to support broadcasting in various\n    operations. Note that this class does not provide an iterator.\n\n    Args:\n        arrays (tuple of arrays): Arrays to be broadcasted.\n\n    Attributes:\n        ~broadcast.shape (tuple of ints): The broadcasted shape.\n        nd (int): Number of dimensions of the broadcasted shape.\n        ~broadcast.size (int): Total size of the broadcasted shape.\n        values (list of arrays): The broadcasted arrays.\n\n    .. seealso:: :class:`numpy.broadcast`\n\n    ", /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core_broadcast, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core_broadcast, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_4core_4core_broadcast, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4cupy_4core_4core_broadcast, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_4core_4core_9broadcast_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core_broadcast, /*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
};

static struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_types);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *)o;
  if (p->__pyx_v_types) {
    e = (*v)(p->__pyx_v_types, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel *)o;
  tmp = ((PyObject*)p->__pyx_v_types);
  p->__pyx_v_types = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.__pyx_scope_struct___get_elementwise_kernel", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel, /*tp_dealloc*/
  0, /*tp_print*/
  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*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel, /*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
};

static struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_1_genexpr[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct_1_genexpr = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_1_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_1_genexpr[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_1_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_1_genexpr(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_k);
  Py_CLEAR(p->__pyx_v_v);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_1_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct_1_genexpr[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_1_genexpr++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_k) {
    e = (*v)(p->__pyx_v_k, a); if (e) return e;
  }
  if (p->__pyx_v_v) {
    e = (*v)(p->__pyx_v_v, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_4cupy_4core_4core___pyx_scope_struct_1_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.__pyx_scope_struct_1_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_1_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  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*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_1_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_1_genexpr, /*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
};

static struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_2___init__[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct_2___init__ = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_2___init__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_2___init__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_2___init__[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_2___init__];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_2___init__(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_nin);
  Py_CLEAR(p->__pyx_v_nout);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_2___init__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct_2___init__[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_2___init__++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_2___init__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *)o;
  if (p->__pyx_v_nin) {
    e = (*v)(p->__pyx_v_nin, a); if (e) return e;
  }
  if (p->__pyx_v_nout) {
    e = (*v)(p->__pyx_v_nout, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_2___init__(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__ *)o;
  tmp = ((PyObject*)p->__pyx_v_nin);
  p->__pyx_v_nin = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_nout);
  p->__pyx_v_nout = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4cupy_4core_4core___pyx_scope_struct_2___init__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.__pyx_scope_struct_2___init__", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_2___init__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_2___init__, /*tp_dealloc*/
  0, /*tp_print*/
  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*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_2___init__, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_2___init__, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_2___init__, /*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
};

static struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_3_genexpr[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct_3_genexpr = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_3_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_3_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_3_genexpr[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_3_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_3_genexpr(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_i);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_3_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct_3_genexpr[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_3_genexpr++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_3_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_i) {
    e = (*v)(p->__pyx_v_i, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_4cupy_4core_4core___pyx_scope_struct_3_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.__pyx_scope_struct_3_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_3_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_3_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  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*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_3_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_3_genexpr, /*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
};

static struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_4_genexpr[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct_4_genexpr = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_4_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_4_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_4_genexpr[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_4_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_4_genexpr(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_i);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_4_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct_4_genexpr[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_4_genexpr++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_4_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_i) {
    e = (*v)(p->__pyx_v_i, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_4cupy_4core_4core___pyx_scope_struct_4_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.__pyx_scope_struct_4_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_4_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_4_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  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*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_4_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_4_genexpr, /*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
};

static struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_types);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *)o;
  if (p->__pyx_v_types) {
    e = (*v)(p->__pyx_v_types, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel *)o;
  tmp = ((PyObject*)p->__pyx_v_types);
  p->__pyx_v_types = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.__pyx_scope_struct_5__get_reduction_kernel", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel, /*tp_dealloc*/
  0, /*tp_print*/
  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*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel, /*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
};

static struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_6_genexpr[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct_6_genexpr = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_6_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_6_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct_6_genexpr[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_6_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_6_genexpr(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_k);
  Py_CLEAR(p->__pyx_v_v);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_6_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct_6_genexpr[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct_6_genexpr++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_6_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_k) {
    e = (*v)(p->__pyx_v_k, a); if (e) return e;
  }
  if (p->__pyx_v_v) {
    e = (*v)(p->__pyx_v_v, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_4cupy_4core_4core___pyx_scope_struct_6_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.__pyx_scope_struct_6_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_6_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct_6_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  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*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct_6_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_4core_4core___pyx_scope_struct_6_genexpr, /*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
};
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);
    ++Py_REFCNT(o);
    __pyx_array___dealloc__(o);
    --Py_REFCNT(o);
    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)
  "cupy.core.core.array", /*tp_name*/
  sizeof(struct __pyx_array_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_array, /*tp_dealloc*/
  0, /*tp_print*/
  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
};

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)
  "cupy.core.core.Enum", /*tp_name*/
  sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_Enum, /*tp_dealloc*/
  0, /*tp_print*/
  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
};
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);
    ++Py_REFCNT(o);
    __pyx_memoryview___dealloc__(o);
    --Py_REFCNT(o);
    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)
  "cupy.core.core.memoryview", /*tp_name*/
  sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_memoryview, /*tp_dealloc*/
  0, /*tp_print*/
  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
};
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);
    ++Py_REFCNT(o);
    __pyx_memoryviewslice___dealloc__(o);
    --Py_REFCNT(o);
    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)
  "cupy.core.core._memoryviewslice", /*tp_name*/
  sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/
  0, /*tp_print*/
  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
};

static PyMethodDef __pyx_methods[] = {
  {"_get_strides_for_nocopy_reshape", (PyCFunction)__pyx_pw_4cupy_4core_4core_1_get_strides_for_nocopy_reshape, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core__get_strides_for_nocopy_reshape},
  {"_get_header_dir_path", (PyCFunction)__pyx_pw_4cupy_4core_4core_3_get_header_dir_path, METH_NOARGS, __pyx_doc_4cupy_4core_4core_2_get_header_dir_path},
  {"_get_header_source", (PyCFunction)__pyx_pw_4cupy_4core_4core_5_get_header_source, METH_NOARGS, __pyx_doc_4cupy_4core_4core_4_get_header_source},
  {"compile_with_cache", (PyCFunction)__pyx_pw_4cupy_4core_4core_7compile_with_cache, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_6compile_with_cache},
  {"_get_simple_elementwise_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_9_get_simple_elementwise_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_8_get_simple_elementwise_kernel},
  {"_python_scalar_to_numpy_scalar", (PyCFunction)__pyx_pw_4cupy_4core_4core_11_python_scalar_to_numpy_scalar, METH_O, __pyx_doc_4cupy_4core_4core_10_python_scalar_to_numpy_scalar},
  {"_get_typename", (PyCFunction)__pyx_pw_4cupy_4core_4core_13_get_typename, METH_O, __pyx_doc_4cupy_4core_4core_12_get_typename},
  {"_preprocess_args", (PyCFunction)__pyx_pw_4cupy_4core_4core_15_preprocess_args, METH_O, __pyx_doc_4cupy_4core_4core_14_preprocess_args},
  {"_get_args_info", (PyCFunction)__pyx_pw_4cupy_4core_4core_17_get_args_info, METH_O, __pyx_doc_4cupy_4core_4core_16_get_args_info},
  {"_get_kernel_params", (PyCFunction)__pyx_pw_4cupy_4core_4core_19_get_kernel_params, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_18_get_kernel_params},
  {"_reduce_dims", (PyCFunction)__pyx_pw_4cupy_4core_4core_21_reduce_dims, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_20_reduce_dims},
  {"create_ufunc", (PyCFunction)__pyx_pw_4cupy_4core_4core_31create_ufunc, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_30create_ufunc},
  {"_get_simple_reduction_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_33_get_simple_reduction_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_32_get_simple_reduction_kernel},
  {"_get_axis", (PyCFunction)__pyx_pw_4cupy_4core_4core_35_get_axis, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_34_get_axis},
  {"_get_out_shape", (PyCFunction)__pyx_pw_4cupy_4core_4core_37_get_out_shape, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_36_get_out_shape},
  {"_get_trans_args", (PyCFunction)__pyx_pw_4cupy_4core_4core_39_get_trans_args, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_38_get_trans_args},
  {"_get_inout_args", (PyCFunction)__pyx_pw_4cupy_4core_4core_41_get_inout_args, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_40_get_inout_args},
  {"create_reduction_func", (PyCFunction)__pyx_pw_4cupy_4core_4core_47create_reduction_func, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_46create_reduction_func},
  {"array", (PyCFunction)__pyx_pw_4cupy_4core_4core_49array, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_48array},
  {"ascontiguousarray", (PyCFunction)__pyx_pw_4cupy_4core_4core_51ascontiguousarray, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_50ascontiguousarray},
  {"asfortranarray", (PyCFunction)__pyx_pw_4cupy_4core_4core_53asfortranarray, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_52asfortranarray},
  {"normalize_axis_tuple", (PyCFunction)__pyx_pw_4cupy_4core_4core_57normalize_axis_tuple, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_56normalize_axis_tuple},
  {"moveaxis", (PyCFunction)__pyx_pw_4cupy_4core_4core_59moveaxis, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_58moveaxis},
  {"rollaxis", (PyCFunction)__pyx_pw_4cupy_4core_4core_61rollaxis, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_60rollaxis},
  {"broadcast_to", (PyCFunction)__pyx_pw_4cupy_4core_4core_65broadcast_to, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_64broadcast_to},
  {"_repeat", (PyCFunction)__pyx_pw_4cupy_4core_4core_67_repeat, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_66_repeat},
  {"concatenate_method", (PyCFunction)__pyx_pw_4cupy_4core_4core_69concatenate_method, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_68concatenate_method},
  {"_concatenate", (PyCFunction)__pyx_pw_4cupy_4core_4core_71_concatenate, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_70_concatenate},
  {"_concatenate_single_kernel", (PyCFunction)__pyx_pw_4cupy_4core_4core_73_concatenate_single_kernel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_72_concatenate_single_kernel},
  {"size", (PyCFunction)__pyx_pw_4cupy_4core_4core_75size, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_74size},
  {"_create_bit_op", (PyCFunction)__pyx_pw_4cupy_4core_4core_77_create_bit_op, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_76_create_bit_op},
  {"_prepare_slice_list", (PyCFunction)__pyx_pw_4cupy_4core_4core_79_prepare_slice_list, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_78_prepare_slice_list},
  {"_prepare_mask_indexing_single", (PyCFunction)__pyx_pw_4cupy_4core_4core_81_prepare_mask_indexing_single, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_80_prepare_mask_indexing_single},
  {"_getitem_mask_single", (PyCFunction)__pyx_pw_4cupy_4core_4core_83_getitem_mask_single, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_82_getitem_mask_single},
  {"_take", (PyCFunction)__pyx_pw_4cupy_4core_4core_85_take, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_84_take},
  {"_scatter_op_single", (PyCFunction)__pyx_pw_4cupy_4core_4core_87_scatter_op_single, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_86_scatter_op_single},
  {"_scatter_op_mask_single", (PyCFunction)__pyx_pw_4cupy_4core_4core_89_scatter_op_mask_single, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_88_scatter_op_mask_single},
  {"_scatter_op", (PyCFunction)__pyx_pw_4cupy_4core_4core_91_scatter_op, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_90_scatter_op},
  {"_diagonal", (PyCFunction)__pyx_pw_4cupy_4core_4core_93_diagonal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_92_diagonal},
  {"_prepare_multiple_array_indexing", (PyCFunction)__pyx_pw_4cupy_4core_4core_95_prepare_multiple_array_indexing, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_94_prepare_multiple_array_indexing},
  {"_getitem_multiple", (PyCFunction)__pyx_pw_4cupy_4core_4core_97_getitem_multiple, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_96_getitem_multiple},
  {"dot", (PyCFunction)__pyx_pw_4cupy_4core_4core_99dot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_98dot},
  {"_get_all_addresses", (PyCFunction)__pyx_pw_4cupy_4core_4core_101_get_all_addresses, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_100_get_all_addresses},
  {"_get_stride_for_strided_batched_gemm", (PyCFunction)__pyx_pw_4cupy_4core_4core_103_get_stride_for_strided_batched_gemm, METH_O, __pyx_doc_4cupy_4core_4core_102_get_stride_for_strided_batched_gemm},
  {"matmul", (PyCFunction)__pyx_pw_4cupy_4core_4core_105matmul, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_104matmul},
  {"tensordot_core", (PyCFunction)__pyx_pw_4cupy_4core_4core_107tensordot_core, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_106tensordot_core},
  {"_mat_to_cublas_contiguous", (PyCFunction)__pyx_pw_4cupy_4core_4core_109_mat_to_cublas_contiguous, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_108_mat_to_cublas_contiguous},
  {"_to_cublas_vector", (PyCFunction)__pyx_pw_4cupy_4core_4core_111_to_cublas_vector, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_110_to_cublas_vector},
  {"create_comparison", (PyCFunction)__pyx_pw_4cupy_4core_4core_113create_comparison, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_112create_comparison},
  {"_var", (PyCFunction)__pyx_pw_4cupy_4core_4core_115_var, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_114_var},
  {"_std", (PyCFunction)__pyx_pw_4cupy_4core_4core_117_std, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_116_std},
  {"scan", (PyCFunction)__pyx_pw_4cupy_4core_4core_127scan, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_126scan},
  {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_core(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_core},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "core",
    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

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_0, __pyx_k_0, sizeof(__pyx_k_0), 0, 0, 1, 0},
  {&__pyx_kp_s_0_1__raw__1__i, __pyx_k_0_1__raw__1__i, sizeof(__pyx_k_0_1__raw__1__i), 0, 0, 1, 0},
  {&__pyx_n_s_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 1, 1},
  {&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1},
  {&__pyx_kp_s_Adds_two_arrays_elementwise_seea, __pyx_k_Adds_two_arrays_elementwise_seea, sizeof(__pyx_k_Adds_two_arrays_elementwise_seea), 0, 0, 1, 0},
  {&__pyx_kp_s_All_arrays_must_have_same_shape, __pyx_k_All_arrays_must_have_same_shape, sizeof(__pyx_k_All_arrays_must_have_same_shape), 0, 0, 1, 0},
  {&__pyx_kp_s_All_arrays_to_concatenate_must_h, __pyx_k_All_arrays_to_concatenate_must_h, sizeof(__pyx_k_All_arrays_to_concatenate_must_h), 0, 0, 1, 0},
  {&__pyx_kp_s_Array_device_must_be_same_as_the, __pyx_k_Array_device_must_be_same_as_the, sizeof(__pyx_k_Array_device_must_be_same_as_the), 0, 0, 1, 0},
  {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
  {&__pyx_kp_s_Axes_overrun, __pyx_k_Axes_overrun, sizeof(__pyx_k_Axes_overrun), 0, 0, 1, 0},
  {&__pyx_n_s_AxisError, __pyx_k_AxisError, sizeof(__pyx_k_AxisError), 0, 0, 1, 1},
  {&__pyx_n_s_AxisError_2, __pyx_k_AxisError_2, sizeof(__pyx_k_AxisError_2), 0, 0, 1, 1},
  {&__pyx_kp_s_Axis_dimension_mismatch, __pyx_k_Axis_dimension_mismatch, sizeof(__pyx_k_Axis_dimension_mismatch), 0, 0, 1, 0},
  {&__pyx_kp_s_Axis_exceeds_ndim, __pyx_k_Axis_exceeds_ndim, sizeof(__pyx_k_Axis_exceeds_ndim), 0, 0, 1, 0},
  {&__pyx_kp_s_Axis_out_of_range, __pyx_k_Axis_out_of_range, sizeof(__pyx_k_Axis_out_of_range), 0, 0, 1, 0},
  {&__pyx_kp_s_Axis_overrun, __pyx_k_Axis_overrun, sizeof(__pyx_k_Axis_overrun), 0, 0, 1, 0},
  {&__pyx_kp_s_B, __pyx_k_B, sizeof(__pyx_k_B), 0, 0, 1, 0},
  {&__pyx_kp_s_BB, __pyx_k_BB, sizeof(__pyx_k_BB), 0, 0, 1, 0},
  {&__pyx_kp_s_BBB_B, __pyx_k_BBB_B, sizeof(__pyx_k_BBB_B), 0, 0, 1, 0},
  {&__pyx_kp_s_BB_B, __pyx_k_BB_B, sizeof(__pyx_k_BB_B), 0, 0, 1, 0},
  {&__pyx_kp_s_BB_BB, __pyx_k_BB_BB, sizeof(__pyx_k_BB_BB), 0, 0, 1, 0},
  {&__pyx_kp_s_BB_d, __pyx_k_BB_d, sizeof(__pyx_k_BB_d), 0, 0, 1, 0},
  {&__pyx_kp_s_B_B, __pyx_k_B_B, sizeof(__pyx_k_B_B), 0, 0, 1, 0},
  {&__pyx_kp_s_B_B_2, __pyx_k_B_B_2, sizeof(__pyx_k_B_B_2), 0, 0, 1, 0},
  {&__pyx_kp_s_B_L, __pyx_k_B_L, sizeof(__pyx_k_B_L), 0, 0, 1, 0},
  {&__pyx_kp_s_B_d, __pyx_k_B_d, sizeof(__pyx_k_B_d), 0, 0, 1, 0},
  {&__pyx_kp_s_B_q, __pyx_k_B_q, sizeof(__pyx_k_B_q), 0, 0, 1, 0},
  {&__pyx_kp_s_Broadcasting_failed, __pyx_k_Broadcasting_failed, sizeof(__pyx_k_Broadcasting_failed), 0, 0, 1, 0},
  {&__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_s_C, __pyx_k_C, sizeof(__pyx_k_C), 0, 0, 1, 1},
  {&__pyx_kp_s_CArray_s_d, __pyx_k_CArray_s_d, sizeof(__pyx_k_CArray_s_d), 0, 0, 1, 0},
  {&__pyx_n_s_CIndexer, __pyx_k_CIndexer, sizeof(__pyx_k_CIndexer), 0, 0, 1, 1},
  {&__pyx_kp_s_CIndexer__in_ind_CIndexer__out_i, __pyx_k_CIndexer__in_ind_CIndexer__out_i, sizeof(__pyx_k_CIndexer__in_ind_CIndexer__out_i), 0, 0, 1, 0},
  {&__pyx_kp_s_CIndexer__ind, __pyx_k_CIndexer__ind, sizeof(__pyx_k_CIndexer__ind), 0, 0, 1, 0},
  {&__pyx_kp_s_CIndexer_d, __pyx_k_CIndexer_d, sizeof(__pyx_k_CIndexer_d), 0, 0, 1, 0},
  {&__pyx_kp_s_Can_not_use_i_as_a_parameter_nam, __pyx_k_Can_not_use_i_as_a_parameter_nam, sizeof(__pyx_k_Can_not_use_i_as_a_parameter_nam), 0, 0, 1, 0},
  {&__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_concatenate_from_empty_tu, __pyx_k_Cannot_concatenate_from_empty_tu, sizeof(__pyx_k_Cannot_concatenate_from_empty_tu), 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_kp_s_Cannot_set_to_non_contiguous_arr, __pyx_k_Cannot_set_to_non_contiguous_arr, sizeof(__pyx_k_Cannot_set_to_non_contiguous_arr), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_specify_out_as_both_a_pos, __pyx_k_Cannot_specify_out_as_both_a_pos, sizeof(__pyx_k_Cannot_specify_out_as_both_a_pos), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_use_out_in_s, __pyx_k_Cannot_use_out_in_s, sizeof(__pyx_k_Cannot_use_out_in_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Casting_complex_values_to_real_d, __pyx_k_Casting_complex_values_to_real_d, sizeof(__pyx_k_Casting_complex_values_to_real_d), 0, 0, 1, 0},
  {&__pyx_kp_s_Changing_the_dtype_of_a_0d_array, __pyx_k_Changing_the_dtype_of_a_0d_array, sizeof(__pyx_k_Changing_the_dtype_of_a_0d_array), 0, 0, 1, 0},
  {&__pyx_n_s_ComplexWarning, __pyx_k_ComplexWarning, sizeof(__pyx_k_ComplexWarning), 0, 0, 1, 1},
  {&__pyx_kp_s_Computes_the_bitwise_AND_of_two, __pyx_k_Computes_the_bitwise_AND_of_two, sizeof(__pyx_k_Computes_the_bitwise_AND_of_two), 0, 0, 1, 0},
  {&__pyx_kp_s_Computes_the_bitwise_NOT_of_an_a, __pyx_k_Computes_the_bitwise_NOT_of_an_a, sizeof(__pyx_k_Computes_the_bitwise_NOT_of_an_a), 0, 0, 1, 0},
  {&__pyx_kp_s_Computes_the_bitwise_OR_of_two_a, __pyx_k_Computes_the_bitwise_OR_of_two_a, sizeof(__pyx_k_Computes_the_bitwise_OR_of_two_a), 0, 0, 1, 0},
  {&__pyx_kp_s_Computes_the_bitwise_XOR_of_two, __pyx_k_Computes_the_bitwise_XOR_of_two, sizeof(__pyx_k_Computes_the_bitwise_XOR_of_two), 0, 0, 1, 0},
  {&__pyx_kp_s_Computes_the_remainder_of_Python, __pyx_k_Computes_the_remainder_of_Python, sizeof(__pyx_k_Computes_the_remainder_of_Python), 0, 0, 1, 0},
  {&__pyx_kp_s_Computes_x1_x2_elementwise_seeal, __pyx_k_Computes_x1_x2_elementwise_seeal, sizeof(__pyx_k_Computes_x1_x2_elementwise_seeal), 0, 0, 1, 0},
  {&__pyx_n_s_D, __pyx_k_D, sizeof(__pyx_k_D), 0, 0, 1, 1},
  {&__pyx_kp_s_DD, __pyx_k_DD, sizeof(__pyx_k_DD), 0, 0, 1, 0},
  {&__pyx_kp_s_DD_D, __pyx_k_DD_D, sizeof(__pyx_k_DD_D), 0, 0, 1, 0},
  {&__pyx_kp_s_D_2, __pyx_k_D_2, sizeof(__pyx_k_D_2), 0, 0, 1, 0},
  {&__pyx_kp_s_D_D, __pyx_k_D_D, sizeof(__pyx_k_D_D), 0, 0, 1, 0},
  {&__pyx_kp_s_D_D_2, __pyx_k_D_D_2, sizeof(__pyx_k_D_D_2), 0, 0, 1, 0},
  {&__pyx_kp_s_D_d, __pyx_k_D_d, sizeof(__pyx_k_D_d), 0, 0, 1, 0},
  {&__pyx_n_s_Device, __pyx_k_Device, sizeof(__pyx_k_Device), 0, 0, 1, 1},
  {&__pyx_kp_s_Divides_arguments_elementwise_se, __pyx_k_Divides_arguments_elementwise_se, sizeof(__pyx_k_Divides_arguments_elementwise_se), 0, 0, 1, 0},
  {&__pyx_kp_s_Elementwise_absolute_value_funct, __pyx_k_Elementwise_absolute_value_funct, sizeof(__pyx_k_Elementwise_absolute_value_funct), 0, 0, 1, 0},
  {&__pyx_kp_s_Elementwise_floor_division_i_e_i, __pyx_k_Elementwise_floor_division_i_e_i, sizeof(__pyx_k_Elementwise_floor_division_i_e_i), 0, 0, 1, 0},
  {&__pyx_kp_s_Elementwise_true_division_i_e_di, __pyx_k_Elementwise_true_division_i_e_di, sizeof(__pyx_k_Elementwise_true_division_i_e_di), 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_n_s_F, __pyx_k_F, sizeof(__pyx_k_F), 0, 0, 1, 1},
  {&__pyx_kp_s_FF, __pyx_k_FF, sizeof(__pyx_k_FF), 0, 0, 1, 0},
  {&__pyx_kp_s_FF_F, __pyx_k_FF_F, sizeof(__pyx_k_FF_F), 0, 0, 1, 0},
  {&__pyx_kp_s_F_2, __pyx_k_F_2, sizeof(__pyx_k_F_2), 0, 0, 1, 0},
  {&__pyx_kp_s_F_F, __pyx_k_F_F, sizeof(__pyx_k_F_F), 0, 0, 1, 0},
  {&__pyx_kp_s_F_F_2, __pyx_k_F_F_2, sizeof(__pyx_k_F_F_2), 0, 0, 1, 0},
  {&__pyx_kp_s_F_f, __pyx_k_F_f, sizeof(__pyx_k_F_f), 0, 0, 1, 0},
  {&__pyx_n_s_Flags, __pyx_k_Flags, sizeof(__pyx_k_Flags), 0, 0, 1, 1},
  {&__pyx_kp_s_H, __pyx_k_H, sizeof(__pyx_k_H), 0, 0, 1, 0},
  {&__pyx_kp_s_HH, __pyx_k_HH, sizeof(__pyx_k_HH), 0, 0, 1, 0},
  {&__pyx_kp_s_HHH_H, __pyx_k_HHH_H, sizeof(__pyx_k_HHH_H), 0, 0, 1, 0},
  {&__pyx_kp_s_HH_H, __pyx_k_HH_H, sizeof(__pyx_k_HH_H), 0, 0, 1, 0},
  {&__pyx_kp_s_HH_HH, __pyx_k_HH_HH, sizeof(__pyx_k_HH_HH), 0, 0, 1, 0},
  {&__pyx_kp_s_HH_d, __pyx_k_HH_d, sizeof(__pyx_k_HH_d), 0, 0, 1, 0},
  {&__pyx_kp_s_H_H, __pyx_k_H_H, sizeof(__pyx_k_H_H), 0, 0, 1, 0},
  {&__pyx_kp_s_H_H_2, __pyx_k_H_H_2, sizeof(__pyx_k_H_H_2), 0, 0, 1, 0},
  {&__pyx_kp_s_H_L, __pyx_k_H_L, sizeof(__pyx_k_H_L), 0, 0, 1, 0},
  {&__pyx_kp_s_H_d, __pyx_k_H_d, sizeof(__pyx_k_H_d), 0, 0, 1, 0},
  {&__pyx_kp_s_H_q, __pyx_k_H_q, sizeof(__pyx_k_H_q), 0, 0, 1, 0},
  {&__pyx_kp_s_I, __pyx_k_I, sizeof(__pyx_k_I), 0, 0, 1, 0},
  {&__pyx_kp_s_II, __pyx_k_II, sizeof(__pyx_k_II), 0, 0, 1, 0},
  {&__pyx_kp_s_III_I, __pyx_k_III_I, sizeof(__pyx_k_III_I), 0, 0, 1, 0},
  {&__pyx_kp_s_II_I, __pyx_k_II_I, sizeof(__pyx_k_II_I), 0, 0, 1, 0},
  {&__pyx_kp_s_II_II, __pyx_k_II_II, sizeof(__pyx_k_II_II), 0, 0, 1, 0},
  {&__pyx_kp_s_II_d, __pyx_k_II_d, sizeof(__pyx_k_II_d), 0, 0, 1, 0},
  {&__pyx_kp_s_I_2, __pyx_k_I_2, sizeof(__pyx_k_I_2), 0, 0, 1, 0},
  {&__pyx_kp_s_I_I, __pyx_k_I_I, sizeof(__pyx_k_I_I), 0, 0, 1, 0},
  {&__pyx_kp_s_I_I_2, __pyx_k_I_I_2, sizeof(__pyx_k_I_I_2), 0, 0, 1, 0},
  {&__pyx_kp_s_I_L, __pyx_k_I_L, sizeof(__pyx_k_I_L), 0, 0, 1, 0},
  {&__pyx_kp_s_I_d, __pyx_k_I_d, sizeof(__pyx_k_I_d), 0, 0, 1, 0},
  {&__pyx_kp_s_I_q, __pyx_k_I_q, sizeof(__pyx_k_I_q), 0, 0, 1, 0},
  {&__pyx_kp_s_I_s, __pyx_k_I_s, sizeof(__pyx_k_I_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Illegal_conditions, __pyx_k_Illegal_conditions, sizeof(__pyx_k_Illegal_conditions), 0, 0, 1, 0},
  {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x05, __pyx_k_Incompatible_checksums_s_vs_0x05, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x05), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x6d, __pyx_k_Incompatible_checksums_s_vs_0x6d, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x6d), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x73, __pyx_k_Incompatible_checksums_s_vs_0x73, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x73), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x7d, __pyx_k_Incompatible_checksums_s_vs_0x7d, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x7d), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_k_Incompatible_checksums_s_vs_0xb0, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xb0), 0, 0, 1, 0},
  {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
  {&__pyx_n_s_IndexOrValueError, __pyx_k_IndexOrValueError, sizeof(__pyx_k_IndexOrValueError), 0, 0, 1, 1},
  {&__pyx_n_s_IndexOrValueError___init, __pyx_k_IndexOrValueError___init, sizeof(__pyx_k_IndexOrValueError___init), 0, 0, 1, 1},
  {&__pyx_kp_s_Index_s_is_out_of_bounds_for_axi, __pyx_k_Index_s_is_out_of_bounds_for_axi, sizeof(__pyx_k_Index_s_is_out_of_bounds_for_axi), 0, 0, 1, 0},
  {&__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_Input_array_should_be_1D_array, __pyx_k_Input_array_should_be_1D_array, sizeof(__pyx_k_Input_array_should_be_1D_array), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_axes_value_s, __pyx_k_Invalid_axes_value_s, sizeof(__pyx_k_Invalid_axes_value_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_dtype_s, __pyx_k_Invalid_dtype_s, sizeof(__pyx_k_Invalid_dtype_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_index_type_s, __pyx_k_Invalid_index_type_s, sizeof(__pyx_k_Invalid_index_type_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_kernel_name_s, __pyx_k_Invalid_kernel_name_s, sizeof(__pyx_k_Invalid_kernel_name_s), 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_K, __pyx_k_K, sizeof(__pyx_k_K), 0, 0, 1, 1},
  {&__pyx_kp_s_L, __pyx_k_L, sizeof(__pyx_k_L), 0, 0, 1, 0},
  {&__pyx_kp_s_LL, __pyx_k_LL, sizeof(__pyx_k_LL), 0, 0, 1, 0},
  {&__pyx_kp_s_LLL_L, __pyx_k_LLL_L, sizeof(__pyx_k_LLL_L), 0, 0, 1, 0},
  {&__pyx_kp_s_LL_L, __pyx_k_LL_L, sizeof(__pyx_k_LL_L), 0, 0, 1, 0},
  {&__pyx_kp_s_LL_LL, __pyx_k_LL_LL, sizeof(__pyx_k_LL_LL), 0, 0, 1, 0},
  {&__pyx_kp_s_LL_d, __pyx_k_LL_d, sizeof(__pyx_k_LL_d), 0, 0, 1, 0},
  {&__pyx_kp_s_L_L, __pyx_k_L_L, sizeof(__pyx_k_L_L), 0, 0, 1, 0},
  {&__pyx_kp_s_L_L_2, __pyx_k_L_L_2, sizeof(__pyx_k_L_L_2), 0, 0, 1, 0},
  {&__pyx_kp_s_L_d, __pyx_k_L_d, sizeof(__pyx_k_L_d), 0, 0, 1, 0},
  {&__pyx_kp_s_L_q, __pyx_k_L_q, sizeof(__pyx_k_L_q), 0, 0, 1, 0},
  {&__pyx_kp_s_Loop_size_is_Undecided, __pyx_k_Loop_size_is_Undecided, sizeof(__pyx_k_Loop_size_is_Undecided), 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_kp_s_Multiplies_two_arrays_elementwis, __pyx_k_Multiplies_two_arrays_elementwis, sizeof(__pyx_k_Multiplies_two_arrays_elementwis), 0, 0, 1, 0},
  {&__pyx_kp_s_Negative_dimensions_are_not_allo, __pyx_k_Negative_dimensions_are_not_allo, sizeof(__pyx_k_Negative_dimensions_are_not_allo), 0, 0, 1, 0},
  {&__pyx_n_s_NotImplemented, __pyx_k_NotImplemented, sizeof(__pyx_k_NotImplemented), 0, 0, 1, 1},
  {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
  {&__pyx_kp_s_Not_supported_dtype_combination, __pyx_k_Not_supported_dtype_combination, sizeof(__pyx_k_Not_supported_dtype_combination), 0, 0, 1, 0},
  {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1},
  {&__pyx_kp_s_Only_cupy_arrays_can_be_concaten, __pyx_k_Only_cupy_arrays_can_be_concaten, sizeof(__pyx_k_Only_cupy_arrays_can_be_concaten), 0, 0, 1, 0},
  {&__pyx_kp_s_Only_numpy_ndarray_can_be_set_to, __pyx_k_Only_numpy_ndarray_can_be_set_to, sizeof(__pyx_k_Only_numpy_ndarray_can_be_set_to), 0, 0, 1, 0},
  {&__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_kp_s_Out_shape_is_mismatched, __pyx_k_Out_shape_is_mismatched, sizeof(__pyx_k_Out_shape_is_mismatched), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_arguments_must_be_cupy_nd, __pyx_k_Output_arguments_must_be_cupy_nd, sizeof(__pyx_k_Output_arguments_must_be_cupy_nd), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_arguments_type_must_be_cu, __pyx_k_Output_arguments_type_must_be_cu, sizeof(__pyx_k_Output_arguments_type_must_be_cu), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_array_has_an_invalid_size, __pyx_k_Output_array_has_an_invalid_size, sizeof(__pyx_k_Output_array_has_an_invalid_size), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_array_must_be_C_contiguou, __pyx_k_Output_array_must_be_C_contiguou, sizeof(__pyx_k_Output_array_must_be_C_contiguou), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_array_size_is_Undecided, __pyx_k_Output_array_size_is_Undecided, sizeof(__pyx_k_Output_array_size_is_Undecided), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_dtype_mismatch, __pyx_k_Output_dtype_mismatch, sizeof(__pyx_k_Output_dtype_mismatch), 0, 0, 1, 0},
  {&__pyx_kp_s_Output_shape_mismatch, __pyx_k_Output_shape_mismatch, sizeof(__pyx_k_Output_shape_mismatch), 0, 0, 1, 0},
  {&__pyx_n_s_PY3, __pyx_k_PY3, sizeof(__pyx_k_PY3), 0, 0, 1, 1},
  {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
  {&__pyx_kp_s_Please_set_the_CUDA_path, __pyx_k_Please_set_the_CUDA_path, sizeof(__pyx_k_Please_set_the_CUDA_path), 0, 0, 1, 0},
  {&__pyx_kp_s_Provided_out_is_the_wrong_size, __pyx_k_Provided_out_is_the_wrong_size, sizeof(__pyx_k_Provided_out_is_the_wrong_size), 0, 0, 1, 0},
  {&__pyx_kp_s_Q, __pyx_k_Q, sizeof(__pyx_k_Q), 0, 0, 1, 0},
  {&__pyx_kp_s_QQ, __pyx_k_QQ, sizeof(__pyx_k_QQ), 0, 0, 1, 0},
  {&__pyx_kp_s_QQQ_Q, __pyx_k_QQQ_Q, sizeof(__pyx_k_QQQ_Q), 0, 0, 1, 0},
  {&__pyx_kp_s_QQ_Q, __pyx_k_QQ_Q, sizeof(__pyx_k_QQ_Q), 0, 0, 1, 0},
  {&__pyx_kp_s_QQ_QQ, __pyx_k_QQ_QQ, sizeof(__pyx_k_QQ_QQ), 0, 0, 1, 0},
  {&__pyx_kp_s_QQ_d, __pyx_k_QQ_d, sizeof(__pyx_k_QQ_d), 0, 0, 1, 0},
  {&__pyx_kp_s_Q_Q, __pyx_k_Q_Q, sizeof(__pyx_k_Q_Q), 0, 0, 1, 0},
  {&__pyx_kp_s_Q_Q_2, __pyx_k_Q_Q_2, sizeof(__pyx_k_Q_Q_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Q_d, __pyx_k_Q_d, sizeof(__pyx_k_Q_d), 0, 0, 1, 0},
  {&__pyx_kp_s_Q_q, __pyx_k_Q_q, sizeof(__pyx_k_Q_q), 0, 0, 1, 0},
  {&__pyx_n_s_ReductionKernel, __pyx_k_ReductionKernel, sizeof(__pyx_k_ReductionKernel), 0, 0, 1, 1},
  {&__pyx_n_s_ReductionKernel___call, __pyx_k_ReductionKernel___call, sizeof(__pyx_k_ReductionKernel___call), 0, 0, 1, 1},
  {&__pyx_n_s_ReductionKernel___init, __pyx_k_ReductionKernel___init, sizeof(__pyx_k_ReductionKernel___init), 0, 0, 1, 1},
  {&__pyx_kp_s_Returns_the_angle_of_the_complex, __pyx_k_Returns_the_angle_of_the_complex, sizeof(__pyx_k_Returns_the_angle_of_the_complex), 0, 0, 1, 0},
  {&__pyx_kp_s_Returns_the_complex_conjugate_el, __pyx_k_Returns_the_complex_conjugate_el, sizeof(__pyx_k_Returns_the_complex_conjugate_el), 0, 0, 1, 0},
  {&__pyx_kp_s_Returns_the_imaginary_part_of_th, __pyx_k_Returns_the_imaginary_part_of_th, sizeof(__pyx_k_Returns_the_imaginary_part_of_th), 0, 0, 1, 0},
  {&__pyx_kp_s_Returns_the_real_part_of_the_ele, __pyx_k_Returns_the_real_part_of_the_ele, sizeof(__pyx_k_Returns_the_real_part_of_the_ele), 0, 0, 1, 0},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_kp_s_S_a_raw_T_choices_int32_n_channe, __pyx_k_S_a_raw_T_choices_int32_n_channe, sizeof(__pyx_k_S_a_raw_T_choices_int32_n_channe), 0, 0, 1, 0},
  {&__pyx_kp_s_S_a_raw_T_choices_int32_n_channe_2, __pyx_k_S_a_raw_T_choices_int32_n_channe_2, sizeof(__pyx_k_S_a_raw_T_choices_int32_n_channe_2), 0, 0, 1, 0},
  {&__pyx_kp_s_S_wrap_indices_indices_adim_if, __pyx_k_S_wrap_indices_indices_adim_if, sizeof(__pyx_k_S_wrap_indices_indices_adim_if), 0, 0, 1, 0},
  {&__pyx_kp_s_S_wrap_indices_indices_adim_if_2, __pyx_k_S_wrap_indices_indices_adim_if_2, sizeof(__pyx_k_S_wrap_indices_indices_adim_if_2), 0, 0, 1, 0},
  {&__pyx_kp_s_S_wrap_indices_indices_index_ra, __pyx_k_S_wrap_indices_indices_index_ra, sizeof(__pyx_k_S_wrap_indices_indices_index_ra), 0, 0, 1, 0},
  {&__pyx_kp_s_S_wrap_indices_indices_index_ra_2, __pyx_k_S_wrap_indices_indices_index_ra_2, sizeof(__pyx_k_S_wrap_indices_indices_index_ra_2), 0, 0, 1, 0},
  {&__pyx_kp_s_S_x_T_mean_T_alpha, __pyx_k_S_x_T_mean_T_alpha, sizeof(__pyx_k_S_x_T_mean_T_alpha), 0, 0, 1, 0},
  {&__pyx_kp_s_S_x_T_y, __pyx_k_S_x_T_y, sizeof(__pyx_k_S_x_T_y), 0, 0, 1, 0},
  {&__pyx_kp_s_S_x_a_if_a_0_x_0_else_if_a_n_x, __pyx_k_S_x_a_if_a_0_x_0_else_if_a_n_x, sizeof(__pyx_k_S_x_a_if_a_0_x_0_else_if_a_n_x), 0, 0, 1, 0},
  {&__pyx_kp_s_Scalar_operands_are_not_allowed, __pyx_k_Scalar_operands_are_not_allowed, sizeof(__pyx_k_Scalar_operands_are_not_allowed), 0, 0, 1, 0},
  {&__pyx_n_s_Sequence, __pyx_k_Sequence, sizeof(__pyx_k_Sequence), 0, 0, 1, 1},
  {&__pyx_kp_s_Sets_the_imaginary_part_of_the_e, __pyx_k_Sets_the_imaginary_part_of_the_e, sizeof(__pyx_k_Sets_the_imaginary_part_of_the_e), 0, 0, 1, 0},
  {&__pyx_kp_s_Sets_the_real_part_of_the_elemen, __pyx_k_Sets_the_real_part_of_the_elemen, sizeof(__pyx_k_Sets_the_real_part_of_the_elemen), 0, 0, 1, 0},
  {&__pyx_kp_s_Shape_mismatch_Old_shape_new_sha, __pyx_k_Shape_mismatch_Old_shape_new_sha, sizeof(__pyx_k_Shape_mismatch_Old_shape_new_sha), 0, 0, 1, 0},
  {&__pyx_kp_s_Shifts_the_bits_of_each_integer, __pyx_k_Shifts_the_bits_of_each_integer, sizeof(__pyx_k_Shifts_the_bits_of_each_integer), 0, 0, 1, 0},
  {&__pyx_kp_s_Shifts_the_bits_of_each_integer_2, __pyx_k_Shifts_the_bits_of_each_integer_2, sizeof(__pyx_k_Shifts_the_bits_of_each_integer_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Sorting_arrays_with_dtype_is_not, __pyx_k_Sorting_arrays_with_dtype_is_not, sizeof(__pyx_k_Sorting_arrays_with_dtype_is_not), 0, 0, 1, 0},
  {&__pyx_kp_s_Sorting_arrays_with_the_rank_of, __pyx_k_Sorting_arrays_with_the_rank_of, sizeof(__pyx_k_Sorting_arrays_with_the_rank_of), 0, 0, 1, 0},
  {&__pyx_kp_s_Sorting_non_contiguous_array_is, __pyx_k_Sorting_non_contiguous_array_is, sizeof(__pyx_k_Sorting_non_contiguous_array_is), 0, 0, 1, 0},
  {&__pyx_kp_s_Specified_size_can_be_used_only, __pyx_k_Specified_size_can_be_used_only, sizeof(__pyx_k_Specified_size_can_be_used_only), 0, 0, 1, 0},
  {&__pyx_kp_s_Subtracts_arguments_elementwise, __pyx_k_Subtracts_arguments_elementwise, sizeof(__pyx_k_Subtracts_arguments_elementwise), 0, 0, 1, 0},
  {&__pyx_kp_s_Syntax_error_s, __pyx_k_Syntax_error_s, sizeof(__pyx_k_Syntax_error_s), 0, 0, 1, 0},
  {&__pyx_kp_s_T_a, __pyx_k_T_a, sizeof(__pyx_k_T_a), 0, 0, 1, 0},
  {&__pyx_kp_s_T_a_bool_mask_S_mask_scanned, __pyx_k_T_a_bool_mask_S_mask_scanned, sizeof(__pyx_k_T_a_bool_mask_S_mask_scanned), 0, 0, 1, 0},
  {&__pyx_kp_s_T_in0, __pyx_k_T_in0, sizeof(__pyx_k_T_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_T_in_d, __pyx_k_T_in_d, sizeof(__pyx_k_T_in_d), 0, 0, 1, 0},
  {&__pyx_kp_s_T_out, __pyx_k_T_out, sizeof(__pyx_k_T_out), 0, 0, 1, 0},
  {&__pyx_kp_s_T_out0, __pyx_k_T_out0, sizeof(__pyx_k_T_out0), 0, 0, 1, 0},
  {&__pyx_kp_s_T_out_d, __pyx_k_T_out_d, sizeof(__pyx_k_T_out_d), 0, 0, 1, 0},
  {&__pyx_kp_s_T_v_S_indices_int32_cdim_int32_r, __pyx_k_T_v_S_indices_int32_cdim_int32_r, sizeof(__pyx_k_T_v_S_indices_int32_cdim_int32_r), 0, 0, 1, 0},
  {&__pyx_kp_s_T_y, __pyx_k_T_y, sizeof(__pyx_k_T_y), 0, 0, 1, 0},
  {&__pyx_kp_s_Takes_numerical_negative_element, __pyx_k_Takes_numerical_negative_element, sizeof(__pyx_k_Takes_numerical_negative_element), 0, 0, 1, 0},
  {&__pyx_n_s_Template, __pyx_k_Template, sizeof(__pyx_k_Template), 0, 0, 1, 1},
  {&__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal, __pyx_k_Tests_elementwise_if_x1_x2_seeal, sizeof(__pyx_k_Tests_elementwise_if_x1_x2_seeal), 0, 0, 1, 0},
  {&__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_2, __pyx_k_Tests_elementwise_if_x1_x2_seeal_2, sizeof(__pyx_k_Tests_elementwise_if_x1_x2_seeal_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_3, __pyx_k_Tests_elementwise_if_x1_x2_seeal_3, sizeof(__pyx_k_Tests_elementwise_if_x1_x2_seeal_3), 0, 0, 1, 0},
  {&__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_4, __pyx_k_Tests_elementwise_if_x1_x2_seeal_4, sizeof(__pyx_k_Tests_elementwise_if_x1_x2_seeal_4), 0, 0, 1, 0},
  {&__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_5, __pyx_k_Tests_elementwise_if_x1_x2_seeal_5, sizeof(__pyx_k_Tests_elementwise_if_x1_x2_seeal_5), 0, 0, 1, 0},
  {&__pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_6, __pyx_k_Tests_elementwise_if_x1_x2_seeal_6, sizeof(__pyx_k_Tests_elementwise_if_x1_x2_seeal_6), 0, 0, 1, 0},
  {&__pyx_kp_s_The_out_array_as_input_is_curren, __pyx_k_The_out_array_as_input_is_curren, sizeof(__pyx_k_The_out_array_as_input_is_curren), 0, 0, 1, 0},
  {&__pyx_kp_s_The_truth_value_of_an_array_with, __pyx_k_The_truth_value_of_an_array_with, sizeof(__pyx_k_The_truth_value_of_an_array_with), 0, 0, 1, 0},
  {&__pyx_kp_s_Thrust_is_needed_to_use_cupy_arg, __pyx_k_Thrust_is_needed_to_use_cupy_arg, sizeof(__pyx_k_Thrust_is_needed_to_use_cupy_arg), 0, 0, 1, 0},
  {&__pyx_kp_s_Thrust_is_needed_to_use_cupy_sor, __pyx_k_Thrust_is_needed_to_use_cupy_sor, sizeof(__pyx_k_Thrust_is_needed_to_use_cupy_sor), 0, 0, 1, 0},
  {&__pyx_kp_s_To_change_to_a_dtype_of_a_differ, __pyx_k_To_change_to_a_dtype_of_a_differ, sizeof(__pyx_k_To_change_to_a_dtype_of_a_differ), 0, 0, 1, 0},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_kp_s_Type_is_mismatched_s_s_s, __pyx_k_Type_is_mismatched_s_s_s, sizeof(__pyx_k_Type_is_mismatched_s_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Type_is_mismatched_s_s_s_s, __pyx_k_Type_is_mismatched_s_s_s_s, sizeof(__pyx_k_Type_is_mismatched_s_s_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_U_out, __pyx_k_U_out, sizeof(__pyx_k_U_out), 0, 0, 1, 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_kp_s_Universal_function_Attributes_uf, __pyx_k_Universal_function_Attributes_uf, sizeof(__pyx_k_Universal_function_Attributes_uf), 0, 0, 1, 0},
  {&__pyx_kp_s_Unknown_keyword_s, __pyx_k_Unknown_keyword_s, sizeof(__pyx_k_Unknown_keyword_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Unsupported_dtype_s, __pyx_k_Unsupported_dtype_s, sizeof(__pyx_k_Unsupported_dtype_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Unsupported_type_s, __pyx_k_Unsupported_type_s, sizeof(__pyx_k_Unsupported_type_s), 0, 0, 1, 0},
  {&__pyx_kp_s_User_defined_reduction_kernel_Th, __pyx_k_User_defined_reduction_kernel_Th, sizeof(__pyx_k_User_defined_reduction_kernel_Th), 0, 0, 1, 0},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_kp_s_Variance_for_complex_numbers_is, __pyx_k_Variance_for_complex_numbers_is, sizeof(__pyx_k_Variance_for_complex_numbers_is), 0, 0, 1, 0},
  {&__pyx_n_s_View_MemoryView, __pyx_k_View_MemoryView, sizeof(__pyx_k_View_MemoryView), 0, 0, 1, 1},
  {&__pyx_kp_s_Wrong_arguments_s, __pyx_k_Wrong_arguments_s, sizeof(__pyx_k_Wrong_arguments_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Wrong_number_of_arguments_for_s, __pyx_k_Wrong_number_of_arguments_for_s, sizeof(__pyx_k_Wrong_number_of_arguments_for_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Wrong_type_s, __pyx_k_Wrong_type_s, sizeof(__pyx_k_Wrong_type_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Wrong_type_s_of_arguments_for_s, __pyx_k_Wrong_type_s_of_arguments_for_s, sizeof(__pyx_k_Wrong_type_s_of_arguments_for_s), 0, 0, 1, 0},
  {&__pyx_kp_s__105, __pyx_k__105, sizeof(__pyx_k__105), 0, 0, 1, 0},
  {&__pyx_n_s__227, __pyx_k__227, sizeof(__pyx_k__227), 0, 0, 1, 1},
  {&__pyx_kp_s__247, __pyx_k__247, sizeof(__pyx_k__247), 0, 0, 1, 0},
  {&__pyx_kp_s__294, __pyx_k__294, sizeof(__pyx_k__294), 0, 0, 1, 0},
  {&__pyx_kp_s__295, __pyx_k__295, sizeof(__pyx_k__295), 0, 0, 1, 0},
  {&__pyx_kp_s__296, __pyx_k__296, sizeof(__pyx_k__296), 0, 0, 1, 0},
  {&__pyx_kp_s__300, __pyx_k__300, sizeof(__pyx_k__300), 0, 0, 1, 0},
  {&__pyx_kp_s__301, __pyx_k__301, sizeof(__pyx_k__301), 0, 0, 1, 0},
  {&__pyx_kp_s__312, __pyx_k__312, sizeof(__pyx_k__312), 0, 0, 1, 0},
  {&__pyx_kp_s__313, __pyx_k__313, sizeof(__pyx_k__313), 0, 0, 1, 0},
  {&__pyx_kp_s__314, __pyx_k__314, sizeof(__pyx_k__314), 0, 0, 1, 0},
  {&__pyx_kp_s__315, __pyx_k__315, sizeof(__pyx_k__315), 0, 0, 1, 0},
  {&__pyx_kp_s__316, __pyx_k__316, sizeof(__pyx_k__316), 0, 0, 1, 0},
  {&__pyx_kp_s__317, __pyx_k__317, sizeof(__pyx_k__317), 0, 0, 1, 0},
  {&__pyx_kp_s__338, __pyx_k__338, sizeof(__pyx_k__338), 0, 0, 1, 0},
  {&__pyx_kp_s__362, __pyx_k__362, sizeof(__pyx_k__362), 0, 0, 1, 0},
  {&__pyx_kp_s__377, __pyx_k__377, sizeof(__pyx_k__377), 0, 0, 1, 0},
  {&__pyx_kp_s__401, __pyx_k__401, sizeof(__pyx_k__401), 0, 0, 1, 0},
  {&__pyx_kp_s__53, __pyx_k__53, sizeof(__pyx_k__53), 0, 0, 1, 0},
  {&__pyx_kp_s__56, __pyx_k__56, sizeof(__pyx_k__56), 0, 0, 1, 0},
  {&__pyx_kp_s__57, __pyx_k__57, sizeof(__pyx_k__57), 0, 0, 1, 0},
  {&__pyx_kp_s__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 0, 1, 0},
  {&__pyx_kp_s__71, __pyx_k__71, sizeof(__pyx_k__71), 0, 0, 1, 0},
  {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
  {&__pyx_kp_s_a_b, __pyx_k_a_b, sizeof(__pyx_k_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_a_b_2, __pyx_k_a_b_2, sizeof(__pyx_k_a_b_2), 0, 0, 1, 0},
  {&__pyx_kp_s_a_b_3, __pyx_k_a_b_3, sizeof(__pyx_k_a_b_3), 0, 0, 1, 0},
  {&__pyx_kp_s_a_b_4, __pyx_k_a_b_4, sizeof(__pyx_k_a_b_4), 0, 0, 1, 0},
  {&__pyx_n_s_a_max, __pyx_k_a_max, sizeof(__pyx_k_a_max), 0, 0, 1, 1},
  {&__pyx_n_s_a_min, __pyx_k_a_min, sizeof(__pyx_k_a_min), 0, 0, 1, 1},
  {&__pyx_n_s_a_shape, __pyx_k_a_shape, sizeof(__pyx_k_a_shape), 0, 0, 1, 1},
  {&__pyx_n_s_absolute, __pyx_k_absolute, sizeof(__pyx_k_absolute), 0, 0, 1, 1},
  {&__pyx_n_s_abspath, __pyx_k_abspath, sizeof(__pyx_k_abspath), 0, 0, 1, 1},
  {&__pyx_n_s_add, __pyx_k_add, sizeof(__pyx_k_add), 0, 0, 1, 1},
  {&__pyx_n_s_add_scan_blocked_sum_kernel, __pyx_k_add_scan_blocked_sum_kernel, sizeof(__pyx_k_add_scan_blocked_sum_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_add_scan_blocked_sum_kernel_2, __pyx_k_add_scan_blocked_sum_kernel_2, sizeof(__pyx_k_add_scan_blocked_sum_kernel_2), 0, 0, 1, 1},
  {&__pyx_n_s_after_loop, __pyx_k_after_loop, sizeof(__pyx_k_after_loop), 0, 0, 1, 1},
  {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
  {&__pyx_n_s_all_2, __pyx_k_all_2, sizeof(__pyx_k_all_2), 0, 0, 1, 1},
  {&__pyx_kp_s_all_elements_of_repeats_should_n, __pyx_k_all_elements_of_repeats_should_n, sizeof(__pyx_k_all_elements_of_repeats_should_n), 0, 0, 1, 0},
  {&__pyx_n_s_all_type_chars, __pyx_k_all_type_chars, sizeof(__pyx_k_all_type_chars), 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_amax, __pyx_k_amax, sizeof(__pyx_k_amax), 0, 0, 1, 1},
  {&__pyx_n_s_amin, __pyx_k_amin, sizeof(__pyx_k_amin), 0, 0, 1, 1},
  {&__pyx_n_s_angle, __pyx_k_angle, sizeof(__pyx_k_angle), 0, 0, 1, 1},
  {&__pyx_n_s_any, __pyx_k_any, sizeof(__pyx_k_any), 0, 0, 1, 1},
  {&__pyx_n_s_any_2, __pyx_k_any_2, sizeof(__pyx_k_any_2), 0, 0, 1, 1},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  {&__pyx_n_s_arange, __pyx_k_arange, sizeof(__pyx_k_arange), 0, 0, 1, 1},
  {&__pyx_n_s_arch, __pyx_k_arch, sizeof(__pyx_k_arch), 0, 0, 1, 1},
  {&__pyx_n_s_argmax, __pyx_k_argmax, sizeof(__pyx_k_argmax), 0, 0, 1, 1},
  {&__pyx_n_s_argmin, __pyx_k_argmin, sizeof(__pyx_k_argmin), 0, 0, 1, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_n_s_args_info, __pyx_k_args_info, sizeof(__pyx_k_args_info), 0, 0, 1, 1},
  {&__pyx_n_s_argsort, __pyx_k_argsort, sizeof(__pyx_k_argsort), 0, 0, 1, 1},
  {&__pyx_n_s_arr, __pyx_k_arr, sizeof(__pyx_k_arr), 0, 0, 1, 1},
  {&__pyx_n_s_array, __pyx_k_array, sizeof(__pyx_k_array), 0, 0, 1, 1},
  {&__pyx_kp_s_array_cannot_be_set_to_array, __pyx_k_array_cannot_be_set_to_array, sizeof(__pyx_k_array_cannot_be_set_to_array), 0, 0, 1, 0},
  {&__pyx_kp_s_array_clip_must_set_either_max_o, __pyx_k_array_clip_must_set_either_max_o, sizeof(__pyx_k_array_clip_must_set_either_max_o), 0, 0, 1, 0},
  {&__pyx_n_s_array_priority, __pyx_k_array_priority, sizeof(__pyx_k_array_priority), 0, 0, 1, 1},
  {&__pyx_n_s_array_split, __pyx_k_array_split, sizeof(__pyx_k_array_split), 0, 0, 1, 1},
  {&__pyx_n_s_arrays, __pyx_k_arrays, sizeof(__pyx_k_arrays), 0, 0, 1, 1},
  {&__pyx_kp_s_arrays_used_as_indices_must_be_o, __pyx_k_arrays_used_as_indices_must_be_o, sizeof(__pyx_k_arrays_used_as_indices_must_be_o), 0, 0, 1, 0},
  {&__pyx_n_s_ary, __pyx_k_ary, sizeof(__pyx_k_ary), 0, 0, 1, 1},
  {&__pyx_n_s_ascontiguousarray, __pyx_k_ascontiguousarray, sizeof(__pyx_k_ascontiguousarray), 0, 0, 1, 1},
  {&__pyx_n_s_asfortranarray, __pyx_k_asfortranarray, sizeof(__pyx_k_asfortranarray), 0, 0, 1, 1},
  {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1},
  {&__pyx_n_s_axis, __pyx_k_axis, sizeof(__pyx_k_axis), 0, 0, 1, 1},
  {&__pyx_n_s_axis1, __pyx_k_axis1, sizeof(__pyx_k_axis1), 0, 0, 1, 1},
  {&__pyx_kp_s_axis1_0_and_axis2_1_must_be_with, __pyx_k_axis1_0_and_axis2_1_must_be_with, sizeof(__pyx_k_axis1_0_and_axis2_1_must_be_with), 0, 0, 1, 0},
  {&__pyx_n_s_axis2, __pyx_k_axis2, sizeof(__pyx_k_axis2), 0, 0, 1, 1},
  {&__pyx_kp_s_axis_entry_d_is_out_of_bounds_d, __pyx_k_axis_entry_d_is_out_of_bounds_d, sizeof(__pyx_k_axis_entry_d_is_out_of_bounds_d), 0, 0, 1, 0},
  {&__pyx_kp_s_axis_is_out_of_bounds_for_array, __pyx_k_axis_is_out_of_bounds_for_array, sizeof(__pyx_k_axis_is_out_of_bounds_for_array), 0, 0, 1, 0},
  {&__pyx_kp_s_axis_out_of_bounds_0, __pyx_k_axis_out_of_bounds_0, sizeof(__pyx_k_axis_out_of_bounds_0), 0, 0, 1, 0},
  {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
  {&__pyx_kp_s_b_2, __pyx_k_b_2, sizeof(__pyx_k_b_2), 0, 0, 1, 0},
  {&__pyx_kp_s_b_b, __pyx_k_b_b, sizeof(__pyx_k_b_b), 0, 0, 1, 0},
  {&__pyx_kp_s_b_b_2, __pyx_k_b_b_2, sizeof(__pyx_k_b_b_2), 0, 0, 1, 0},
  {&__pyx_kp_s_b_l, __pyx_k_b_l, sizeof(__pyx_k_b_l), 0, 0, 1, 0},
  {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
  {&__pyx_kp_s_bb, __pyx_k_bb, sizeof(__pyx_k_bb), 0, 0, 1, 0},
  {&__pyx_kp_s_bb_b, __pyx_k_bb_b, sizeof(__pyx_k_bb_b), 0, 0, 1, 0},
  {&__pyx_kp_s_bb_bb, __pyx_k_bb_bb, sizeof(__pyx_k_bb_bb), 0, 0, 1, 0},
  {&__pyx_kp_s_bb_d, __pyx_k_bb_d, sizeof(__pyx_k_bb_d), 0, 0, 1, 0},
  {&__pyx_kp_s_bbb_b, __pyx_k_bbb_b, sizeof(__pyx_k_bbb_b), 0, 0, 1, 0},
  {&__pyx_kp_s_bhilqBHILQefdFD, __pyx_k_bhilqBHILQefdFD, sizeof(__pyx_k_bhilqBHILQefdFD), 0, 0, 1, 0},
  {&__pyx_n_s_bit_length, __pyx_k_bit_length, sizeof(__pyx_k_bit_length), 0, 0, 1, 1},
  {&__pyx_n_s_bitwise_and, __pyx_k_bitwise_and, sizeof(__pyx_k_bitwise_and), 0, 0, 1, 1},
  {&__pyx_n_s_bitwise_or, __pyx_k_bitwise_or, sizeof(__pyx_k_bitwise_or), 0, 0, 1, 1},
  {&__pyx_n_s_bitwise_xor, __pyx_k_bitwise_xor, sizeof(__pyx_k_bitwise_xor), 0, 0, 1, 1},
  {&__pyx_n_s_biu, __pyx_k_biu, sizeof(__pyx_k_biu), 0, 0, 1, 1},
  {&__pyx_n_s_block, __pyx_k_block, sizeof(__pyx_k_block), 0, 0, 1, 1},
  {&__pyx_n_s_block_size, __pyx_k_block_size, sizeof(__pyx_k_block_size), 0, 0, 1, 1},
  {&__pyx_n_s_block_size_2, __pyx_k_block_size_2, sizeof(__pyx_k_block_size_2), 0, 0, 1, 1},
  {&__pyx_n_s_block_stride, __pyx_k_block_stride, sizeof(__pyx_k_block_stride), 0, 0, 1, 1},
  {&__pyx_n_s_bool, __pyx_k_bool, sizeof(__pyx_k_bool), 0, 0, 1, 1},
  {&__pyx_n_s_bool_2, __pyx_k_bool_2, sizeof(__pyx_k_bool_2), 0, 0, 1, 1},
  {&__pyx_n_s_broad, __pyx_k_broad, sizeof(__pyx_k_broad), 0, 0, 1, 1},
  {&__pyx_n_s_broad_shape, __pyx_k_broad_shape, sizeof(__pyx_k_broad_shape), 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_cPickle, __pyx_k_cPickle, sizeof(__pyx_k_cPickle), 0, 0, 1, 1},
  {&__pyx_n_s_c_contiguous, __pyx_k_c_contiguous, sizeof(__pyx_k_c_contiguous), 0, 0, 1, 1},
  {&__pyx_n_s_cachd_dir, __pyx_k_cachd_dir, sizeof(__pyx_k_cachd_dir), 0, 0, 1, 1},
  {&__pyx_n_s_call, __pyx_k_call, sizeof(__pyx_k_call), 0, 0, 1, 1},
  {&__pyx_n_s_can_cast, __pyx_k_can_cast, sizeof(__pyx_k_can_cast), 0, 0, 1, 1},
  {&__pyx_kp_s_cannot_select_an_axis_to_squeeze, __pyx_k_cannot_select_an_axis_to_squeeze, sizeof(__pyx_k_cannot_select_an_axis_to_squeeze), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_specify_out_as_both_a_pos, __pyx_k_cannot_specify_out_as_both_a_pos, sizeof(__pyx_k_cannot_specify_out_as_both_a_pos), 0, 0, 1, 0},
  {&__pyx_n_s_casting, __pyx_k_casting, sizeof(__pyx_k_casting), 0, 0, 1, 1},
  {&__pyx_kp_s_casting_is_not_supported_yet, __pyx_k_casting_is_not_supported_yet, sizeof(__pyx_k_casting_is_not_supported_yet), 0, 0, 1, 0},
  {&__pyx_n_s_cgemmBatched, __pyx_k_cgemmBatched, sizeof(__pyx_k_cgemmBatched), 0, 0, 1, 1},
  {&__pyx_n_s_cgemmStridedBatched, __pyx_k_cgemmStridedBatched, sizeof(__pyx_k_cgemmStridedBatched), 0, 0, 1, 1},
  {&__pyx_n_s_char, __pyx_k_char, sizeof(__pyx_k_char), 0, 0, 1, 1},
  {&__pyx_n_s_choices, __pyx_k_choices, sizeof(__pyx_k_choices), 0, 0, 1, 1},
  {&__pyx_n_s_choose, __pyx_k_choose, sizeof(__pyx_k_choose), 0, 0, 1, 1},
  {&__pyx_n_s_chr, __pyx_k_chr, sizeof(__pyx_k_chr), 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_clip, __pyx_k_clip, sizeof(__pyx_k_clip), 0, 0, 1, 1},
  {&__pyx_n_s_clip_2, __pyx_k_clip_2, sizeof(__pyx_k_clip_2), 0, 0, 1, 1},
  {&__pyx_kp_s_clipmode_not_understood, __pyx_k_clipmode_not_understood, sizeof(__pyx_k_clipmode_not_understood), 0, 0, 1, 0},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_clp2_count, __pyx_k_clp2_count, sizeof(__pyx_k_clp2_count), 0, 0, 1, 1},
  {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1},
  {&__pyx_n_s_compile_with_cache, __pyx_k_compile_with_cache, sizeof(__pyx_k_compile_with_cache), 0, 0, 1, 1},
  {&__pyx_n_s_compiler, __pyx_k_compiler, sizeof(__pyx_k_compiler), 0, 0, 1, 1},
  {&__pyx_n_s_complex128, __pyx_k_complex128, sizeof(__pyx_k_complex128), 0, 0, 1, 1},
  {&__pyx_n_s_complex64, __pyx_k_complex64, sizeof(__pyx_k_complex64), 0, 0, 1, 1},
  {&__pyx_kp_s_complex_double, __pyx_k_complex_double, sizeof(__pyx_k_complex_double), 0, 0, 1, 0},
  {&__pyx_kp_s_complex_float, __pyx_k_complex_float, sizeof(__pyx_k_complex_float), 0, 0, 1, 0},
  {&__pyx_n_s_complexfloating, __pyx_k_complexfloating, sizeof(__pyx_k_complexfloating), 0, 0, 1, 1},
  {&__pyx_n_s_conj, __pyx_k_conj, sizeof(__pyx_k_conj), 0, 0, 1, 1},
  {&__pyx_kp_s_const_0_1__raw__1__j, __pyx_k_const_0_1__raw__1__j, sizeof(__pyx_k_const_0_1__raw__1__j), 0, 0, 1, 0},
  {&__pyx_kp_s_const_in_0__type_in_0__raw_in_0, __pyx_k_const_in_0__type_in_0__raw_in_0, sizeof(__pyx_k_const_in_0__type_in_0__raw_in_0), 0, 0, 1, 0},
  {&__pyx_kp_s_const_type_in0_raw_in0__raw_in0, __pyx_k_const_type_in0_raw_in0__raw_in0, sizeof(__pyx_k_const_type_in0_raw_in0__raw_in0), 0, 0, 1, 0},
  {&__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_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1},
  {&__pyx_n_s_create_ufunc, __pyx_k_create_ufunc, sizeof(__pyx_k_create_ufunc), 0, 0, 1, 1},
  {&__pyx_n_s_ctype, __pyx_k_ctype, sizeof(__pyx_k_ctype), 0, 0, 1, 1},
  {&__pyx_n_s_ctypes, __pyx_k_ctypes, sizeof(__pyx_k_ctypes), 0, 0, 1, 1},
  {&__pyx_n_s_cublas, __pyx_k_cublas, sizeof(__pyx_k_cublas), 0, 0, 1, 1},
  {&__pyx_n_s_cublas_handle, __pyx_k_cublas_handle, sizeof(__pyx_k_cublas_handle), 0, 0, 1, 1},
  {&__pyx_n_s_cuda, __pyx_k_cuda, sizeof(__pyx_k_cuda), 0, 0, 1, 1},
  {&__pyx_n_s_cupy, __pyx_k_cupy, sizeof(__pyx_k_cupy), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_2, __pyx_k_cupy_2, sizeof(__pyx_k_cupy_2), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_absolute, __pyx_k_cupy_absolute, sizeof(__pyx_k_cupy_absolute), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_all, __pyx_k_cupy_all, sizeof(__pyx_k_cupy_all), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_angle, __pyx_k_cupy_angle, sizeof(__pyx_k_cupy_angle), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_any, __pyx_k_cupy_any, sizeof(__pyx_k_cupy_any), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_argmax, __pyx_k_cupy_argmax, sizeof(__pyx_k_cupy_argmax), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_argmin, __pyx_k_cupy_argmin, sizeof(__pyx_k_cupy_argmin), 0, 0, 1, 1},
  {&__pyx_kp_s_cupy_atomics_cuh, __pyx_k_cupy_atomics_cuh, sizeof(__pyx_k_cupy_atomics_cuh), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_carray_cuh, __pyx_k_cupy_carray_cuh, sizeof(__pyx_k_cupy_carray_cuh), 0, 0, 1, 0},
  {&__pyx_n_s_cupy_choose, __pyx_k_cupy_choose, sizeof(__pyx_k_cupy_choose), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_choose_clip, __pyx_k_cupy_choose_clip, sizeof(__pyx_k_cupy_choose_clip), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_clip, __pyx_k_cupy_clip, sizeof(__pyx_k_cupy_clip), 0, 0, 1, 1},
  {&__pyx_kp_s_cupy_complex_arithmetic_h, __pyx_k_cupy_complex_arithmetic_h, sizeof(__pyx_k_cupy_complex_arithmetic_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_catrig_h, __pyx_k_cupy_complex_catrig_h, sizeof(__pyx_k_cupy_complex_catrig_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_catrigf_h, __pyx_k_cupy_complex_catrigf_h, sizeof(__pyx_k_cupy_complex_catrigf_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_ccosh_h, __pyx_k_cupy_complex_ccosh_h, sizeof(__pyx_k_cupy_complex_ccosh_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_ccoshf_h, __pyx_k_cupy_complex_ccoshf_h, sizeof(__pyx_k_cupy_complex_ccoshf_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_cexp_h, __pyx_k_cupy_complex_cexp_h, sizeof(__pyx_k_cupy_complex_cexp_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_cexpf_h, __pyx_k_cupy_complex_cexpf_h, sizeof(__pyx_k_cupy_complex_cexpf_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_clog_h, __pyx_k_cupy_complex_clog_h, sizeof(__pyx_k_cupy_complex_clog_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_clogf_h, __pyx_k_cupy_complex_clogf_h, sizeof(__pyx_k_cupy_complex_clogf_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_complex_h, __pyx_k_cupy_complex_complex_h, sizeof(__pyx_k_cupy_complex_complex_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_complex_inl_h, __pyx_k_cupy_complex_complex_inl_h, sizeof(__pyx_k_cupy_complex_complex_inl_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_cpow_h, __pyx_k_cupy_complex_cpow_h, sizeof(__pyx_k_cupy_complex_cpow_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_cproj_h, __pyx_k_cupy_complex_cproj_h, sizeof(__pyx_k_cupy_complex_cproj_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_csinh_h, __pyx_k_cupy_complex_csinh_h, sizeof(__pyx_k_cupy_complex_csinh_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_csinhf_h, __pyx_k_cupy_complex_csinhf_h, sizeof(__pyx_k_cupy_complex_csinhf_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_csqrt_h, __pyx_k_cupy_complex_csqrt_h, sizeof(__pyx_k_cupy_complex_csqrt_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_csqrtf_h, __pyx_k_cupy_complex_csqrtf_h, sizeof(__pyx_k_cupy_complex_csqrtf_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_ctanh_h, __pyx_k_cupy_complex_ctanh_h, sizeof(__pyx_k_cupy_complex_ctanh_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_ctanhf_h, __pyx_k_cupy_complex_ctanhf_h, sizeof(__pyx_k_cupy_complex_ctanhf_h), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_cuh, __pyx_k_cupy_complex_cuh, sizeof(__pyx_k_cupy_complex_cuh), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_complex_math_private_h, __pyx_k_cupy_complex_math_private_h, sizeof(__pyx_k_cupy_complex_math_private_h), 0, 0, 1, 0},
  {&__pyx_n_s_cupy_concatenate, __pyx_k_cupy_concatenate, sizeof(__pyx_k_cupy_concatenate), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_concatenate_same_size, __pyx_k_cupy_concatenate_same_size, sizeof(__pyx_k_cupy_concatenate_same_size), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_conj, __pyx_k_cupy_conj, sizeof(__pyx_k_cupy_conj), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_copy, __pyx_k_cupy_copy, sizeof(__pyx_k_cupy_copy), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_copy_where, __pyx_k_cupy_copy_where, sizeof(__pyx_k_cupy_copy_where), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_core, __pyx_k_cupy_core, sizeof(__pyx_k_cupy_core), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_core_core, __pyx_k_cupy_core_core, sizeof(__pyx_k_cupy_core_core), 0, 0, 1, 1},
  {&__pyx_kp_s_cupy_core_core_pyx, __pyx_k_cupy_core_core_pyx, sizeof(__pyx_k_cupy_core_core_pyx), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_core_elementwise_pxi, __pyx_k_cupy_core_elementwise_pxi, sizeof(__pyx_k_cupy_core_elementwise_pxi), 0, 0, 1, 0},
  {&__pyx_kp_s_cupy_core_reduction_pxi, __pyx_k_cupy_core_reduction_pxi, sizeof(__pyx_k_cupy_core_reduction_pxi), 0, 0, 1, 0},
  {&__pyx_n_s_cupy_cuda, __pyx_k_cupy_cuda, sizeof(__pyx_k_cupy_cuda), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_divide, __pyx_k_cupy_divide, sizeof(__pyx_k_cupy_divide), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_divmod, __pyx_k_cupy_divmod, sizeof(__pyx_k_cupy_divmod), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_floor_divide, __pyx_k_cupy_floor_divide, sizeof(__pyx_k_cupy_floor_divide), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_getitem_mask, __pyx_k_cupy_getitem_mask, sizeof(__pyx_k_cupy_getitem_mask), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_imag, __pyx_k_cupy_imag, sizeof(__pyx_k_cupy_imag), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_imag_setter, __pyx_k_cupy_imag_setter, sizeof(__pyx_k_cupy_imag_setter), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_invert, __pyx_k_cupy_invert, sizeof(__pyx_k_cupy_invert), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_max, __pyx_k_cupy_max, sizeof(__pyx_k_cupy_max), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_mean, __pyx_k_cupy_mean, sizeof(__pyx_k_cupy_mean), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_min, __pyx_k_cupy_min, sizeof(__pyx_k_cupy_min), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_nanmax, __pyx_k_cupy_nanmax, sizeof(__pyx_k_cupy_nanmax), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_nanmin, __pyx_k_cupy_nanmin, sizeof(__pyx_k_cupy_nanmin), 0, 0, 1, 1},
  {&__pyx_kp_s_cupy_ndarray_does_not_have_imagi, __pyx_k_cupy_ndarray_does_not_have_imagi, sizeof(__pyx_k_cupy_ndarray_does_not_have_imagi), 0, 0, 1, 0},
  {&__pyx_n_s_cupy_negative, __pyx_k_cupy_negative, sizeof(__pyx_k_cupy_negative), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_power, __pyx_k_cupy_power, sizeof(__pyx_k_cupy_power), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_prod, __pyx_k_cupy_prod, sizeof(__pyx_k_cupy_prod), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_prod_with_dtype, __pyx_k_cupy_prod_with_dtype, sizeof(__pyx_k_cupy_prod_with_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_real, __pyx_k_cupy_real, sizeof(__pyx_k_cupy_real), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_real_setter, __pyx_k_cupy_real_setter, sizeof(__pyx_k_cupy_real_setter), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_remainder, __pyx_k_cupy_remainder, sizeof(__pyx_k_cupy_remainder), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_scatter_add, __pyx_k_cupy_scatter_add, sizeof(__pyx_k_cupy_scatter_add), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_scatter_add_mask, __pyx_k_cupy_scatter_add_mask, sizeof(__pyx_k_cupy_scatter_add_mask), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_scatter_update, __pyx_k_cupy_scatter_update, sizeof(__pyx_k_cupy_scatter_update), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_scatter_update_mask, __pyx_k_cupy_scatter_update_mask, sizeof(__pyx_k_cupy_scatter_update_mask), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_sqrt, __pyx_k_cupy_sqrt, sizeof(__pyx_k_cupy_sqrt), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_sum, __pyx_k_cupy_sum, sizeof(__pyx_k_cupy_sum), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_sum_with_dtype, __pyx_k_cupy_sum_with_dtype, sizeof(__pyx_k_cupy_sum_with_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_take, __pyx_k_cupy_take, sizeof(__pyx_k_cupy_take), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_take_0axis, __pyx_k_cupy_take_0axis, sizeof(__pyx_k_cupy_take_0axis), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_true_divide, __pyx_k_cupy_true_divide, sizeof(__pyx_k_cupy_true_divide), 0, 0, 1, 1},
  {&__pyx_kp_s_currently_CuPy_only_supports_sli, __pyx_k_currently_CuPy_only_supports_sli, sizeof(__pyx_k_currently_CuPy_only_supports_sli), 0, 0, 1, 0},
  {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1},
  {&__pyx_kp_s_d_2, __pyx_k_d_2, sizeof(__pyx_k_d_2), 0, 0, 1, 0},
  {&__pyx_kp_s_d_3, __pyx_k_d_3, sizeof(__pyx_k_d_3), 0, 0, 1, 0},
  {&__pyx_kp_s_d_D, __pyx_k_d_D, sizeof(__pyx_k_d_D), 0, 0, 1, 0},
  {&__pyx_kp_s_d_d, __pyx_k_d_d, sizeof(__pyx_k_d_d), 0, 0, 1, 0},
  {&__pyx_kp_s_d_d_2, __pyx_k_d_d_2, sizeof(__pyx_k_d_d_2), 0, 0, 1, 0},
  {&__pyx_kp_s_d_q, __pyx_k_d_q, sizeof(__pyx_k_d_q), 0, 0, 1, 0},
  {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
  {&__pyx_kp_s_dd, __pyx_k_dd, sizeof(__pyx_k_dd), 0, 0, 1, 0},
  {&__pyx_kp_s_dd_d, __pyx_k_dd_d, sizeof(__pyx_k_dd_d), 0, 0, 1, 0},
  {&__pyx_kp_s_dd_dd, __pyx_k_dd_dd, sizeof(__pyx_k_dd_dd), 0, 0, 1, 0},
  {&__pyx_kp_s_ddd_d, __pyx_k_ddd_d, sizeof(__pyx_k_ddd_d), 0, 0, 1, 0},
  {&__pyx_n_s_ddof, __pyx_k_ddof, sizeof(__pyx_k_ddof), 0, 0, 1, 1},
  {&__pyx_n_s_decide_params_type, __pyx_k_decide_params_type, sizeof(__pyx_k_decide_params_type), 0, 0, 1, 1},
  {&__pyx_n_s_default_casting, __pyx_k_default_casting, sizeof(__pyx_k_default_casting), 0, 0, 1, 1},
  {&__pyx_n_s_default_casting_2, __pyx_k_default_casting_2, sizeof(__pyx_k_default_casting_2), 0, 0, 1, 1},
  {&__pyx_n_s_destination, __pyx_k_destination, sizeof(__pyx_k_destination), 0, 0, 1, 1},
  {&__pyx_n_s_device, __pyx_k_device, sizeof(__pyx_k_device), 0, 0, 1, 1},
  {&__pyx_n_s_dgeam, __pyx_k_dgeam, sizeof(__pyx_k_dgeam), 0, 0, 1, 1},
  {&__pyx_n_s_dgemmBatched, __pyx_k_dgemmBatched, sizeof(__pyx_k_dgemmBatched), 0, 0, 1, 1},
  {&__pyx_n_s_dgemmStridedBatched, __pyx_k_dgemmStridedBatched, sizeof(__pyx_k_dgemmStridedBatched), 0, 0, 1, 1},
  {&__pyx_n_s_diagonal, __pyx_k_diagonal, sizeof(__pyx_k_diagonal), 0, 0, 1, 1},
  {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  {&__pyx_n_s_dirname, __pyx_k_dirname, sizeof(__pyx_k_dirname), 0, 0, 1, 1},
  {&__pyx_n_s_divide, __pyx_k_divide, sizeof(__pyx_k_divide), 0, 0, 1, 1},
  {&__pyx_n_s_divmod, __pyx_k_divmod, sizeof(__pyx_k_divmod), 0, 0, 1, 1},
  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  {&__pyx_n_s_doc_2, __pyx_k_doc_2, sizeof(__pyx_k_doc_2), 0, 0, 1, 1},
  {&__pyx_n_s_double, __pyx_k_double, sizeof(__pyx_k_double), 0, 0, 1, 1},
  {&__pyx_n_s_dst_dtype, __pyx_k_dst_dtype, sizeof(__pyx_k_dst_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_dtype_2, __pyx_k_dtype_2, sizeof(__pyx_k_dtype_2), 0, 0, 1, 1},
  {&__pyx_kp_s_dtype_is_None, __pyx_k_dtype_is_None, sizeof(__pyx_k_dtype_is_None), 0, 0, 1, 0},
  {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1},
  {&__pyx_n_s_dump, __pyx_k_dump, sizeof(__pyx_k_dump), 0, 0, 1, 1},
  {&__pyx_n_s_dumps, __pyx_k_dumps, sizeof(__pyx_k_dumps), 0, 0, 1, 1},
  {&__pyx_kp_s_duplicate_value_in_axis, __pyx_k_duplicate_value_in_axis, sizeof(__pyx_k_duplicate_value_in_axis), 0, 0, 1, 0},
  {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 1, 1},
  {&__pyx_kp_s_e_2, __pyx_k_e_2, sizeof(__pyx_k_e_2), 0, 0, 1, 0},
  {&__pyx_kp_s_e_e, __pyx_k_e_e, sizeof(__pyx_k_e_e), 0, 0, 1, 0},
  {&__pyx_kp_s_e_e_2, __pyx_k_e_e_2, sizeof(__pyx_k_e_e_2), 0, 0, 1, 0},
  {&__pyx_kp_s_e_q, __pyx_k_e_q, sizeof(__pyx_k_e_q), 0, 0, 1, 0},
  {&__pyx_n_s_each_size, __pyx_k_each_size, sizeof(__pyx_k_each_size), 0, 0, 1, 1},
  {&__pyx_kp_s_ee, __pyx_k_ee, sizeof(__pyx_k_ee), 0, 0, 1, 0},
  {&__pyx_kp_s_ee_e, __pyx_k_ee_e, sizeof(__pyx_k_ee_e), 0, 0, 1, 0},
  {&__pyx_kp_s_ee_ee, __pyx_k_ee_ee, sizeof(__pyx_k_ee_ee), 0, 0, 1, 0},
  {&__pyx_kp_s_eee_e, __pyx_k_eee_e, sizeof(__pyx_k_eee_e), 0, 0, 1, 0},
  {&__pyx_n_s_elem, __pyx_k_elem, sizeof(__pyx_k_elem), 0, 0, 1, 1},
  {&__pyx_n_s_elementwise_copy, __pyx_k_elementwise_copy, sizeof(__pyx_k_elementwise_copy), 0, 0, 1, 1},
  {&__pyx_n_s_elementwise_copy_where, __pyx_k_elementwise_copy_where, sizeof(__pyx_k_elementwise_copy_where), 0, 0, 1, 1},
  {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1},
  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_n_s_equal, __pyx_k_equal, sizeof(__pyx_k_equal), 0, 0, 1, 1},
  {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
  {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
  {&__pyx_n_s_extend, __pyx_k_extend, sizeof(__pyx_k_extend), 0, 0, 1, 1},
  {&__pyx_kp_s_extern_C___global___void_name_C, __pyx_k_extern_C___global___void_name_C, sizeof(__pyx_k_extern_C___global___void_name_C), 0, 0, 1, 0},
  {&__pyx_kp_s_extern_C___global___void_name_c, __pyx_k_extern_C___global___void_name_c, sizeof(__pyx_k_extern_C___global___void_name_c), 0, 0, 1, 0},
  {&__pyx_kp_s_extern_C___global___void_name_c_2, __pyx_k_extern_C___global___void_name_c_2, sizeof(__pyx_k_extern_C___global___void_name_c_2), 0, 0, 1, 0},
  {&__pyx_kp_s_extern_C___global___void_name_c_3, __pyx_k_extern_C___global___void_name_c_3, sizeof(__pyx_k_extern_C___global___void_name_c_3), 0, 0, 1, 0},
  {&__pyx_n_s_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 0, 1, 1},
  {&__pyx_kp_s_f_2, __pyx_k_f_2, sizeof(__pyx_k_f_2), 0, 0, 1, 0},
  {&__pyx_kp_s_f_F, __pyx_k_f_F, sizeof(__pyx_k_f_F), 0, 0, 1, 0},
  {&__pyx_kp_s_f_f, __pyx_k_f_f, sizeof(__pyx_k_f_f), 0, 0, 1, 0},
  {&__pyx_kp_s_f_f_2, __pyx_k_f_f_2, sizeof(__pyx_k_f_f_2), 0, 0, 1, 0},
  {&__pyx_kp_s_f_q, __pyx_k_f_q, sizeof(__pyx_k_f_q), 0, 0, 1, 0},
  {&__pyx_n_s_false, __pyx_k_false, sizeof(__pyx_k_false), 0, 0, 1, 1},
  {&__pyx_n_s_fdFD, __pyx_k_fdFD, sizeof(__pyx_k_fdFD), 0, 0, 1, 1},
  {&__pyx_kp_s_ff, __pyx_k_ff, sizeof(__pyx_k_ff), 0, 0, 1, 0},
  {&__pyx_kp_s_ff_f, __pyx_k_ff_f, sizeof(__pyx_k_ff_f), 0, 0, 1, 0},
  {&__pyx_kp_s_ff_ff, __pyx_k_ff_ff, sizeof(__pyx_k_ff_ff), 0, 0, 1, 0},
  {&__pyx_kp_s_fff_f, __pyx_k_fff_f, sizeof(__pyx_k_fff_f), 0, 0, 1, 0},
  {&__pyx_n_s_fid, __pyx_k_fid, sizeof(__pyx_k_fid), 0, 0, 1, 1},
  {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1},
  {&__pyx_n_s_fill, __pyx_k_fill, sizeof(__pyx_k_fill), 0, 0, 1, 1},
  {&__pyx_n_s_find_common_type, __pyx_k_find_common_type, sizeof(__pyx_k_find_common_type), 0, 0, 1, 1},
  {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
  {&__pyx_n_s_flatten, __pyx_k_flatten, sizeof(__pyx_k_flatten), 0, 0, 1, 1},
  {&__pyx_n_s_float, __pyx_k_float, sizeof(__pyx_k_float), 0, 0, 1, 1},
  {&__pyx_n_s_float16, __pyx_k_float16, sizeof(__pyx_k_float16), 0, 0, 1, 1},
  {&__pyx_n_s_float32, __pyx_k_float32, sizeof(__pyx_k_float32), 0, 0, 1, 1},
  {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1},
  {&__pyx_n_s_floating, __pyx_k_floating, sizeof(__pyx_k_floating), 0, 0, 1, 1},
  {&__pyx_n_s_floor_divide, __pyx_k_floor_divide, sizeof(__pyx_k_floor_divide), 0, 0, 1, 1},
  {&__pyx_n_s_fmt, __pyx_k_fmt, sizeof(__pyx_k_fmt), 0, 0, 1, 1},
  {&__pyx_n_s_for_each_device, __pyx_k_for_each_device, sizeof(__pyx_k_for_each_device), 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_frombuffer, __pyx_k_frombuffer, sizeof(__pyx_k_frombuffer), 0, 0, 1, 1},
  {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_get_as_parameter, __pyx_k_get_as_parameter, sizeof(__pyx_k_get_as_parameter), 0, 0, 1, 1},
  {&__pyx_n_s_get_cuda_path, __pyx_k_get_cuda_path, sizeof(__pyx_k_get_cuda_path), 0, 0, 1, 1},
  {&__pyx_n_s_get_elementwise_kernel, __pyx_k_get_elementwise_kernel, sizeof(__pyx_k_get_elementwise_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_get_elementwise_kernel_locals_g, __pyx_k_get_elementwise_kernel_locals_g, sizeof(__pyx_k_get_elementwise_kernel_locals_g), 0, 0, 1, 1},
  {&__pyx_n_s_get_param_info, __pyx_k_get_param_info, sizeof(__pyx_k_get_param_info), 0, 0, 1, 1},
  {&__pyx_n_s_get_reduction_kernel, __pyx_k_get_reduction_kernel, sizeof(__pyx_k_get_reduction_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_get_reduction_kernel_locals_gen, __pyx_k_get_reduction_kernel_locals_gen, sizeof(__pyx_k_get_reduction_kernel_locals_gen), 0, 0, 1, 1},
  {&__pyx_n_s_get_simple_elementwise_kernel, __pyx_k_get_simple_elementwise_kernel, sizeof(__pyx_k_get_simple_elementwise_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_get_simple_reduction_function, __pyx_k_get_simple_reduction_function, sizeof(__pyx_k_get_simple_reduction_function), 0, 0, 1, 1},
  {&__pyx_n_s_get_ufunc_kernel, __pyx_k_get_ufunc_kernel, sizeof(__pyx_k_get_ufunc_kernel), 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_greater, __pyx_k_greater, sizeof(__pyx_k_greater), 0, 0, 1, 1},
  {&__pyx_n_s_greater_equal, __pyx_k_greater_equal, sizeof(__pyx_k_greater_equal), 0, 0, 1, 1},
  {&__pyx_n_s_grid, __pyx_k_grid, sizeof(__pyx_k_grid), 0, 0, 1, 1},
  {&__pyx_kp_s_h, __pyx_k_h, sizeof(__pyx_k_h), 0, 0, 1, 0},
  {&__pyx_kp_s_h_d, __pyx_k_h_d, sizeof(__pyx_k_h_d), 0, 0, 1, 0},
  {&__pyx_kp_s_h_h, __pyx_k_h_h, sizeof(__pyx_k_h_h), 0, 0, 1, 0},
  {&__pyx_kp_s_h_h_2, __pyx_k_h_h_2, sizeof(__pyx_k_h_h_2), 0, 0, 1, 0},
  {&__pyx_kp_s_h_l, __pyx_k_h_l, sizeof(__pyx_k_h_l), 0, 0, 1, 0},
  {&__pyx_kp_s_h_q, __pyx_k_h_q, sizeof(__pyx_k_h_q), 0, 0, 1, 0},
  {&__pyx_n_s_has_element, __pyx_k_has_element, sizeof(__pyx_k_has_element), 0, 0, 1, 1},
  {&__pyx_n_s_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 0, 0, 1, 1},
  {&__pyx_kp_s_hh, __pyx_k_hh, sizeof(__pyx_k_hh), 0, 0, 1, 0},
  {&__pyx_kp_s_hh_d, __pyx_k_hh_d, sizeof(__pyx_k_hh_d), 0, 0, 1, 0},
  {&__pyx_kp_s_hh_h, __pyx_k_hh_h, sizeof(__pyx_k_hh_h), 0, 0, 1, 0},
  {&__pyx_kp_s_hh_hh, __pyx_k_hh_hh, sizeof(__pyx_k_hh_hh), 0, 0, 1, 0},
  {&__pyx_kp_s_hhh_h, __pyx_k_hhh_h, sizeof(__pyx_k_hhh_h), 0, 0, 1, 0},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_kp_s_i_2, __pyx_k_i_2, sizeof(__pyx_k_i_2), 0, 0, 1, 0},
  {&__pyx_kp_s_i_d, __pyx_k_i_d, sizeof(__pyx_k_i_d), 0, 0, 1, 0},
  {&__pyx_kp_s_i_i, __pyx_k_i_i, sizeof(__pyx_k_i_i), 0, 0, 1, 0},
  {&__pyx_kp_s_i_i_2, __pyx_k_i_i_2, sizeof(__pyx_k_i_i_2), 0, 0, 1, 0},
  {&__pyx_kp_s_i_l, __pyx_k_i_l, sizeof(__pyx_k_i_l), 0, 0, 1, 0},
  {&__pyx_kp_s_i_q, __pyx_k_i_q, sizeof(__pyx_k_i_q), 0, 0, 1, 0},
  {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
  {&__pyx_n_s_identity, __pyx_k_identity, sizeof(__pyx_k_identity), 0, 0, 1, 1},
  {&__pyx_kp_s_if_in1_0_out0_0_out1_0_else_out, __pyx_k_if_in1_0_out0_0_out1_0_else_out, sizeof(__pyx_k_if_in1_0_out0_0_out1_0_else_out), 0, 0, 1, 0},
  {&__pyx_kp_s_if_in1_out0_in0, __pyx_k_if_in1_out0_in0, sizeof(__pyx_k_if_in1_out0_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_if_mask_a_a_v_mask_scanned_1, __pyx_k_if_mask_a_a_v_mask_scanned_1, sizeof(__pyx_k_if_mask_a_a_v_mask_scanned_1), 0, 0, 1, 0},
  {&__pyx_kp_s_if_mask_a_v_mask_scanned_1, __pyx_k_if_mask_a_v_mask_scanned_1, sizeof(__pyx_k_if_mask_a_v_mask_scanned_1), 0, 0, 1, 0},
  {&__pyx_kp_s_if_mask_out_mask_scanned_1_a, __pyx_k_if_mask_out_mask_scanned_1_a, sizeof(__pyx_k_if_mask_out_mask_scanned_1_a), 0, 0, 1, 0},
  {&__pyx_kp_s_ii, __pyx_k_ii, sizeof(__pyx_k_ii), 0, 0, 1, 0},
  {&__pyx_kp_s_ii_d, __pyx_k_ii_d, sizeof(__pyx_k_ii_d), 0, 0, 1, 0},
  {&__pyx_kp_s_ii_i, __pyx_k_ii_i, sizeof(__pyx_k_ii_i), 0, 0, 1, 0},
  {&__pyx_kp_s_ii_ii, __pyx_k_ii_ii, sizeof(__pyx_k_ii_ii), 0, 0, 1, 0},
  {&__pyx_kp_s_iii_i, __pyx_k_iii_i, sizeof(__pyx_k_iii_i), 0, 0, 1, 0},
  {&__pyx_n_s_iinfo, __pyx_k_iinfo, sizeof(__pyx_k_iinfo), 0, 0, 1, 1},
  {&__pyx_n_s_imag, __pyx_k_imag, sizeof(__pyx_k_imag), 0, 0, 1, 1},
  {&__pyx_n_s_imag_setter, __pyx_k_imag_setter, sizeof(__pyx_k_imag_setter), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_in0, __pyx_k_in0, sizeof(__pyx_k_in0), 0, 0, 1, 1},
  {&__pyx_kp_s_in0_type_in0_raw_0, __pyx_k_in0_type_in0_raw_0, sizeof(__pyx_k_in0_type_in0_raw_0), 0, 0, 1, 0},
  {&__pyx_n_s_in_arg_dtype, __pyx_k_in_arg_dtype, sizeof(__pyx_k_in_arg_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_in_args, __pyx_k_in_args, sizeof(__pyx_k_in_args), 0, 0, 1, 1},
  {&__pyx_n_s_in_args_dtype, __pyx_k_in_args_dtype, sizeof(__pyx_k_in_args_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_in_indexer, __pyx_k_in_indexer, sizeof(__pyx_k_in_indexer), 0, 0, 1, 1},
  {&__pyx_n_s_in_ndarray_types, __pyx_k_in_ndarray_types, sizeof(__pyx_k_in_ndarray_types), 0, 0, 1, 1},
  {&__pyx_n_s_in_params, __pyx_k_in_params, sizeof(__pyx_k_in_params), 0, 0, 1, 1},
  {&__pyx_n_s_in_params_2, __pyx_k_in_params_2, sizeof(__pyx_k_in_params_2), 0, 0, 1, 1},
  {&__pyx_n_s_in_sahpe, __pyx_k_in_sahpe, sizeof(__pyx_k_in_sahpe), 0, 0, 1, 1},
  {&__pyx_n_s_in_shape, __pyx_k_in_shape, sizeof(__pyx_k_in_shape), 0, 0, 1, 1},
  {&__pyx_n_s_in_str, __pyx_k_in_str, sizeof(__pyx_k_in_str), 0, 0, 1, 1},
  {&__pyx_n_s_in_types, __pyx_k_in_types, sizeof(__pyx_k_in_types), 0, 0, 1, 1},
  {&__pyx_n_s_include, __pyx_k_include, sizeof(__pyx_k_include), 0, 0, 1, 1},
  {&__pyx_kp_s_include_s, __pyx_k_include_s, sizeof(__pyx_k_include_s), 0, 0, 1, 0},
  {&__pyx_n_s_inclusive_scan_kernel, __pyx_k_inclusive_scan_kernel, sizeof(__pyx_k_inclusive_scan_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_inclusive_scan_kernel_2, __pyx_k_inclusive_scan_kernel_2, sizeof(__pyx_k_inclusive_scan_kernel_2), 0, 0, 1, 1},
  {&__pyx_kp_s_incompatible_shape, __pyx_k_incompatible_shape, sizeof(__pyx_k_incompatible_shape), 0, 0, 1, 0},
  {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1},
  {&__pyx_n_s_index_dtype, __pyx_k_index_dtype, sizeof(__pyx_k_index_dtype), 0, 0, 1, 1},
  {&__pyx_kp_s_index_out_of_range, __pyx_k_index_out_of_range, sizeof(__pyx_k_index_out_of_range), 0, 0, 1, 0},
  {&__pyx_n_s_indexer, __pyx_k_indexer, sizeof(__pyx_k_indexer), 0, 0, 1, 1},
  {&__pyx_n_s_indices, __pyx_k_indices, sizeof(__pyx_k_indices), 0, 0, 1, 1},
  {&__pyx_n_s_indices_or_sections, __pyx_k_indices_or_sections, sizeof(__pyx_k_indices_or_sections), 0, 0, 1, 1},
  {&__pyx_kp_s_inf, __pyx_k_inf, sizeof(__pyx_k_inf), 0, 0, 1, 0},
  {&__pyx_n_s_inf_2, __pyx_k_inf_2, sizeof(__pyx_k_inf_2), 0, 0, 1, 1},
  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  {&__pyx_n_s_inout_args, __pyx_k_inout_args, sizeof(__pyx_k_inout_args), 0, 0, 1, 1},
  {&__pyx_n_s_input_expr, __pyx_k_input_expr, sizeof(__pyx_k_input_expr), 0, 0, 1, 1},
  {&__pyx_n_s_input_expr_2, __pyx_k_input_expr_2, sizeof(__pyx_k_input_expr_2), 0, 0, 1, 1},
  {&__pyx_kp_s_input_operand_has_more_dimension, __pyx_k_input_operand_has_more_dimension, sizeof(__pyx_k_input_operand_has_more_dimension), 0, 0, 1, 0},
  {&__pyx_n_s_int, __pyx_k_int, sizeof(__pyx_k_int), 0, 0, 1, 1},
  {&__pyx_n_s_int16, __pyx_k_int16, sizeof(__pyx_k_int16), 0, 0, 1, 1},
  {&__pyx_n_s_int32, __pyx_k_int32, sizeof(__pyx_k_int32), 0, 0, 1, 1},
  {&__pyx_kp_s_int32__block_stride, __pyx_k_int32__block_stride, sizeof(__pyx_k_int32__block_stride), 0, 0, 1, 0},
  {&__pyx_n_s_int64, __pyx_k_int64, sizeof(__pyx_k_int64), 0, 0, 1, 1},
  {&__pyx_n_s_int8, __pyx_k_int8, sizeof(__pyx_k_int8), 0, 0, 1, 1},
  {&__pyx_n_s_int_iinfo, __pyx_k_int_iinfo, sizeof(__pyx_k_int_iinfo), 0, 0, 1, 1},
  {&__pyx_n_s_integer, __pyx_k_integer, sizeof(__pyx_k_integer), 0, 0, 1, 1},
  {&__pyx_n_s_integer_types, __pyx_k_integer_types, sizeof(__pyx_k_integer_types), 0, 0, 1, 1},
  {&__pyx_n_s_intp, __pyx_k_intp, sizeof(__pyx_k_intp), 0, 0, 1, 1},
  {&__pyx_kp_s_invalid_entry_in_choice_array, __pyx_k_invalid_entry_in_choice_array, sizeof(__pyx_k_invalid_entry_in_choice_array), 0, 0, 1, 0},
  {&__pyx_n_s_invert, __pyx_k_invert, sizeof(__pyx_k_invert), 0, 0, 1, 1},
  {&__pyx_n_s_is_const, __pyx_k_is_const, sizeof(__pyx_k_is_const), 0, 0, 1, 1},
  {&__pyx_n_s_is_valid_kernel_name, __pyx_k_is_valid_kernel_name, sizeof(__pyx_k_is_valid_kernel_name), 0, 0, 1, 1},
  {&__pyx_n_s_isscalar, __pyx_k_isscalar, sizeof(__pyx_k_isscalar), 0, 0, 1, 1},
  {&__pyx_n_s_issubdtype, __pyx_k_issubdtype, sizeof(__pyx_k_issubdtype), 0, 0, 1, 1},
  {&__pyx_n_s_item, __pyx_k_item, sizeof(__pyx_k_item), 0, 0, 1, 1},
  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 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_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
  {&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1},
  {&__pyx_n_s_keepdims, __pyx_k_keepdims, sizeof(__pyx_k_keepdims), 0, 0, 1, 1},
  {&__pyx_n_s_kern, __pyx_k_kern, sizeof(__pyx_k_kern), 0, 0, 1, 1},
  {&__pyx_n_s_kernel, __pyx_k_kernel, sizeof(__pyx_k_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_kernel_params, __pyx_k_kernel_params, sizeof(__pyx_k_kernel_params), 0, 0, 1, 1},
  {&__pyx_n_s_kind, __pyx_k_kind, sizeof(__pyx_k_kind), 0, 0, 1, 1},
  {&__pyx_n_s_kth, __pyx_k_kth, sizeof(__pyx_k_kth), 0, 0, 1, 1},
  {&__pyx_kp_s_kth_out_of_bounds, __pyx_k_kth_out_of_bounds, sizeof(__pyx_k_kth_out_of_bounds), 0, 0, 1, 0},
  {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
  {&__pyx_kp_s_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 0},
  {&__pyx_kp_s_l_2, __pyx_k_l_2, sizeof(__pyx_k_l_2), 0, 0, 1, 0},
  {&__pyx_kp_s_l_d, __pyx_k_l_d, sizeof(__pyx_k_l_d), 0, 0, 1, 0},
  {&__pyx_kp_s_l_l, __pyx_k_l_l, sizeof(__pyx_k_l_l), 0, 0, 1, 0},
  {&__pyx_kp_s_l_l_2, __pyx_k_l_l_2, sizeof(__pyx_k_l_l_2), 0, 0, 1, 0},
  {&__pyx_kp_s_l_q, __pyx_k_l_q, sizeof(__pyx_k_l_q), 0, 0, 1, 0},
  {&__pyx_n_s_laxis, __pyx_k_laxis, sizeof(__pyx_k_laxis), 0, 0, 1, 1},
  {&__pyx_n_s_left_shift, __pyx_k_left_shift, sizeof(__pyx_k_left_shift), 0, 0, 1, 1},
  {&__pyx_kp_s_len_of_unsized_object, __pyx_k_len_of_unsized_object, sizeof(__pyx_k_len_of_unsized_object), 0, 0, 1, 0},
  {&__pyx_kp_s_len_shape_len_strides, __pyx_k_len_shape_len_strides, sizeof(__pyx_k_len_shape_len_strides), 0, 0, 1, 0},
  {&__pyx_n_s_less, __pyx_k_less, sizeof(__pyx_k_less), 0, 0, 1, 1},
  {&__pyx_n_s_less_equal, __pyx_k_less_equal, sizeof(__pyx_k_less_equal), 0, 0, 1, 1},
  {&__pyx_n_s_li, __pyx_k_li, sizeof(__pyx_k_li), 0, 0, 1, 1},
  {&__pyx_n_s_linear_launch, __pyx_k_linear_launch, sizeof(__pyx_k_linear_launch), 0, 0, 1, 1},
  {&__pyx_kp_s_ll, __pyx_k_ll, sizeof(__pyx_k_ll), 0, 0, 1, 0},
  {&__pyx_kp_s_ll_d, __pyx_k_ll_d, sizeof(__pyx_k_ll_d), 0, 0, 1, 0},
  {&__pyx_kp_s_ll_l, __pyx_k_ll_l, sizeof(__pyx_k_ll_l), 0, 0, 1, 0},
  {&__pyx_kp_s_ll_ll, __pyx_k_ll_ll, sizeof(__pyx_k_ll_ll), 0, 0, 1, 0},
  {&__pyx_kp_s_lll_l, __pyx_k_lll_l, sizeof(__pyx_k_lll_l), 0, 0, 1, 0},
  {&__pyx_n_s_long, __pyx_k_long, sizeof(__pyx_k_long), 0, 0, 1, 1},
  {&__pyx_kp_s_long_long, __pyx_k_long_long, sizeof(__pyx_k_long_long), 0, 0, 1, 0},
  {&__pyx_n_s_loop_prep, __pyx_k_loop_prep, sizeof(__pyx_k_loop_prep), 0, 0, 1, 1},
  {&__pyx_n_s_lower, __pyx_k_lower, sizeof(__pyx_k_lower), 0, 0, 1, 1},
  {&__pyx_n_s_m, __pyx_k_m, sizeof(__pyx_k_m), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_map, __pyx_k_map, sizeof(__pyx_k_map), 0, 0, 1, 1},
  {&__pyx_n_s_map_expr, __pyx_k_map_expr, sizeof(__pyx_k_map_expr), 0, 0, 1, 1},
  {&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1},
  {&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1},
  {&__pyx_n_s_maximum, __pyx_k_maximum, sizeof(__pyx_k_maximum), 0, 0, 1, 1},
  {&__pyx_n_s_maxsize, __pyx_k_maxsize, sizeof(__pyx_k_maxsize), 0, 0, 1, 1},
  {&__pyx_n_s_mean, __pyx_k_mean, sizeof(__pyx_k_mean), 0, 0, 1, 1},
  {&__pyx_n_s_memoize, __pyx_k_memoize, sizeof(__pyx_k_memoize), 0, 0, 1, 1},
  {&__pyx_n_s_memptr, __pyx_k_memptr, sizeof(__pyx_k_memptr), 0, 0, 1, 1},
  {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1},
  {&__pyx_n_s_merge_kernel, __pyx_k_merge_kernel, sizeof(__pyx_k_merge_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  {&__pyx_n_s_min, __pyx_k_min, sizeof(__pyx_k_min), 0, 0, 1, 1},
  {&__pyx_kp_s_min_max_st_type_in0_raw, __pyx_k_min_max_st_type_in0_raw, sizeof(__pyx_k_min_max_st_type_in0_raw), 0, 0, 1, 0},
  {&__pyx_kp_s_min_max_st_type_in0_raw_in0, __pyx_k_min_max_st_type_in0_raw_in0, sizeof(__pyx_k_min_max_st_type_in0_raw_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_min_max_st_type_in0_raw_in0__J, __pyx_k_min_max_st_type_in0_raw_in0__J, sizeof(__pyx_k_min_max_st_type_in0_raw_in0__J), 0, 0, 1, 0},
  {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  {&__pyx_n_s_module_2, __pyx_k_module_2, sizeof(__pyx_k_module_2), 0, 0, 1, 1},
  {&__pyx_n_s_moves, __pyx_k_moves, sizeof(__pyx_k_moves), 0, 0, 1, 1},
  {&__pyx_n_s_multiply, __pyx_k_multiply, sizeof(__pyx_k_multiply), 0, 0, 1, 1},
  {&__pyx_kp_s_my_argmax_a_b, __pyx_k_my_argmax_a_b, sizeof(__pyx_k_my_argmax_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_my_argmax_float_a_b, __pyx_k_my_argmax_float_a_b, sizeof(__pyx_k_my_argmax_float_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_my_argmin_a_b, __pyx_k_my_argmin_a_b, sizeof(__pyx_k_my_argmin_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_my_argmin_float_a_b, __pyx_k_my_argmin_float_a_b, sizeof(__pyx_k_my_argmin_float_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_my_max_a_b, __pyx_k_my_max_a_b, sizeof(__pyx_k_my_max_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_my_max_float_a_b, __pyx_k_my_max_float_a_b, sizeof(__pyx_k_my_max_float_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_my_min_a_b, __pyx_k_my_min_a_b, sizeof(__pyx_k_my_min_a_b), 0, 0, 1, 0},
  {&__pyx_kp_s_my_min_float_a_b, __pyx_k_my_min_float_a_b, sizeof(__pyx_k_my_min_float_a_b), 0, 0, 1, 0},
  {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1},
  {&__pyx_n_s_n_args, __pyx_k_n_args, sizeof(__pyx_k_n_args), 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_nanmax, __pyx_k_nanmax, sizeof(__pyx_k_nanmax), 0, 0, 1, 1},
  {&__pyx_n_s_nanmin, __pyx_k_nanmin, sizeof(__pyx_k_nanmin), 0, 0, 1, 1},
  {&__pyx_n_s_nargs, __pyx_k_nargs, sizeof(__pyx_k_nargs), 0, 0, 1, 1},
  {&__pyx_n_s_nbytes, __pyx_k_nbytes, sizeof(__pyx_k_nbytes), 0, 0, 1, 1},
  {&__pyx_n_s_ndarray, __pyx_k_ndarray, sizeof(__pyx_k_ndarray), 0, 0, 1, 1},
  {&__pyx_kp_u_ndarray___getitem___line_1507, __pyx_k_ndarray___getitem___line_1507, sizeof(__pyx_k_ndarray___getitem___line_1507), 0, 1, 0, 0},
  {&__pyx_kp_u_ndarray___setitem___line_1553, __pyx_k_ndarray___setitem___line_1553, sizeof(__pyx_k_ndarray___setitem___line_1553), 0, 1, 0, 0},
  {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
  {&__pyx_n_s_ndmin, __pyx_k_ndmin, sizeof(__pyx_k_ndmin), 0, 0, 1, 1},
  {&__pyx_n_s_negative, __pyx_k_negative, sizeof(__pyx_k_negative), 0, 0, 1, 1},
  {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  {&__pyx_n_s_newshape, __pyx_k_newshape, sizeof(__pyx_k_newshape), 0, 0, 1, 1},
  {&__pyx_n_s_nin, __pyx_k_nin, sizeof(__pyx_k_nin), 0, 0, 1, 1},
  {&__pyx_n_s_no_bool, __pyx_k_no_bool, sizeof(__pyx_k_no_bool), 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_kp_s_non_scalar_numpy_ndarray_cannot, __pyx_k_non_scalar_numpy_ndarray_cannot, sizeof(__pyx_k_non_scalar_numpy_ndarray_cannot), 0, 0, 1, 0},
  {&__pyx_n_s_nonzero_1d_kernel, __pyx_k_nonzero_1d_kernel, sizeof(__pyx_k_nonzero_1d_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_nonzero_1d_kernel_2, __pyx_k_nonzero_1d_kernel_2, sizeof(__pyx_k_nonzero_1d_kernel_2), 0, 0, 1, 1},
  {&__pyx_n_s_nonzero_kernel, __pyx_k_nonzero_kernel, sizeof(__pyx_k_nonzero_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_nonzero_kernel_2, __pyx_k_nonzero_kernel_2, sizeof(__pyx_k_nonzero_kernel_2), 0, 0, 1, 1},
  {&__pyx_n_s_not_equal, __pyx_k_not_equal, sizeof(__pyx_k_not_equal), 0, 0, 1, 1},
  {&__pyx_n_s_nout, __pyx_k_nout, sizeof(__pyx_k_nout), 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_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
  {&__pyx_n_s_oct, __pyx_k_oct, sizeof(__pyx_k_oct), 0, 0, 1, 1},
  {&__pyx_n_s_offset, __pyx_k_offset, sizeof(__pyx_k_offset), 0, 0, 1, 1},
  {&__pyx_kp_s_only_integers_slices_ellipsis_nu, __pyx_k_only_integers_slices_ellipsis_nu, sizeof(__pyx_k_only_integers_slices_ellipsis_nu), 0, 0, 1, 0},
  {&__pyx_n_s_op, __pyx_k_op, sizeof(__pyx_k_op), 0, 0, 1, 1},
  {&__pyx_n_s_open, __pyx_k_open, sizeof(__pyx_k_open), 0, 0, 1, 1},
  {&__pyx_kp_s_operands_could_not_be_broadcast, __pyx_k_operands_could_not_be_broadcast, sizeof(__pyx_k_operands_could_not_be_broadcast), 0, 0, 1, 0},
  {&__pyx_n_s_operation, __pyx_k_operation, sizeof(__pyx_k_operation), 0, 0, 1, 1},
  {&__pyx_n_s_ops, __pyx_k_ops, sizeof(__pyx_k_ops), 0, 0, 1, 1},
  {&__pyx_n_s_ops_2, __pyx_k_ops_2, sizeof(__pyx_k_ops_2), 0, 0, 1, 1},
  {&__pyx_n_s_options, __pyx_k_options, sizeof(__pyx_k_options), 0, 0, 1, 1},
  {&__pyx_n_s_order, __pyx_k_order, sizeof(__pyx_k_order), 0, 0, 1, 1},
  {&__pyx_kp_s_order_not_understood, __pyx_k_order_not_understood, sizeof(__pyx_k_order_not_understood), 0, 0, 1, 0},
  {&__pyx_kp_s_order_not_understood_order, __pyx_k_order_not_understood_order, sizeof(__pyx_k_order_not_understood_order), 0, 0, 1, 0},
  {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
  {&__pyx_n_s_out, __pyx_k_out, sizeof(__pyx_k_out), 0, 0, 1, 1},
  {&__pyx_kp_s_out0_0, __pyx_k_out0_0, sizeof(__pyx_k_out0_0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0__floor_divide_in0_in1, __pyx_k_out0__floor_divide_in0_in1, sizeof(__pyx_k_out0__floor_divide_in0_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_a, __pyx_k_out0_a, sizeof(__pyx_k_out0_a), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_a__type_reduce__in_ind_size, __pyx_k_out0_a__type_reduce__in_ind_size, sizeof(__pyx_k_out0_a__type_reduce__in_ind_size), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_a_index, __pyx_k_out0_a_index, sizeof(__pyx_k_out0_a_index), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_a_value, __pyx_k_out0_a_value, sizeof(__pyx_k_out0_a_value), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_abs_in0, __pyx_k_out0_abs_in0, sizeof(__pyx_k_out0_abs_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_arg_in0, __pyx_k_out0_arg_in0, sizeof(__pyx_k_out0_arg_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_conj_in0, __pyx_k_out0_conj_in0, sizeof(__pyx_k_out0_conj_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_fabs_in0, __pyx_k_out0_fabs_in0, sizeof(__pyx_k_out0_fabs_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_fabsf_in0, __pyx_k_out0_fabsf_in0, sizeof(__pyx_k_out0_fabsf_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_imag_in0, __pyx_k_out0_imag_in0, sizeof(__pyx_k_out0_imag_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0, __pyx_k_out0_in0, sizeof(__pyx_k_out0_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_0_0_M_PI, __pyx_k_out0_in0_0_0_M_PI, sizeof(__pyx_k_out0_in0_0_0_M_PI), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_0_in0_in0, __pyx_k_out0_in0_0_in0_in0, sizeof(__pyx_k_out0_in0_0_in0_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_2, __pyx_k_out0_in0_2, sizeof(__pyx_k_out0_in0_2), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_3, __pyx_k_out0_in0_3, sizeof(__pyx_k_out0_in0_3), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_4, __pyx_k_out0_in0_4, sizeof(__pyx_k_out0_in0_4), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0__floor_divide_in0_in1_i, __pyx_k_out0_in0__floor_divide_in0_in1_i, sizeof(__pyx_k_out0_in0__floor_divide_in0_in1_i), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0__floor_divide_in0_in1_i_2, __pyx_k_out0_in0__floor_divide_in0_in1_i_2, sizeof(__pyx_k_out0_in0__floor_divide_in0_in1_i_2), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_imag, __pyx_k_out0_in0_imag, sizeof(__pyx_k_out0_in0_imag), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_in1, __pyx_k_out0_in0_in1, sizeof(__pyx_k_out0_in0_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_in1_in1_in0_in2_in2_in0, __pyx_k_out0_in0_in1_in1_in0_in2_in2_in0, sizeof(__pyx_k_out0_in0_in1_in1_in0_in2_in2_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_real, __pyx_k_out0_in0_real, sizeof(__pyx_k_out0_in0_real), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in0_s_in1, __pyx_k_out0_in0_s_in1, sizeof(__pyx_k_out0_in0_s_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_in1_0_0_floor_double_in0_do, __pyx_k_out0_in1_0_0_floor_double_in0_do, sizeof(__pyx_k_out0_in1_0_0_floor_double_in0_do), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_out0_type_in0, __pyx_k_out0_out0_type_in0, sizeof(__pyx_k_out0_out0_type_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_out0_type_in0_out0_type_in1, __pyx_k_out0_out0_type_in0_out0_type_in1, sizeof(__pyx_k_out0_out0_type_in0_out0_type_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_pow_in0_in1, __pyx_k_out0_pow_in0_in1, sizeof(__pyx_k_out0_pow_in0_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_powf_in0_in1, __pyx_k_out0_powf_in0_in1, sizeof(__pyx_k_out0_powf_in0_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_real_in0, __pyx_k_out0_real_in0, sizeof(__pyx_k_out0_real_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_rint_pow_double_in0_double, __pyx_k_out0_rint_pow_double_in0_double, sizeof(__pyx_k_out0_rint_pow_double_in0_double), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_sqrt_in0, __pyx_k_out0_sqrt_in0, sizeof(__pyx_k_out0_sqrt_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_type_a__floor_divide_in0_i, __pyx_k_out0_type_a__floor_divide_in0_i, sizeof(__pyx_k_out0_type_a__floor_divide_in0_i), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_type_out0_raw_a, __pyx_k_out0_type_out0_raw_a, sizeof(__pyx_k_out0_type_out0_raw_a), 0, 0, 1, 0},
  {&__pyx_kp_s_out_0__type_out_0__raw_out_0__in, __pyx_k_out_0__type_out_0__raw_out_0__in, sizeof(__pyx_k_out_0__type_out_0__raw_out_0__in), 0, 0, 1, 0},
  {&__pyx_kp_s_out_a, __pyx_k_out_a, sizeof(__pyx_k_out_a), 0, 0, 1, 0},
  {&__pyx_kp_s_out_alpha_a, __pyx_k_out_alpha_a, sizeof(__pyx_k_out_alpha_a), 0, 0, 1, 0},
  {&__pyx_n_s_out_arg_dtype, __pyx_k_out_arg_dtype, sizeof(__pyx_k_out_arg_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_out_args, __pyx_k_out_args, sizeof(__pyx_k_out_args), 0, 0, 1, 1},
  {&__pyx_n_s_out_args_dtype, __pyx_k_out_args_dtype, sizeof(__pyx_k_out_args_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_out_clp2_size, __pyx_k_out_clp2_size, sizeof(__pyx_k_out_clp2_size), 0, 0, 1, 1},
  {&__pyx_n_s_out_indexer, __pyx_k_out_indexer, sizeof(__pyx_k_out_indexer), 0, 0, 1, 1},
  {&__pyx_n_s_out_ndarray_types, __pyx_k_out_ndarray_types, sizeof(__pyx_k_out_ndarray_types), 0, 0, 1, 1},
  {&__pyx_n_s_out_params, __pyx_k_out_params, sizeof(__pyx_k_out_params), 0, 0, 1, 1},
  {&__pyx_n_s_out_params_2, __pyx_k_out_params_2, sizeof(__pyx_k_out_params_2), 0, 0, 1, 1},
  {&__pyx_n_s_out_shape, __pyx_k_out_shape, sizeof(__pyx_k_out_shape), 0, 0, 1, 1},
  {&__pyx_n_s_out_str, __pyx_k_out_str, sizeof(__pyx_k_out_str), 0, 0, 1, 1},
  {&__pyx_n_s_out_types, __pyx_k_out_types, sizeof(__pyx_k_out_types), 0, 0, 1, 1},
  {&__pyx_n_s_output_expr, __pyx_k_output_expr, sizeof(__pyx_k_output_expr), 0, 0, 1, 1},
  {&__pyx_n_s_output_expr_2, __pyx_k_output_expr_2, sizeof(__pyx_k_output_expr_2), 0, 0, 1, 1},
  {&__pyx_kp_s_output_typecode_could_not_be_coe, __pyx_k_output_typecode_could_not_be_coe, sizeof(__pyx_k_output_typecode_could_not_be_coe), 0, 0, 1, 0},
  {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1},
  {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1},
  {&__pyx_n_s_param, __pyx_k_param, sizeof(__pyx_k_param), 0, 0, 1, 1},
  {&__pyx_n_s_params, __pyx_k_params, sizeof(__pyx_k_params), 0, 0, 1, 1},
  {&__pyx_n_s_params_2, __pyx_k_params_2, sizeof(__pyx_k_params_2), 0, 0, 1, 1},
  {&__pyx_n_s_partition_kernel, __pyx_k_partition_kernel, sizeof(__pyx_k_partition_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_partition_kernel_2, __pyx_k_partition_kernel_2, sizeof(__pyx_k_partition_kernel_2), 0, 0, 1, 1},
  {&__pyx_n_s_partition_merge_kernel, __pyx_k_partition_merge_kernel, sizeof(__pyx_k_partition_merge_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
  {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
  {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
  {&__pyx_n_s_post_map_expr, __pyx_k_post_map_expr, sizeof(__pyx_k_post_map_expr), 0, 0, 1, 1},
  {&__pyx_n_s_power, __pyx_k_power, sizeof(__pyx_k_power), 0, 0, 1, 1},
  {&__pyx_n_s_pre_map_expr, __pyx_k_pre_map_expr, sizeof(__pyx_k_pre_map_expr), 0, 0, 1, 1},
  {&__pyx_n_s_preamble, __pyx_k_preamble, sizeof(__pyx_k_preamble), 0, 0, 1, 1},
  {&__pyx_n_s_preamble_2, __pyx_k_preamble_2, sizeof(__pyx_k_preamble_2), 0, 0, 1, 1},
  {&__pyx_kp_s_preamble_extern_C___global___vo, __pyx_k_preamble_extern_C___global___vo, sizeof(__pyx_k_preamble_extern_C___global___vo), 0, 0, 1, 0},
  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  {&__pyx_n_s_prev, __pyx_k_prev, sizeof(__pyx_k_prev), 0, 0, 1, 1},
  {&__pyx_n_s_prod, __pyx_k_prod, sizeof(__pyx_k_prod), 0, 0, 1, 1},
  {&__pyx_n_s_prod_auto_dtype, __pyx_k_prod_auto_dtype, sizeof(__pyx_k_prod_auto_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_prod_keep_dtype, __pyx_k_prod_keep_dtype, sizeof(__pyx_k_prod_keep_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_property, __pyx_k_property, sizeof(__pyx_k_property), 0, 0, 1, 1},
  {&__pyx_kp_s_provided_op_is_not_supported, __pyx_k_provided_op_is_not_supported, sizeof(__pyx_k_provided_op_is_not_supported), 0, 0, 1, 0},
  {&__pyx_n_s_ptr, __pyx_k_ptr, sizeof(__pyx_k_ptr), 0, 0, 1, 1},
  {&__pyx_kp_s_ptrdiff_t_axis_ind__ind_get_axi, __pyx_k_ptrdiff_t_axis_ind__ind_get_axi, sizeof(__pyx_k_ptrdiff_t_axis_ind__ind_get_axi), 0, 0, 1, 0},
  {&__pyx_kp_s_ptrdiff_t_middle_i_base_ptrdiff, __pyx_k_ptrdiff_t_middle_i_base_ptrdiff, sizeof(__pyx_k_ptrdiff_t_middle_i_base_ptrdiff), 0, 0, 1, 0},
  {&__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_ElementwiseKernel, __pyx_k_pyx_unpickle_ElementwiseKernel, sizeof(__pyx_k_pyx_unpickle_ElementwiseKernel), 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_unpickle_Indexer, __pyx_k_pyx_unpickle_Indexer, sizeof(__pyx_k_pyx_unpickle_Indexer), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_ParameterInfo, __pyx_k_pyx_unpickle_ParameterInfo, sizeof(__pyx_k_pyx_unpickle_ParameterInfo), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_broadcast, __pyx_k_pyx_unpickle_broadcast, sizeof(__pyx_k_pyx_unpickle_broadcast), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_kp_s_q, __pyx_k_q, sizeof(__pyx_k_q), 0, 0, 1, 0},
  {&__pyx_kp_s_q_2, __pyx_k_q_2, sizeof(__pyx_k_q_2), 0, 0, 1, 0},
  {&__pyx_kp_s_q_d, __pyx_k_q_d, sizeof(__pyx_k_q_d), 0, 0, 1, 0},
  {&__pyx_kp_s_q_q, __pyx_k_q_q, sizeof(__pyx_k_q_q), 0, 0, 1, 0},
  {&__pyx_kp_s_q_q_2, __pyx_k_q_q_2, sizeof(__pyx_k_q_q_2), 0, 0, 1, 0},
  {&__pyx_kp_s_qq, __pyx_k_qq, sizeof(__pyx_k_qq), 0, 0, 1, 0},
  {&__pyx_kp_s_qq_d, __pyx_k_qq_d, sizeof(__pyx_k_qq_d), 0, 0, 1, 0},
  {&__pyx_kp_s_qq_q, __pyx_k_qq_q, sizeof(__pyx_k_qq_q), 0, 0, 1, 0},
  {&__pyx_kp_s_qq_qq, __pyx_k_qq_qq, sizeof(__pyx_k_qq_qq), 0, 0, 1, 0},
  {&__pyx_kp_s_qqq_q, __pyx_k_qqq_q, sizeof(__pyx_k_qqq_q), 0, 0, 1, 0},
  {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  {&__pyx_n_s_radd, __pyx_k_radd, sizeof(__pyx_k_radd), 0, 0, 1, 1},
  {&__pyx_n_s_raise, __pyx_k_raise, sizeof(__pyx_k_raise), 0, 0, 1, 1},
  {&__pyx_n_s_rand, __pyx_k_rand, sizeof(__pyx_k_rand), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_ravel, __pyx_k_ravel, sizeof(__pyx_k_ravel), 0, 0, 1, 1},
  {&__pyx_n_s_raw, __pyx_k_raw, sizeof(__pyx_k_raw), 0, 0, 1, 1},
  {&__pyx_n_s_raw_2, __pyx_k_raw_2, sizeof(__pyx_k_raw_2), 0, 0, 1, 1},
  {&__pyx_kp_s_raw_P_x_int32_axis_raw_int64_cum, __pyx_k_raw_P_x_int32_axis_raw_int64_cum, sizeof(__pyx_k_raw_P_x_int32_axis_raw_int64_cum), 0, 0, 1, 0},
  {&__pyx_kp_s_raw_P_x_int64_base, __pyx_k_raw_P_x_int64_base, sizeof(__pyx_k_raw_P_x_int64_base), 0, 0, 1, 0},
  {&__pyx_kp_s_raw_T_a, __pyx_k_raw_T_a, sizeof(__pyx_k_raw_T_a), 0, 0, 1, 0},
  {&__pyx_kp_s_raw_T_a_S_indices_int32_cdim_int, __pyx_k_raw_T_a_S_indices_int32_cdim_int, sizeof(__pyx_k_raw_T_a_S_indices_int32_cdim_int), 0, 0, 1, 0},
  {&__pyx_kp_s_raw_T_a_S_indices_int32_rdim_S_i, __pyx_k_raw_T_a_S_indices_int32_rdim_S_i, sizeof(__pyx_k_raw_T_a_S_indices_int32_rdim_S_i), 0, 0, 1, 0},
  {&__pyx_kp_s_raw_T_out, __pyx_k_raw_T_out, sizeof(__pyx_k_raw_T_out), 0, 0, 1, 0},
  {&__pyx_kp_s_raw_T_v_S_indices_int32_cdim_int, __pyx_k_raw_T_v_S_indices_int32_cdim_int, sizeof(__pyx_k_raw_T_v_S_indices_int32_cdim_int), 0, 0, 1, 0},
  {&__pyx_kp_s_raw_T_v_bool_mask_S_mask_scanned, __pyx_k_raw_T_v_bool_mask_S_mask_scanned, sizeof(__pyx_k_raw_T_v_bool_mask_S_mask_scanned), 0, 0, 1, 0},
  {&__pyx_n_s_raxis, __pyx_k_raxis, sizeof(__pyx_k_raxis), 0, 0, 1, 1},
  {&__pyx_n_s_rdiv, __pyx_k_rdiv, sizeof(__pyx_k_rdiv), 0, 0, 1, 1},
  {&__pyx_n_s_rdivmod, __pyx_k_rdivmod, sizeof(__pyx_k_rdivmod), 0, 0, 1, 1},
  {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1},
  {&__pyx_n_s_real, __pyx_k_real, sizeof(__pyx_k_real), 0, 0, 1, 1},
  {&__pyx_n_s_real_setter, __pyx_k_real_setter, sizeof(__pyx_k_real_setter), 0, 0, 1, 1},
  {&__pyx_n_s_record, __pyx_k_record, sizeof(__pyx_k_record), 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_dims, __pyx_k_reduce_dims, sizeof(__pyx_k_reduce_dims), 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_reduce_expr, __pyx_k_reduce_expr, sizeof(__pyx_k_reduce_expr), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_kernel, __pyx_k_reduce_kernel, sizeof(__pyx_k_reduce_kernel), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_type, __pyx_k_reduce_type, sizeof(__pyx_k_reduce_type), 0, 0, 1, 1},
  {&__pyx_n_s_reduced_view, __pyx_k_reduced_view, sizeof(__pyx_k_reduced_view), 0, 0, 1, 1},
  {&__pyx_n_s_remainder, __pyx_k_remainder, sizeof(__pyx_k_remainder), 0, 0, 1, 1},
  {&__pyx_n_s_repeat, __pyx_k_repeat, sizeof(__pyx_k_repeat), 0, 0, 1, 1},
  {&__pyx_kp_s_repeated_axis, __pyx_k_repeated_axis, sizeof(__pyx_k_repeated_axis), 0, 0, 1, 0},
  {&__pyx_n_s_repeats, __pyx_k_repeats, sizeof(__pyx_k_repeats), 0, 0, 1, 1},
  {&__pyx_kp_s_repeats_and_axis_of_a_should_be, __pyx_k_repeats_and_axis_of_a_should_be, sizeof(__pyx_k_repeats_and_axis_of_a_should_be), 0, 0, 1, 0},
  {&__pyx_kp_s_repeats_should_be_int_or_sequen, __pyx_k_repeats_should_be_int_or_sequen, sizeof(__pyx_k_repeats_should_be_int_or_sequen), 0, 0, 1, 0},
  {&__pyx_kp_s_repeats_should_not_be_negative, __pyx_k_repeats_should_not_be_negative, sizeof(__pyx_k_repeats_should_not_be_negative), 0, 0, 1, 0},
  {&__pyx_n_s_repr, __pyx_k_repr, sizeof(__pyx_k_repr), 0, 0, 1, 1},
  {&__pyx_n_s_require_sortable_dtype, __pyx_k_require_sortable_dtype, sizeof(__pyx_k_require_sortable_dtype), 0, 0, 1, 1},
  {&__pyx_kp_s_requires_a_ndim_1, __pyx_k_requires_a_ndim_1, sizeof(__pyx_k_requires_a_ndim_1), 0, 0, 1, 0},
  {&__pyx_n_s_reshape, __pyx_k_reshape, sizeof(__pyx_k_reshape), 0, 0, 1, 1},
  {&__pyx_n_s_reshape_2, __pyx_k_reshape_2, sizeof(__pyx_k_reshape_2), 0, 0, 1, 1},
  {&__pyx_n_s_result_type, __pyx_k_result_type, sizeof(__pyx_k_result_type), 0, 0, 1, 1},
  {&__pyx_n_s_ret, __pyx_k_ret, sizeof(__pyx_k_ret), 0, 0, 1, 1},
  {&__pyx_n_s_ret_shape, __pyx_k_ret_shape, sizeof(__pyx_k_ret_shape), 0, 0, 1, 1},
  {&__pyx_n_s_rfloordiv, __pyx_k_rfloordiv, sizeof(__pyx_k_rfloordiv), 0, 0, 1, 1},
  {&__pyx_n_s_ri, __pyx_k_ri, sizeof(__pyx_k_ri), 0, 0, 1, 1},
  {&__pyx_n_s_right_shift, __pyx_k_right_shift, sizeof(__pyx_k_right_shift), 0, 0, 1, 1},
  {&__pyx_n_s_rlshift, __pyx_k_rlshift, sizeof(__pyx_k_rlshift), 0, 0, 1, 1},
  {&__pyx_n_s_rmatmul, __pyx_k_rmatmul, sizeof(__pyx_k_rmatmul), 0, 0, 1, 1},
  {&__pyx_n_s_rmod, __pyx_k_rmod, sizeof(__pyx_k_rmod), 0, 0, 1, 1},
  {&__pyx_n_s_rmul, __pyx_k_rmul, sizeof(__pyx_k_rmul), 0, 0, 1, 1},
  {&__pyx_n_s_rollaxis, __pyx_k_rollaxis, sizeof(__pyx_k_rollaxis), 0, 0, 1, 1},
  {&__pyx_n_s_ror, __pyx_k_ror, sizeof(__pyx_k_ror), 0, 0, 1, 1},
  {&__pyx_n_s_routine, __pyx_k_routine, sizeof(__pyx_k_routine), 0, 0, 1, 1},
  {&__pyx_n_s_routine_cache, __pyx_k_routine_cache, sizeof(__pyx_k_routine_cache), 0, 0, 1, 1},
  {&__pyx_n_s_rpow, __pyx_k_rpow, sizeof(__pyx_k_rpow), 0, 0, 1, 1},
  {&__pyx_n_s_rrshift, __pyx_k_rrshift, sizeof(__pyx_k_rrshift), 0, 0, 1, 1},
  {&__pyx_n_s_rsub, __pyx_k_rsub, sizeof(__pyx_k_rsub), 0, 0, 1, 1},
  {&__pyx_n_s_rtruediv, __pyx_k_rtruediv, sizeof(__pyx_k_rtruediv), 0, 0, 1, 1},
  {&__pyx_n_s_rundim, __pyx_k_rundim, sizeof(__pyx_k_rundim), 0, 0, 1, 1},
  {&__pyx_n_s_rxor, __pyx_k_rxor, sizeof(__pyx_k_rxor), 0, 0, 1, 1},
  {&__pyx_kp_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 0},
  {&__pyx_n_s_s_2, __pyx_k_s_2, sizeof(__pyx_k_s_2), 0, 0, 1, 1},
  {&__pyx_kp_s_s_s, __pyx_k_s_s, sizeof(__pyx_k_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_s, __pyx_k_s_s_s, sizeof(__pyx_k_s_s_s), 0, 0, 1, 0},
  {&__pyx_n_s_same_kind, __pyx_k_same_kind, sizeof(__pyx_k_same_kind), 0, 0, 1, 1},
  {&__pyx_n_s_same_shape_and_contiguous, __pyx_k_same_shape_and_contiguous, sizeof(__pyx_k_same_shape_and_contiguous), 0, 0, 1, 1},
  {&__pyx_kp_s_scatter_add_only_supports_int32, __pyx_k_scatter_add_only_supports_int32, sizeof(__pyx_k_scatter_add_only_supports_int32), 0, 0, 1, 0},
  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__pyx_kp_s_self_ptr_cannot_be_converted_to, __pyx_k_self_ptr_cannot_be_converted_to, sizeof(__pyx_k_self_ptr_cannot_be_converted_to), 0, 0, 1, 0},
  {&__pyx_kp_s_self_ptr_self_val_cannot_be_conv, __pyx_k_self_ptr_self_val_cannot_be_conv, sizeof(__pyx_k_self_ptr_self_val_cannot_be_conv), 0, 0, 1, 0},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_n_s_sep, __pyx_k_sep, sizeof(__pyx_k_sep), 0, 0, 1, 1},
  {&__pyx_n_s_set, __pyx_k_set, sizeof(__pyx_k_set), 0, 0, 1, 1},
  {&__pyx_n_s_set_shape_and_strides, __pyx_k_set_shape_and_strides, sizeof(__pyx_k_set_shape_and_strides), 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_sgeam, __pyx_k_sgeam, sizeof(__pyx_k_sgeam), 0, 0, 1, 1},
  {&__pyx_n_s_sgemmBatched, __pyx_k_sgemmBatched, sizeof(__pyx_k_sgemmBatched), 0, 0, 1, 1},
  {&__pyx_n_s_sgemmStridedBatched, __pyx_k_sgemmStridedBatched, sizeof(__pyx_k_sgemmStridedBatched), 0, 0, 1, 1},
  {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
  {&__pyx_n_s_shape_2, __pyx_k_shape_2, sizeof(__pyx_k_shape_2), 0, 0, 1, 1},
  {&__pyx_kp_s_shape_mismatch_objects_cannot_be, __pyx_k_shape_mismatch_objects_cannot_be, sizeof(__pyx_k_shape_mismatch_objects_cannot_be), 0, 0, 1, 0},
  {&__pyx_kp_s_shapes_and_not_aligned, __pyx_k_shapes_and_not_aligned, sizeof(__pyx_k_shapes_and_not_aligned), 0, 0, 1, 0},
  {&__pyx_n_s_shared_mem, __pyx_k_shared_mem, sizeof(__pyx_k_shared_mem), 0, 0, 1, 1},
  {&__pyx_n_s_short, __pyx_k_short, sizeof(__pyx_k_short), 0, 0, 1, 1},
  {&__pyx_kp_s_signed_char, __pyx_k_signed_char, sizeof(__pyx_k_signed_char), 0, 0, 1, 0},
  {&__pyx_n_s_simple_reduction_function, __pyx_k_simple_reduction_function, sizeof(__pyx_k_simple_reduction_function), 0, 0, 1, 1},
  {&__pyx_n_s_simple_reduction_function___call, __pyx_k_simple_reduction_function___call, sizeof(__pyx_k_simple_reduction_function___call), 0, 0, 1, 1},
  {&__pyx_n_s_simple_reduction_function___init, __pyx_k_simple_reduction_function___init, sizeof(__pyx_k_simple_reduction_function___init), 0, 0, 1, 1},
  {&__pyx_n_s_six, __pyx_k_six, sizeof(__pyx_k_six), 0, 0, 1, 1},
  {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
  {&__pyx_n_s_slices, __pyx_k_slices, sizeof(__pyx_k_slices), 0, 0, 1, 1},
  {&__pyx_n_s_sort, __pyx_k_sort, sizeof(__pyx_k_sort), 0, 0, 1, 1},
  {&__pyx_n_s_source, __pyx_k_source, sizeof(__pyx_k_source), 0, 0, 1, 1},
  {&__pyx_kp_s_source_and_destination_argument, __pyx_k_source_and_destination_argument, sizeof(__pyx_k_source_and_destination_argument), 0, 0, 1, 0},
  {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
  {&__pyx_n_s_sqrt, __pyx_k_sqrt, sizeof(__pyx_k_sqrt), 0, 0, 1, 1},
  {&__pyx_n_s_squeeze, __pyx_k_squeeze, sizeof(__pyx_k_squeeze), 0, 0, 1, 1},
  {&__pyx_n_s_src_dtype, __pyx_k_src_dtype, sizeof(__pyx_k_src_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_src_ndim, __pyx_k_src_ndim, sizeof(__pyx_k_src_ndim), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_s_start_adr, __pyx_k_start_adr, sizeof(__pyx_k_start_adr), 0, 0, 1, 1},
  {&__pyx_kp_s_static_cast_U_x_static_cast_U_y, __pyx_k_static_cast_U_x_static_cast_U_y, sizeof(__pyx_k_static_cast_U_x_static_cast_U_y), 0, 0, 1, 0},
  {&__pyx_n_s_std, __pyx_k_std, sizeof(__pyx_k_std), 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_n_s_stream, __pyx_k_stream, sizeof(__pyx_k_stream), 0, 0, 1, 1},
  {&__pyx_n_s_stride, __pyx_k_stride, sizeof(__pyx_k_stride), 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_strides, __pyx_k_strides, sizeof(__pyx_k_strides), 0, 0, 1, 1},
  {&__pyx_n_s_string, __pyx_k_string, sizeof(__pyx_k_string), 0, 0, 1, 1},
  {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
  {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
  {&__pyx_n_s_subok, __pyx_k_subok, sizeof(__pyx_k_subok), 0, 0, 1, 1},
  {&__pyx_kp_s_subok_is_not_supported_yet, __pyx_k_subok_is_not_supported_yet, sizeof(__pyx_k_subok_is_not_supported_yet), 0, 0, 1, 0},
  {&__pyx_n_s_substitute, __pyx_k_substitute, sizeof(__pyx_k_substitute), 0, 0, 1, 1},
  {&__pyx_n_s_subtract, __pyx_k_subtract, sizeof(__pyx_k_subtract), 0, 0, 1, 1},
  {&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1},
  {&__pyx_n_s_sum_auto_dtype, __pyx_k_sum_auto_dtype, sizeof(__pyx_k_sum_auto_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_sum_keep_dtype, __pyx_k_sum_keep_dtype, sizeof(__pyx_k_sum_keep_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
  {&__pyx_n_s_swapaxes, __pyx_k_swapaxes, sizeof(__pyx_k_swapaxes), 0, 0, 1, 1},
  {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
  {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
  {&__pyx_kp_s_t_n__raw__n__ind_get, __pyx_k_t_n__raw__n__ind_get, sizeof(__pyx_k_t_n__raw__n__ind_get), 0, 0, 1, 0},
  {&__pyx_n_s_take, __pyx_k_take, sizeof(__pyx_k_take), 0, 0, 1, 1},
  {&__pyx_kp_s_template_typename_T___device, __pyx_k_template_typename_T___device, sizeof(__pyx_k_template_typename_T___device), 0, 0, 1, 0},
  {&__pyx_kp_s_template_typename_T_struct_min, __pyx_k_template_typename_T_struct_min, sizeof(__pyx_k_template_typename_T_struct_min), 0, 0, 1, 0},
  {&__pyx_n_s_tensordot_core_mul_sum, __pyx_k_tensordot_core_mul_sum, sizeof(__pyx_k_tensordot_core_mul_sum), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_kp_s_this_op_is_not_supported, __pyx_k_this_op_is_not_supported, sizeof(__pyx_k_this_op_is_not_supported), 0, 0, 1, 0},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_n_s_thrust, __pyx_k_thrust, sizeof(__pyx_k_thrust), 0, 0, 1, 1},
  {&__pyx_n_s_thrust_enabled, __pyx_k_thrust_enabled, sizeof(__pyx_k_thrust_enabled), 0, 0, 1, 1},
  {&__pyx_kp_s_to_environment_variable_CUDA_PAT, __pyx_k_to_environment_variable_CUDA_PAT, sizeof(__pyx_k_to_environment_variable_CUDA_PAT), 0, 0, 1, 0},
  {&__pyx_n_s_tofile, __pyx_k_tofile, sizeof(__pyx_k_tofile), 0, 0, 1, 1},
  {&__pyx_n_s_tolist, __pyx_k_tolist, sizeof(__pyx_k_tolist), 0, 0, 1, 1},
  {&__pyx_kp_s_too_many_indices_for_array, __pyx_k_too_many_indices_for_array, sizeof(__pyx_k_too_many_indices_for_array), 0, 0, 1, 0},
  {&__pyx_kp_s_total_size_of_new_array_must_be, __pyx_k_total_size_of_new_array_must_be, sizeof(__pyx_k_total_size_of_new_array_must_be), 0, 0, 1, 0},
  {&__pyx_n_s_trace, __pyx_k_trace, sizeof(__pyx_k_trace), 0, 0, 1, 1},
  {&__pyx_n_s_trans, __pyx_k_trans, sizeof(__pyx_k_trans), 0, 0, 1, 1},
  {&__pyx_n_s_transpose, __pyx_k_transpose, sizeof(__pyx_k_transpose), 0, 0, 1, 1},
  {&__pyx_n_s_transpose_2, __pyx_k_transpose_2, sizeof(__pyx_k_transpose_2), 0, 0, 1, 1},
  {&__pyx_n_s_true, __pyx_k_true, sizeof(__pyx_k_true), 0, 0, 1, 1},
  {&__pyx_n_s_true_divide, __pyx_k_true_divide, sizeof(__pyx_k_true_divide), 0, 0, 1, 1},
  {&__pyx_n_s_tup, __pyx_k_tup, sizeof(__pyx_k_tup), 0, 0, 1, 1},
  {&__pyx_n_s_type, __pyx_k_type, sizeof(__pyx_k_type), 0, 0, 1, 1},
  {&__pyx_n_s_type_dict, __pyx_k_type_dict, sizeof(__pyx_k_type_dict), 0, 0, 1, 1},
  {&__pyx_kp_s_type_out0_raw_out0__raw_out0__ou, __pyx_k_type_out0_raw_out0__raw_out0__ou, sizeof(__pyx_k_type_out0_raw_out0__raw_out0__ou), 0, 0, 1, 0},
  {&__pyx_n_s_type_preamble, __pyx_k_type_preamble, sizeof(__pyx_k_type_preamble), 0, 0, 1, 1},
  {&__pyx_kp_s_type_preamble_preamble_define_R, __pyx_k_type_preamble_preamble_define_R, sizeof(__pyx_k_type_preamble_preamble_define_R), 0, 0, 1, 0},
  {&__pyx_kp_s_typedef_s_in_d_type, __pyx_k_typedef_s_in_d_type, sizeof(__pyx_k_typedef_s_in_d_type), 0, 0, 1, 0},
  {&__pyx_kp_s_typedef_s_out_d_type, __pyx_k_typedef_s_out_d_type, sizeof(__pyx_k_typedef_s_out_d_type), 0, 0, 1, 0},
  {&__pyx_kp_s_typedef_s_s, __pyx_k_typedef_s_s, sizeof(__pyx_k_typedef_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_typedef_s_type_in0_raw_typedef_s, __pyx_k_typedef_s_type_in0_raw_typedef_s, sizeof(__pyx_k_typedef_s_type_in0_raw_typedef_s), 0, 0, 1, 0},
  {&__pyx_n_s_types, __pyx_k_types, sizeof(__pyx_k_types), 0, 0, 1, 1},
  {&__pyx_n_s_types_preamble, __pyx_k_types_preamble, sizeof(__pyx_k_types_preamble), 0, 0, 1, 1},
  {&__pyx_n_s_u, __pyx_k_u, sizeof(__pyx_k_u), 0, 0, 1, 1},
  {&__pyx_n_s_ufunc, __pyx_k_ufunc, sizeof(__pyx_k_ufunc), 0, 0, 1, 1},
  {&__pyx_n_s_ufunc___call, __pyx_k_ufunc___call, sizeof(__pyx_k_ufunc___call), 0, 0, 1, 1},
  {&__pyx_n_s_ufunc___init, __pyx_k_ufunc___init, sizeof(__pyx_k_ufunc___init), 0, 0, 1, 1},
  {&__pyx_n_s_ufunc___init___locals_genexpr, __pyx_k_ufunc___init___locals_genexpr, sizeof(__pyx_k_ufunc___init___locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_ufunc___repr, __pyx_k_ufunc___repr, sizeof(__pyx_k_ufunc___repr), 0, 0, 1, 1},
  {&__pyx_kp_s_ufunc_s, __pyx_k_ufunc_s, sizeof(__pyx_k_ufunc_s), 0, 0, 1, 0},
  {&__pyx_n_s_ufunc_types, __pyx_k_ufunc_types, sizeof(__pyx_k_ufunc_types), 0, 0, 1, 1},
  {&__pyx_n_s_uint16, __pyx_k_uint16, sizeof(__pyx_k_uint16), 0, 0, 1, 1},
  {&__pyx_n_s_uint32, __pyx_k_uint32, sizeof(__pyx_k_uint32), 0, 0, 1, 1},
  {&__pyx_n_s_uint64, __pyx_k_uint64, sizeof(__pyx_k_uint64), 0, 0, 1, 1},
  {&__pyx_n_s_uint8, __pyx_k_uint8, sizeof(__pyx_k_uint8), 0, 0, 1, 1},
  {&__pyx_n_s_uintp, __pyx_k_uintp, sizeof(__pyx_k_uintp), 0, 0, 1, 1},
  {&__pyx_n_s_ulonglong, __pyx_k_ulonglong, sizeof(__pyx_k_ulonglong), 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_unknown_ctype, __pyx_k_unknown_ctype, sizeof(__pyx_k_unknown_ctype), 0, 0, 1, 1},
  {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1},
  {&__pyx_n_s_unsafe, __pyx_k_unsafe, sizeof(__pyx_k_unsafe), 0, 0, 1, 1},
  {&__pyx_kp_s_unsigned_char, __pyx_k_unsigned_char, sizeof(__pyx_k_unsigned_char), 0, 0, 1, 0},
  {&__pyx_kp_s_unsigned_int, __pyx_k_unsigned_int, sizeof(__pyx_k_unsigned_int), 0, 0, 1, 0},
  {&__pyx_kp_s_unsigned_long_long, __pyx_k_unsigned_long_long, sizeof(__pyx_k_unsigned_long_long), 0, 0, 1, 0},
  {&__pyx_kp_s_unsigned_short, __pyx_k_unsigned_short, sizeof(__pyx_k_unsigned_short), 0, 0, 1, 0},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {&__pyx_n_s_update_c_contiguity, __pyx_k_update_c_contiguity, sizeof(__pyx_k_update_c_contiguity), 0, 0, 1, 1},
  {&__pyx_n_s_update_c_contiguity_2, __pyx_k_update_c_contiguity_2, sizeof(__pyx_k_update_c_contiguity_2), 0, 0, 1, 1},
  {&__pyx_n_s_update_contiguity, __pyx_k_update_contiguity, sizeof(__pyx_k_update_contiguity), 0, 0, 1, 1},
  {&__pyx_n_s_update_f_contiguity, __pyx_k_update_f_contiguity, sizeof(__pyx_k_update_f_contiguity), 0, 0, 1, 1},
  {&__pyx_n_s_util, __pyx_k_util, sizeof(__pyx_k_util), 0, 0, 1, 1},
  {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_n_s_var, __pyx_k_var, sizeof(__pyx_k_var), 0, 0, 1, 1},
  {&__pyx_n_s_var_2, __pyx_k_var_2, sizeof(__pyx_k_var_2), 0, 0, 1, 1},
  {&__pyx_n_s_var_core, __pyx_k_var_core, sizeof(__pyx_k_var_core), 0, 0, 1, 1},
  {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1},
  {&__pyx_n_s_view, __pyx_k_view, sizeof(__pyx_k_view), 0, 0, 1, 1},
  {&__pyx_n_s_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 0, 0, 1, 1},
  {&__pyx_n_s_warnings, __pyx_k_warnings, sizeof(__pyx_k_warnings), 0, 0, 1, 1},
  {&__pyx_n_s_wrap, __pyx_k_wrap, sizeof(__pyx_k_wrap), 0, 0, 1, 1},
  {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1},
  {&__pyx_kp_u_x___getitem___y_x_y_Supports_bot, __pyx_k_x___getitem___y_x_y_Supports_bot, sizeof(__pyx_k_x___getitem___y_x_y_Supports_bot), 0, 1, 0, 0},
  {&__pyx_kp_u_x___setitem___slices_y_x_slices, __pyx_k_x___setitem___slices_y_x_slices, sizeof(__pyx_k_x___setitem___slices_y_x_slices), 0, 1, 0, 0},
  {&__pyx_kp_s_x_mean_x_mean, __pyx_k_x_mean_x_mean, sizeof(__pyx_k_x_mean_x_mean), 0, 0, 1, 0},
  {&__pyx_kp_s_y_choices_i_n_channel_a, __pyx_k_y_choices_i_n_channel_a, sizeof(__pyx_k_y_choices_i_n_channel_a), 0, 0, 1, 0},
  {&__pyx_kp_s_zero_dimensional_arrays_cannot_b, __pyx_k_zero_dimensional_arrays_cannot_b, sizeof(__pyx_k_zero_dimensional_arrays_cannot_b), 0, 0, 1, 0},
  {&__pyx_kp_s_zero_size_array_to_reduction_ope, __pyx_k_zero_size_array_to_reduction_ope, sizeof(__pyx_k_zero_size_array_to_reduction_ope), 0, 0, 1, 0},
  {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1},
  {&__pyx_n_s_zgemmBatched, __pyx_k_zgemmBatched, sizeof(__pyx_k_zgemmBatched), 0, 0, 1, 1},
  {&__pyx_n_s_zgemmStridedBatched, __pyx_k_zgemmStridedBatched, sizeof(__pyx_k_zgemmStridedBatched), 0, 0, 1, 1},
  {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(0, 16, __pyx_L1_error)
  __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 45, __pyx_L1_error)
  __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(0, 46, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 46, __pyx_L1_error)
  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(1, 696, __pyx_L1_error)
  __pyx_builtin_property = __Pyx_GetBuiltinName(__pyx_n_s_property); if (!__pyx_builtin_property) __PYX_ERR(1, 734, __pyx_L1_error)
  __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 49, __pyx_L1_error)
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 56, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 362, __pyx_L1_error)
  __pyx_builtin_chr = __Pyx_GetBuiltinName(__pyx_n_s_chr); if (!__pyx_builtin_chr) __PYX_ERR(0, 371, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 544, __pyx_L1_error)
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 796, __pyx_L1_error)
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(0, 806, __pyx_L1_error)
  __pyx_builtin_NotImplemented = __Pyx_GetBuiltinName(__pyx_n_s_NotImplemented); if (!__pyx_builtin_NotImplemented) __PYX_ERR(0, 1264, __pyx_L1_error)
  __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s_sum); if (!__pyx_builtin_sum) __PYX_ERR(0, 1546, __pyx_L1_error)
  __pyx_builtin_oct = __Pyx_GetBuiltinName(__pyx_n_s_oct); if (!__pyx_builtin_oct) __PYX_ERR(0, 1633, __pyx_L1_error)
  __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) __PYX_ERR(0, 1636, __pyx_L1_error)
  __pyx_builtin_open = __Pyx_GetBuiltinName(__pyx_n_s_open); if (!__pyx_builtin_open) __PYX_ERR(2, 119, __pyx_L1_error)
  __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(1, 298, __pyx_L1_error)
  __pyx_builtin_map = __Pyx_GetBuiltinName(__pyx_n_s_map); if (!__pyx_builtin_map) __PYX_ERR(1, 842, __pyx_L1_error)
  __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(4, 147, __pyx_L1_error)
  __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(4, 399, __pyx_L1_error)
  __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(4, 608, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "cupy/core/core.pyx":56
 * cdef int _normalize_order(str order) except? 0:
 *     if len(order) != 1:
 *         raise TypeError('order not understood')             # <<<<<<<<<<<<<<
 *     cdef int order_char = ord(order)
 *     if order_char == 'K' or order_char == 'k':
 */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_order_not_understood); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "cupy/core/core.pyx":67
 *         order_char = 'F'
 *     else:
 *         raise TypeError('order not understood')             # <<<<<<<<<<<<<<
 *     return order_char
 * 
 */
  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_order_not_understood); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "cupy/core/core.pyx":109
 *         for x in self._shape:
 *             if x < 0:
 *                 raise ValueError('Negative dimensions are not allowed')             # <<<<<<<<<<<<<<
 *         self.dtype = get_dtype(dtype)
 *         self.size = internal.prod_ssize_t(self._shape)
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_Negative_dimensions_are_not_allo); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "cupy/core/core.pyx":176
 *             strides = _get_strides_for_nocopy_reshape(self, shape)
 *             if strides.size() != shape.size():
 *                 raise AttributeError('incompatible shape')             # <<<<<<<<<<<<<<
 *             self._shape = shape
 *             self._strides = strides
 */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_incompatible_shape); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 176, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "cupy/core/core.pyx":330
 *         # TODO(beam2d): Support casting and subok option
 *         if casting is not None:
 *             raise TypeError('casting is not supported yet')             # <<<<<<<<<<<<<<
 *         if subok is not None:
 *             raise TypeError('subok is not supported yet')
 */
  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_casting_is_not_supported_yet); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "cupy/core/core.pyx":332
 *             raise TypeError('casting is not supported yet')
 *         if subok is not None:
 *             raise TypeError('subok is not supported yet')             # <<<<<<<<<<<<<<
 * 
 *         if order is None:
 */
  __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_subok_is_not_supported_yet); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "cupy/core/core.pyx":414
 *         else:
 *             # It need to make a contiguous copy for copying from another device
 *             with self.device:             # <<<<<<<<<<<<<<
 *                 x = self.astype(self.dtype, copy=False, order=order)
 *             newarray = ndarray(x.shape, dtype=x.dtype)
 */
  __pyx_tuple__9 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "cupy/core/core.pyx":447
 *         else:
 *             if self.ndim == 0:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     "Changing the dtype of a 0d array is only supported if "
 *                     "the itemsize is unchanged")
 */
  __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Changing_the_dtype_of_a_0d_array); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "cupy/core/core.pyx":451
 *                     "the itemsize is unchanged")
 *             if not self._c_contiguous:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     "To change to a dtype of a different size, the array must "
 *                     "be C-contiguous")
 */
  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_To_change_to_a_dtype_of_a_differ); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "cupy/core/core.pyx":482
 *         if isinstance(value, numpy.ndarray):
 *             if value.shape != ():
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'non-scalar numpy.ndarray cannot be used for fill')
 *             value = value.item()
 */
  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_non_scalar_numpy_ndarray_cannot); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 482, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "cupy/core/core.pyx":509
 * 
 *         if shape.size() != strides.size():
 *             raise ValueError('total size of new array must be unchanged')             # <<<<<<<<<<<<<<
 *         newarray._set_shape_and_strides(shape, strides, False)
 *         return newarray
 */
  __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_total_size_of_new_array_must_be); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);

  /* "cupy/core/core.pyx":548
 *             axis = axes[i]
 *             if axis < -ndim or axis >= ndim:
 *                 raise IndexError('Axes overrun')             # <<<<<<<<<<<<<<
 *             axes[i] = axis % ndim
 * 
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Axes_overrun); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 548, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "cupy/core/core.pyx":602
 *         cdef vector.vector[Py_ssize_t] axes
 *         if axis1 < -ndim or axis1 >= ndim or axis2 < -ndim or axis2 >= ndim:
 *             raise ValueError('Axis out of range')             # <<<<<<<<<<<<<<
 *         axis1 %= ndim
 *         axis2 %= ndim
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 602, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "cupy/core/core.pyx":676
 *                         (axis_orig, ndim, ndim))
 *                 if axis_flags[_axis] == 1:
 *                     raise ValueError("duplicate value in 'axis'")             # <<<<<<<<<<<<<<
 *                 axis_flags[_axis] = 1
 *         else:
 */
  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_duplicate_value_in_axis); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 676, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "cupy/core/core.pyx":701
 *                     any_ones = 1
 *                 else:
 *                     raise ValueError('cannot select an axis to squeeze out '             # <<<<<<<<<<<<<<
 *                                      'which has size not equal to one')
 * 
 */
  __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_cannot_select_an_axis_to_squeeze); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 701, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "cupy/core/core.pyx":749
 *         if a.ndim < choices.ndim - 1:
 *             for i in range(choices.ndim - 1 - a.ndim):
 *                 a = a[None, ...]             # <<<<<<<<<<<<<<
 *         elif a.ndim > choices.ndim - 1:
 *             for i in range(a.ndim + 1 - choices.ndim):
 */
  __pyx_tuple__18 = PyTuple_Pack(2, Py_None, Py_Ellipsis); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 749, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "cupy/core/core.pyx":752
 *         elif a.ndim > choices.ndim - 1:
 *             for i in range(a.ndim + 1 - choices.ndim):
 *                 choices = choices[:, None, ...]             # <<<<<<<<<<<<<<
 *         ba, bcs = broadcast(a, choices).values
 * 
 */
  __pyx_slice__19 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__19)) __PYX_ERR(0, 752, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__19);
  __Pyx_GIVEREF(__pyx_slice__19);
  __pyx_tuple__20 = PyTuple_Pack(3, __pyx_slice__19, Py_None, Py_Ellipsis); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 752, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "cupy/core/core.pyx":756
 * 
 *         if out is None:
 *             out = ndarray(ba.shape[1:], choices.dtype)             # <<<<<<<<<<<<<<
 * 
 *         n_channel = numpy.prod(bcs[0].shape)
 */
  __pyx_slice__21 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__21)) __PYX_ERR(0, 756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__21);
  __Pyx_GIVEREF(__pyx_slice__21);

  /* "cupy/core/core.pyx":761
 *         if mode == 'raise':
 *             if not ((a < n).all() and (0 <= a).all()):
 *                 raise ValueError('invalid entry in choice array')             # <<<<<<<<<<<<<<
 *             _choose_kernel(ba[0], bcs, n_channel, out)
 *         elif mode == 'wrap':
 */
  __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_invalid_entry_in_choice_array); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 761, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);

  /* "cupy/core/core.pyx":769
 *             _choose_clip_kernel(ba[0], bcs, n_channel, n, out)
 *         else:
 *             raise TypeError('clipmode not understood')             # <<<<<<<<<<<<<<
 * 
 *         return out
 */
  __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_clipmode_not_understood); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 769, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "cupy/core/core.pyx":796
 * 
 *         if not cupy.cuda.thrust_enabled:
 *             raise RuntimeError('Thrust is needed to use cupy.sort. Please '             # <<<<<<<<<<<<<<
 *                                'install CUDA Toolkit with Thrust then '
 *                                'reinstall CuPy after uninstalling it.')
 */
  __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_Thrust_is_needed_to_use_cupy_sor); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 796, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "cupy/core/core.pyx":801
 * 
 *         if ndim == 0:
 *             raise ValueError('Sorting arrays with the rank of zero is not '             # <<<<<<<<<<<<<<
 *                              'supported')  # as numpy.sort() raises
 * 
 */
  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_Sorting_arrays_with_the_rank_of); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "cupy/core/core.pyx":806
 *         # TODO(takagi): Support sorting views
 *         if not self._c_contiguous:
 *             raise NotImplementedError('Sorting non-contiguous array is not '             # <<<<<<<<<<<<<<
 *                                       'supported.')
 * 
 */
  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_Sorting_non_contiguous_array_is); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 806, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "cupy/core/core.pyx":812
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
  __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);

  /* "cupy/core/core.pyx":854
 * 
 *         if not cupy.cuda.thrust_enabled:
 *             raise RuntimeError('Thrust is needed to use cupy.argsort. Please '             # <<<<<<<<<<<<<<
 *                                'install CUDA Toolkit with Thrust then '
 *                                'reinstall CuPy after uninstalling it.')
 */
  __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_Thrust_is_needed_to_use_cupy_arg); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);

  /* "cupy/core/core.pyx":859
 * 
 *         if ndim == 0:
 *             raise ValueError('Sorting arrays with the rank of zero is not '             # <<<<<<<<<<<<<<
 *                              'supported')  # as numpy.argsort() raises
 * 
 */
  __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_Sorting_arrays_with_the_rank_of); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 859, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);

  /* "cupy/core/core.pyx":871
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
  __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 871, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);

  /* "cupy/core/core.pyx":917
 * 
 *         if ndim == 0:
 *             raise ValueError('Sorting arrays with the rank of zero is not '             # <<<<<<<<<<<<<<
 *                              'supported')
 * 
 */
  __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_Sorting_arrays_with_the_rank_of); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 917, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);

  /* "cupy/core/core.pyx":921
 * 
 *         if not self._c_contiguous:
 *             raise NotImplementedError('Sorting non-contiguous array is not '             # <<<<<<<<<<<<<<
 *                                       'supported.')
 * 
 */
  __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_Sorting_non_contiguous_array_is); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 921, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);

  /* "cupy/core/core.pyx":927
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         if axis == ndim - 1:
 */
  __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);

  /* "cupy/core/core.pyx":1021
 *             axis += ndim
 *         if not (0 <= axis < ndim):
 *             raise _AxisError('Axis out of range')             # <<<<<<<<<<<<<<
 * 
 *         length = data.shape[axis]
 */
  __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 1021, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);

  /* "cupy/core/core.pyx":1064
 *         ndim = max(self._shape.size(), 1)
 *         if count_nonzero == 0:
 *             return (ndarray((0,), dtype=dtype),) * ndim             # <<<<<<<<<<<<<<
 * 
 *         dst = ndarray((count_nonzero * ndim,), dtype=dtype)
 */
  __pyx_tuple__35 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 1064, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);
  __pyx_tuple__36 = PyTuple_Pack(1, __pyx_tuple__35); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 1064, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);

  /* "cupy/core/core.pyx":1149
 *         """
 *         if a_min is None and a_max is None:
 *             raise ValueError('array_clip: must set either max or min')             # <<<<<<<<<<<<<<
 *         if a_min is None:
 *             if issubclass(self.dtype.type, numpy.floating):
 */
  __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_array_clip_must_set_either_max_o); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 1149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);

  /* "cupy/core/core.pyx":1152
 *         if a_min is None:
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_min = self.dtype.type('-inf')             # <<<<<<<<<<<<<<
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_min = numpy.iinfo(self.dtype.type).min
 */
  __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_inf); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 1152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);

  /* "cupy/core/core.pyx":1157
 *         if a_max is None:
 *             if issubclass(self.dtype.type, numpy.floating):
 *                 a_max = self.dtype.type('inf')             # <<<<<<<<<<<<<<
 *             elif issubclass(self.dtype.type, numpy.integer):
 *                 a_max = numpy.iinfo(self.dtype.type).max
 */
  __pyx_tuple__39 = PyTuple_Pack(1, __pyx_n_s_inf_2); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 1157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);

  /* "cupy/core/core.pyx":1468
 *             _imag_setter(value, self)
 *         else:
 *             raise TypeError('cupy.ndarray does not have imaginary part to set')             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_cupy_ndarray_does_not_have_imagi); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 1468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);

  /* "cupy/core/core.pyx":1480
 *     def __deepcopy__(self, memo):
 *         if self.device is not None:
 *             with self.device:             # <<<<<<<<<<<<<<
 *                 return self.copy()
 *         else:
 */
  __pyx_tuple__41 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 1480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);
  __pyx_tuple__42 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 1480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "cupy/core/core.pyx":1504
 *     def __len__(self):
 *         if self._shape.size() == 0:
 *             raise TypeError('len() of unsized object')             # <<<<<<<<<<<<<<
 *         return self._shape[0]
 * 
 */
  __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_s_len_of_unsized_object); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 1504, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);

  /* "cupy/core/core.pyx":1682
 *             return numpy.ndarray(self._shape, dtype=self.dtype)
 * 
 *         with self.device:             # <<<<<<<<<<<<<<
 *             a_gpu = ascontiguousarray(self)
 *         a_cpu = numpy.empty(self._shape, dtype=self.dtype)
 */
  __pyx_tuple__44 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 1682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);

  /* "cupy/core/core.pyx":1707
 *         """
 *         if not isinstance(arr, numpy.ndarray):
 *             raise TypeError('Only numpy.ndarray can be set to cupy.ndarray')             # <<<<<<<<<<<<<<
 *         if self.dtype != arr.dtype:
 *             raise TypeError('{} array cannot be set to {} array'.format(
 */
  __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_Only_numpy_ndarray_can_be_set_to); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 1707, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);

  /* "cupy/core/core.pyx":1720
 *             arr = numpy.asfortranarray(arr)
 *         else:
 *             raise RuntimeError('Cannot set to non-contiguous array')             # <<<<<<<<<<<<<<
 * 
 *         ptr = arr.ctypes.get_as_parameter()
 */
  __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_to_non_contiguous_arr); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 1720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);

  /* "cupy/core/core.pyx":1790
 *                                  bint update_c_contiguity=True):
 *         if shape.size() != strides.size():
 *             raise ValueError('len(shape) != len(strides)')             # <<<<<<<<<<<<<<
 *         self._shape = shape
 *         self._strides = strides
 */
  __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_s_len_shape_len_strides); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 1790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_self_val_cannot_be_conv); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr,self.val cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_self_val_cannot_be_conv); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_cannot_be_converted_to); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);

  /* "(tree fragment)":4
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.ptr cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_cannot_be_converted_to); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);

  /* "cupy/core/carray.pxi":119
 *         for file_path in _cupy_header_list + _cupy_extra_header_list:
 *             header_path = os.path.join(base_path, file_path)
 *             with open(header_path) as header_file:             # <<<<<<<<<<<<<<
 *                 source.append(header_file.read())
 *         _header_source = '\n'.join(source)
 */
  __pyx_tuple__52 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(2, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);

  /* "cupy/core/elementwise.pxi":17
 *         params, operation, name, preamble,
 *         loop_prep='', after_loop='', options=()):
 *     module_code = string.Template('''             # <<<<<<<<<<<<<<
 *     ${preamble}
 *     extern "C" __global__ void ${name}(${params}) {
 */
  __pyx_tuple__54 = PyTuple_Pack(1, __pyx_kp_s_preamble_extern_C___global___vo); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__54);
  __Pyx_GIVEREF(__pyx_tuple__54);

  /* "cupy/core/elementwise.pxi":108
 * cpdef str _get_typename(dtype):
 *     if dtype is None:
 *         raise ValueError('dtype is None')             # <<<<<<<<<<<<<<
 *     if dtype not in _typenames:
 *         dtype = get_dtype(dtype).type
 */
  __pyx_tuple__55 = PyTuple_Pack(1, __pyx_kp_s_dtype_is_None); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(1, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);

  /* "cupy/core/elementwise.pxi":290
 *     if len(s) == 0:
 *         return ()
 *     return tuple([ParameterInfo(i, is_const) for i in s.strip().split(',')])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__58 = PyTuple_Pack(1, __pyx_kp_s__57); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(1, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_GIVEREF(__pyx_tuple__58);

  /* "cupy/core/elementwise.pxi":300
 *         for p, a in zip(out_params, out_args_dtype):
 *             if a is None:
 *                 raise TypeError('Output arguments must be cupy.ndarray')             # <<<<<<<<<<<<<<
 *             if p.dtype is not None:
 *                 if get_dtype(a) != get_dtype(p.dtype):
 */
  __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_s_Output_arguments_must_be_cupy_nd); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(1, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);

  /* "cupy/core/elementwise.pxi":360
 *     if use_size:
 *         if not is_none:
 *             raise ValueError("Specified 'size' can be used only "             # <<<<<<<<<<<<<<
 *                              "if all of the ndarray are 'raw'.")
 *     else:
 */
  __pyx_tuple__60 = PyTuple_Pack(1, __pyx_kp_s_Specified_size_can_be_used_only); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(1, 360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__60);
  __Pyx_GIVEREF(__pyx_tuple__60);

  /* "cupy/core/elementwise.pxi":364
 *     else:
 *         if not is_not_none:
 *             raise ValueError('Loop size is Undecided')             # <<<<<<<<<<<<<<
 *     brod = broadcast(*value)
 *     value = []
 */
  __pyx_tuple__61 = PyTuple_Pack(1, __pyx_kp_s_Loop_size_is_Undecided); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(1, 364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);

  /* "cupy/core/elementwise.pxi":382
 *     for i, a in enumerate(out_args):
 *         if not isinstance(a, ndarray):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'Output arguments type must be cupy.ndarray')
 *         if a.shape != out_shape:
 */
  __pyx_tuple__62 = PyTuple_Pack(1, __pyx_kp_s_Output_arguments_type_must_be_cu); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(1, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__62);
  __Pyx_GIVEREF(__pyx_tuple__62);

  /* "cupy/core/elementwise.pxi":385
 *                 'Output arguments type must be cupy.ndarray')
 *         if a.shape != out_shape:
 *             raise ValueError('Out shape is mismatched')             # <<<<<<<<<<<<<<
 *         out_type = out_types[i]
 *         if not numpy.can_cast(out_type, a.dtype, casting=casting):
 */
  __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_s_Out_shape_is_mismatched); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(1, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);

  /* "cupy/core/elementwise.pxi":405
 *         for p in out_params:
 *             if p.raw and is_size_specified is False:
 *                 raise ValueError('Output array size is Undecided')             # <<<<<<<<<<<<<<
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 */
  __pyx_tuple__64 = PyTuple_Pack(1, __pyx_kp_s_Output_array_size_is_Undecided); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(1, 405, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__64);
  __Pyx_GIVEREF(__pyx_tuple__64);

  /* "cupy/core/elementwise.pxi":412
 *         p = out_params[i]
 *         if not isinstance(a, ndarray):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'Output arguments type must be cupy.ndarray')
 *         if not p.raw and a.shape != out_shape:
 */
  __pyx_tuple__65 = PyTuple_Pack(1, __pyx_kp_s_Output_arguments_type_must_be_cu); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(1, 412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);

  /* "cupy/core/elementwise.pxi":415
 *                 'Output arguments type must be cupy.ndarray')
 *         if not p.raw and a.shape != out_shape:
 *             raise ValueError('Out shape is mismatched')             # <<<<<<<<<<<<<<
 *     return out_args
 * 
 */
  __pyx_tuple__66 = PyTuple_Pack(1, __pyx_kp_s_Out_shape_is_mismatched); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(1, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__66);
  __Pyx_GIVEREF(__pyx_tuple__66);

  /* "cupy/core/elementwise.pxi":502
 *         self.nout = len(self.out_params)
 *         self.nargs = self.nin + self.nout
 *         param_rest = _get_param_info('CIndexer _ind', False)             # <<<<<<<<<<<<<<
 *         self.params = self.in_params + self.out_params + param_rest
 *         self.operation = operation
 */
  __pyx_tuple__67 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__ind, Py_False); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(1, 502, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__67);
  __Pyx_GIVEREF(__pyx_tuple__67);

  /* "cupy/core/elementwise.pxi":511
 *         names = [p.name for p in self.in_params + self.out_params]
 *         if 'i' in names:
 *             raise ValueError("Can not use 'i' as a parameter name")             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, *args, **kwargs):
 */
  __pyx_tuple__68 = PyTuple_Pack(1, __pyx_kp_s_Can_not_use_i_as_a_parameter_nam); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(1, 511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__68);
  __Pyx_GIVEREF(__pyx_tuple__68);

  /* "cupy/core/elementwise.pxi":728
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 *             ParameterInfo('CIndexer _ind', False),)             # <<<<<<<<<<<<<<
 *         self._routine_cache = {}
 * 
 */
  __pyx_tuple__69 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__ind, Py_False); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(1, 728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__69);
  __Pyx_GIVEREF(__pyx_tuple__69);

  /* "cupy/core/elementwise.pxi":788
 *                 raise ValueError("Cannot use 'out' in %s" % self.name)
 *             if n_args != self.nin:
 *                 raise ValueError("Cannot specify 'out' as both "             # <<<<<<<<<<<<<<
 *                                  "a positional and keyword argument")
 * 
 */
  __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_s_Cannot_specify_out_as_both_a_pos); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(1, 788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__70);
  __Pyx_GIVEREF(__pyx_tuple__70);

  /* "cupy/core/elementwise.pxi":838
 *             typ, rt = t
 * 
 *         types = typ.split('->')             # <<<<<<<<<<<<<<
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)
 */
  __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_s__71); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(1, 838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__72);
  __Pyx_GIVEREF(__pyx_tuple__72);

  /* "cupy/core/reduction.pxi":16
 *     if identity is None:
 *         identity = ''
 *     module_code = string.Template('''             # <<<<<<<<<<<<<<
 *     ${type_preamble}
 *     ${preamble}
 */
  __pyx_tuple__73 = PyTuple_Pack(1, __pyx_kp_s_type_preamble_preamble_define_R); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(5, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__73);
  __Pyx_GIVEREF(__pyx_tuple__73);

  /* "cupy/core/reduction.pxi":120
 *     for dim in axis:
 *         if dim < -ndim or dim >= ndim:
 *             raise ValueError('Axis overrun')             # <<<<<<<<<<<<<<
 *     axis = tuple(sorted([dim % ndim for dim in axis]))
 *     raxis = tuple([dim for dim in range(ndim) if dim not in axis])
 */
  __pyx_tuple__74 = PyTuple_Pack(1, __pyx_kp_s_Axis_overrun); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(5, 120, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__74);
  __Pyx_GIVEREF(__pyx_tuple__74);

  /* "cupy/core/reduction.pxi":143
 *         for p in params:
 *             if p.raw:
 *                 raise NotImplementedError('Illegal conditions')             # <<<<<<<<<<<<<<
 *     args = [a.transpose(trans) if isinstance(a, ndarray) else a
 *             for a in args]
 */
  __pyx_tuple__75 = PyTuple_Pack(1, __pyx_kp_s_Illegal_conditions); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(5, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__75);
  __Pyx_GIVEREF(__pyx_tuple__75);

  /* "cupy/core/reduction.pxi":195
 *         self.nin = 1
 *         self.nout = 1
 *         in_params = _get_param_info('T in0', True)             # <<<<<<<<<<<<<<
 *         out_params = _get_param_info('T out0', False)
 *         self._params = (
 */
  __pyx_tuple__76 = PyTuple_Pack(2, __pyx_kp_s_T_in0, Py_True); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(5, 195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);

  /* "cupy/core/reduction.pxi":196
 *         self.nout = 1
 *         in_params = _get_param_info('T in0', True)
 *         out_params = _get_param_info('T out0', False)             # <<<<<<<<<<<<<<
 *         self._params = (
 *             in_params + out_params +
 */
  __pyx_tuple__77 = PyTuple_Pack(2, __pyx_kp_s_T_out0, Py_False); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(5, 196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__77);
  __Pyx_GIVEREF(__pyx_tuple__77);

  /* "cupy/core/reduction.pxi":199
 *         self._params = (
 *             in_params + out_params +
 *             _get_param_info(             # <<<<<<<<<<<<<<
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))
 */
  __pyx_tuple__78 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__in_ind_CIndexer__out_i, Py_False); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(5, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__78);
  __Pyx_GIVEREF(__pyx_tuple__78);

  /* "cupy/core/reduction.pxi":201
 *             _get_param_info(
 *                 'CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))             # <<<<<<<<<<<<<<
 *         self._input_expr = 'const type_in0_raw in0 = _raw_in0[_in_ind.get()];'
 *         self._output_expr = 'type_out0_raw &out0 = _raw_out0[_out_ind.get()];'
 */
  __pyx_tuple__79 = PyTuple_Pack(2, __pyx_kp_s_int32__block_stride, Py_True); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(5, 201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);

  /* "cupy/core/reduction.pxi":342
 *         self.params = (
 *             self.in_params + self.out_params +
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +             # <<<<<<<<<<<<<<
 *             _get_param_info('int32 _block_stride', True))
 *         self.identity = identity
 */
  __pyx_tuple__80 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__in_ind_CIndexer__out_i, Py_False); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(5, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__80);
  __Pyx_GIVEREF(__pyx_tuple__80);

  /* "cupy/core/reduction.pxi":343
 *             self.in_params + self.out_params +
 *             _get_param_info('CIndexer _in_ind, CIndexer _out_ind', False) +
 *             _get_param_info('int32 _block_stride', True))             # <<<<<<<<<<<<<<
 *         self.identity = identity
 *         self.reduce_expr = reduce_expr
 */
  __pyx_tuple__81 = PyTuple_Pack(2, __pyx_kp_s_int32__block_stride, Py_True); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(5, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__81);
  __Pyx_GIVEREF(__pyx_tuple__81);

  /* "cupy/core/reduction.pxi":388
 *         if out is not None:
 *             if self.nout != 1:
 *                 raise NotImplementedError('')             # <<<<<<<<<<<<<<
 *             if len(out_args) != 0:
 *                 raise ValueError("cannot specify 'out' as both "
 */
  __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_s__6); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(5, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__82);
  __Pyx_GIVEREF(__pyx_tuple__82);

  /* "cupy/core/reduction.pxi":390
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:
 *                 raise ValueError("cannot specify 'out' as both "             # <<<<<<<<<<<<<<
 *                                  "a positional and keyword argument")
 *             out_args = [out]
 */
  __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_s_cannot_specify_out_as_both_a_pos); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(5, 390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__83);
  __Pyx_GIVEREF(__pyx_tuple__83);

  /* "cupy/core/reduction.pxi":464
 *             rt = tuple([i or j for i, j in zip(rt, routine)])
 * 
 *         types = typ.split('->')             # <<<<<<<<<<<<<<
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)
 */
  __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_s__71); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(5, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__84);
  __Pyx_GIVEREF(__pyx_tuple__84);

  /* "cupy/core/core.pyx":2072
 *                 # When `copy` is False, `a` is same as `obj`.
 *                 a = a.view()
 *             a.shape = (1,) * (ndmin - ndim) + a.shape             # <<<<<<<<<<<<<<
 *     else:
 *         if order == 'K':
 */
  __pyx_tuple__85 = PyTuple_New(1); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(0, 2072, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__85);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__85, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__85);

  /* "cupy/core/core.pyx":2176
 *                              'dimension {}'.format(ax, ndim))
 *         if _has_element(ret, ax):
 *             raise _AxisError('repeated axis')             # <<<<<<<<<<<<<<
 *         ret.push_back(ax % ndim)
 * 
 */
  __pyx_tuple__86 = PyTuple_Pack(1, __pyx_kp_s_repeated_axis); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(0, 2176, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__86);
  __Pyx_GIVEREF(__pyx_tuple__86);

  /* "cupy/core/core.pyx":2188
 * 
 *     if len(src) != len(dest):
 *         raise ValueError('`source` and `destination` arguments must have '             # <<<<<<<<<<<<<<
 *                          'the same number of elements')
 * 
 */
  __pyx_tuple__87 = PyTuple_Pack(1, __pyx_kp_s_source_and_destination_argument); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(0, 2188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__87);
  __Pyx_GIVEREF(__pyx_tuple__87);

  /* "cupy/core/core.pyx":2213
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 *         raise ValueError('Axis out of range')             # <<<<<<<<<<<<<<
 *     if axis < start:
 *         start -= 1
 */
  __pyx_tuple__88 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(0, 2213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__88);
  __Pyx_GIVEREF(__pyx_tuple__88);

  /* "cupy/core/core.pyx":2235
 *     ndim = ary.ndim
 *     if -ndim > axis or ndim <= axis:
 *         raise IndexError('Axis exceeds ndim')             # <<<<<<<<<<<<<<
 *     if axis < 0:
 *         axis += ndim
 */
  __pyx_tuple__89 = PyTuple_Pack(1, __pyx_kp_s_Axis_exceeds_ndim); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(0, 2235, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__89);
  __Pyx_GIVEREF(__pyx_tuple__89);

  /* "cupy/core/core.pyx":2307
 *         cdef vector.vector[vector.vector[Py_ssize_t]] shape_arr
 *         cdef ndarray a, view
 *         cdef slice rev = slice(None, None, -1)             # <<<<<<<<<<<<<<
 * 
 *         self.nd = 0
 */
  __pyx_slice__90 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__90)) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__90);
  __Pyx_GIVEREF(__pyx_slice__90);

  /* "cupy/core/core.pyx":2328
 *                     smax = max(smax, s)
 *             if smin == 0 and smax > 1:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'shape mismatch: objects cannot be broadcast to a '
 *                     'single shape')
 */
  __pyx_tuple__91 = PyTuple_Pack(1, __pyx_kp_s_shape_mismatch_objects_cannot_be); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(0, 2328, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__91);
  __Pyx_GIVEREF(__pyx_tuple__91);

  /* "cupy/core/core.pyx":2354
 *                     r_strides[i] = a._strides[a_ndim - i - 1]
 *                 elif a_sh != 1:
 *                     raise ValueError('Broadcasting failed')             # <<<<<<<<<<<<<<
 * 
 *             strides.assign(r_strides.rbegin(), r_strides.rend())
 */
  __pyx_tuple__92 = PyTuple_Pack(1, __pyx_kp_s_Broadcasting_failed); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(0, 2354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__92);
  __Pyx_GIVEREF(__pyx_tuple__92);

  /* "cupy/core/core.pyx":2373
 *     """
 *     if array.ndim > len(shape):
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'input operand has more dimensions than allowed by the axis '
 *             'remapping')
 */
  __pyx_tuple__93 = PyTuple_Pack(1, __pyx_kp_s_input_operand_has_more_dimension); if (unlikely(!__pyx_tuple__93)) __PYX_ERR(0, 2373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__93);
  __Pyx_GIVEREF(__pyx_tuple__93);

  /* "cupy/core/core.pyx":2385
 *             strides[j] = array._strides[j % array.ndim]
 *         elif a_sh != 1:
 *             raise ValueError('Broadcasting failed')             # <<<<<<<<<<<<<<
 * 
 *     view = array.view()
 */
  __pyx_tuple__94 = PyTuple_Pack(1, __pyx_kp_s_Broadcasting_failed); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(0, 2385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__94);
  __Pyx_GIVEREF(__pyx_tuple__94);

  /* "cupy/core/core.pyx":2431
 *     if axis is None:
 *         if broadcast:
 *             a = a.reshape((-1, 1))             # <<<<<<<<<<<<<<
 *             ret = ndarray((a.size, repeats[0]), dtype=a.dtype)
 *             if ret.size:
 */
  __pyx_tuple__95 = PyTuple_Pack(2, __pyx_int_neg_1, __pyx_int_1); if (unlikely(!__pyx_tuple__95)) __PYX_ERR(0, 2431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__95);
  __Pyx_GIVEREF(__pyx_tuple__95);
  __pyx_tuple__96 = PyTuple_Pack(1, __pyx_tuple__95); if (unlikely(!__pyx_tuple__96)) __PYX_ERR(0, 2431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__96);
  __Pyx_GIVEREF(__pyx_tuple__96);

  /* "cupy/core/core.pyx":2457
 *     ret_shape[axis] = sum(repeats)
 *     ret = ndarray(ret_shape, dtype=a.dtype)
 *     a_index = [slice(None)] * len(ret_shape)             # <<<<<<<<<<<<<<
 *     ret_index = list(a_index)
 *     offset = 0
 */
  __pyx_slice__97 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__97)) __PYX_ERR(0, 2457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__97);
  __Pyx_GIVEREF(__pyx_slice__97);

  /* "cupy/core/core.pyx":2484
 *     for o in arrays:
 *         if not isinstance(o, ndarray):
 *             raise TypeError('Only cupy arrays can be concatenated')             # <<<<<<<<<<<<<<
 *         a = o
 *         if a.ndim == 0:
 */
  __pyx_tuple__98 = PyTuple_Pack(1, __pyx_kp_s_Only_cupy_arrays_can_be_concaten); if (unlikely(!__pyx_tuple__98)) __PYX_ERR(0, 2484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__98);
  __Pyx_GIVEREF(__pyx_tuple__98);

  /* "cupy/core/core.pyx":2487
 *         a = o
 *         if a.ndim == 0:
 *             raise TypeError('zero-dimensional arrays cannot be concatenated')             # <<<<<<<<<<<<<<
 *         if ndim == -1:
 *             ndim = a.ndim
 */
  __pyx_tuple__99 = PyTuple_Pack(1, __pyx_kp_s_zero_dimensional_arrays_cannot_b); if (unlikely(!__pyx_tuple__99)) __PYX_ERR(0, 2487, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__99);
  __Pyx_GIVEREF(__pyx_tuple__99);

  /* "cupy/core/core.pyx":2501
 *         have_same_types = have_same_types and (a.dtype == dtype)
 *         if a.ndim != ndim:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'All arrays to concatenate must have the same ndim')
 *         for i in range(ndim):
 */
  __pyx_tuple__100 = PyTuple_Pack(1, __pyx_kp_s_All_arrays_to_concatenate_must_h); if (unlikely(!__pyx_tuple__100)) __PYX_ERR(0, 2501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__100);
  __Pyx_GIVEREF(__pyx_tuple__100);

  /* "cupy/core/core.pyx":2505
 *         for i in range(ndim):
 *             if i != axis and shape[i] != a._shape[i]:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'All arrays must have same shape except the axis to '
 *                     'concatenate')
 */
  __pyx_tuple__101 = PyTuple_Pack(1, __pyx_kp_s_All_arrays_must_have_same_shape); if (unlikely(!__pyx_tuple__101)) __PYX_ERR(0, 2505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__101);
  __Pyx_GIVEREF(__pyx_tuple__101);

  /* "cupy/core/core.pyx":2511
 * 
 *     if ndim == -1:
 *         raise ValueError('Cannot concatenate from empty tuple')             # <<<<<<<<<<<<<<
 * 
 *     if not have_same_types:
 */
  __pyx_tuple__102 = PyTuple_Pack(1, __pyx_kp_s_Cannot_concatenate_from_empty_tu); if (unlikely(!__pyx_tuple__102)) __PYX_ERR(0, 2511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__102);
  __Pyx_GIVEREF(__pyx_tuple__102);

  /* "cupy/core/core.pyx":2546
 *     ret = ndarray(shape, dtype=dtype)
 *     i = 0
 *     slice_list = [slice(None)] * len(shape)             # <<<<<<<<<<<<<<
 *     for a in arrays:
 *         aw = a._shape[axis]
 */
  __pyx_slice__103 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__103)) __PYX_ERR(0, 2546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__103);
  __Pyx_GIVEREF(__pyx_slice__103);

  /* "cupy/core/core.pyx":2664
 *             index += ndim
 *         if not 0 <= index < ndim:
 *             raise IndexError('index out of range')             # <<<<<<<<<<<<<<
 *         return a._shape[index]
 * 
 */
  __pyx_tuple__104 = PyTuple_Pack(1, __pyx_kp_s_index_out_of_range); if (unlikely(!__pyx_tuple__104)) __PYX_ERR(0, 2664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__104);
  __Pyx_GIVEREF(__pyx_tuple__104);

  /* "cupy/core/core.pyx":2672
 * 
 * cpdef _create_bit_op(name, op, no_bool, doc=''):
 *     types = () if no_bool else ('??->?',)             # <<<<<<<<<<<<<<
 *     return create_ufunc(
 *         'cupy_' + name,
 */
  __pyx_tuple__106 = PyTuple_Pack(1, __pyx_kp_s__105); if (unlikely(!__pyx_tuple__106)) __PYX_ERR(0, 2672, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__106);
  __Pyx_GIVEREF(__pyx_tuple__106);

  /* "cupy/core/core.pyx":2675
 *     return create_ufunc(
 *         'cupy_' + name,
 *         types + ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',             # <<<<<<<<<<<<<<
 *                  'LL->L', 'qq->q', 'QQ->Q'),
 *         'out0 = in0 %s in1' % op,
 */
  __pyx_tuple__107 = PyTuple_Pack(10, __pyx_kp_s_bb_b, __pyx_kp_s_BB_B, __pyx_kp_s_hh_h, __pyx_kp_s_HH_H, __pyx_kp_s_ii_i, __pyx_kp_s_II_I, __pyx_kp_s_ll_l, __pyx_kp_s_LL_L, __pyx_kp_s_qq_q, __pyx_kp_s_QQ_Q); if (unlikely(!__pyx_tuple__107)) __PYX_ERR(0, 2675, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__107);
  __Pyx_GIVEREF(__pyx_tuple__107);

  /* "cupy/core/core.pyx":2797
 * 
 *     if not mask_exists and len(slice_list) > ndim + n_newaxes:
 *         raise IndexError('too many indices for array')             # <<<<<<<<<<<<<<
 *     return slice_list, advanced, mask_exists
 * 
 */
  __pyx_tuple__108 = PyTuple_Pack(1, __pyx_kp_s_too_many_indices_for_array); if (unlikely(!__pyx_tuple__108)) __PYX_ERR(0, 2797, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__108);
  __Pyx_GIVEREF(__pyx_tuple__108);

  /* "cupy/core/core.pyx":2803
 * cdef Py_ssize_t _get_mask_index(list slice_list) except *:
 *     cdef Py_ssize_t i, n_not_slice_none, mask_i
 *     cdef slice none_slice = slice(None)             # <<<<<<<<<<<<<<
 *     n_not_slice_none = 0
 *     mask_i = -1
 */
  __pyx_slice__109 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__109)) __PYX_ERR(0, 2803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__109);
  __Pyx_GIVEREF(__pyx_slice__109);

  /* "cupy/core/core.pyx":2812
 *                 mask_i = i
 *     if n_not_slice_none != 1 or mask_i == -1:
 *         raise ValueError('currently, CuPy only supports slices that '             # <<<<<<<<<<<<<<
 *                          'consist of one boolean array.')
 *     return mask_i
 */
  __pyx_tuple__110 = PyTuple_Pack(1, __pyx_kp_s_currently_CuPy_only_supports_sli); if (unlikely(!__pyx_tuple__110)) __PYX_ERR(0, 2812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__110);
  __Pyx_GIVEREF(__pyx_tuple__110);

  /* "cupy/core/core.pyx":2818
 * 
 * cdef tuple _prepare_advanced_indexing(ndarray a, list slice_list):
 *     cdef slice none_slice = slice(None)             # <<<<<<<<<<<<<<
 * 
 *     # split slices that can be handled by basic-indexing
 */
  __pyx_slice__111 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__111)) __PYX_ERR(0, 2818, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__111);
  __Pyx_GIVEREF(__pyx_slice__111);

  /* "cupy/core/core.pyx":2844
 *         elif isinstance(s, int):
 *             basic_slices.append(none_slice)
 *             scalar_array = ndarray((), dtype=numpy.int64)             # <<<<<<<<<<<<<<
 *             scalar_array.fill(s)
 *             adv_slices.append(scalar_array)
 */
  __pyx_tuple__112 = PyTuple_Pack(1, __pyx_empty_tuple); if (unlikely(!__pyx_tuple__112)) __PYX_ERR(0, 2844, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__112);
  __Pyx_GIVEREF(__pyx_tuple__112);

  /* "cupy/core/core.pyx":2849
 *             adv_mask.append(True)
 *         else:
 *             raise IndexError(             # <<<<<<<<<<<<<<
 *                 'only integers, slices (`:`), ellipsis (`...`),'
 *                 'numpy.newaxis (`None`) and integer or '
 */
  __pyx_tuple__113 = PyTuple_Pack(1, __pyx_kp_s_only_integers_slices_ellipsis_nu); if (unlikely(!__pyx_tuple__113)) __PYX_ERR(0, 2849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__113);
  __Pyx_GIVEREF(__pyx_tuple__113);

  /* "cupy/core/core.pyx":2881
 *                 strides.push_back(a.itemsize)
 *         elif ndim <= j:
 *             raise IndexError("too many indices for array")             # <<<<<<<<<<<<<<
 *         elif isinstance(s, slice):
 *             ss = internal.complete_slice(s, a._shape[j])
 */
  __pyx_tuple__114 = PyTuple_Pack(1, __pyx_kp_s_too_many_indices_for_array); if (unlikely(!__pyx_tuple__114)) __PYX_ERR(0, 2881, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__114);
  __Pyx_GIVEREF(__pyx_tuple__114);

  /* "cupy/core/core.pyx":3025
 * 
 *     if mask.size == 0:
 *         masked_shape = lshape + (0,) + rshape             # <<<<<<<<<<<<<<
 *         mask_br = mask._reshape(masked_shape)
 *         return mask_br, mask_br, masked_shape
 */
  __pyx_tuple__115 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__115)) __PYX_ERR(0, 3025, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__115);
  __Pyx_GIVEREF(__pyx_tuple__115);

  /* "cupy/core/core.pyx":3045
 *     # The scan of the broadcasted array is used to index on kernel.
 *     mask_br = mask._reshape(
 *         axis * (1,) + mask.shape + (a.ndim - axis - mask.ndim) * (1,))             # <<<<<<<<<<<<<<
 *     mask_br = broadcast_to(mask_br, a.shape)
 *     if mask.size <= 2 ** 31 - 1:
 */
  __pyx_tuple__116 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__116)) __PYX_ERR(0, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__116);
  __Pyx_GIVEREF(__pyx_tuple__116);
  __pyx_tuple__117 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__117)) __PYX_ERR(0, 3045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__117);
  __Pyx_GIVEREF(__pyx_tuple__117);

  /* "cupy/core/core.pyx":3081
 *     else:
 *         if not (-a.ndim <= li < a.ndim and -a.ndim <= ri < a.ndim):
 *             raise _AxisError('Axis overrun')             # <<<<<<<<<<<<<<
 *         if a.ndim != 0:
 *             li %= a.ndim
 */
  __pyx_tuple__118 = PyTuple_Pack(1, __pyx_kp_s_Axis_overrun); if (unlikely(!__pyx_tuple__118)) __PYX_ERR(0, 3081, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__118);
  __Pyx_GIVEREF(__pyx_tuple__118);

  /* "cupy/core/core.pyx":3099
 *         else:
 *             if out.dtype != a.dtype:
 *                 raise TypeError('Output dtype mismatch')             # <<<<<<<<<<<<<<
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')
 */
  __pyx_tuple__119 = PyTuple_Pack(1, __pyx_kp_s_Output_dtype_mismatch); if (unlikely(!__pyx_tuple__119)) __PYX_ERR(0, 3099, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__119);
  __Pyx_GIVEREF(__pyx_tuple__119);

  /* "cupy/core/core.pyx":3100
 *             if out.dtype != a.dtype:
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Output shape mismatch')
 *             elementwise_copy(a[indices], out)
 */
  __pyx_slice__120 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__120)) __PYX_ERR(0, 3100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__120);
  __Pyx_GIVEREF(__pyx_slice__120);

  /* "cupy/core/core.pyx":3101
 *                 raise TypeError('Output dtype mismatch')
 *             if out.shape != a.shape[1:]:
 *                 raise ValueError('Output shape mismatch')             # <<<<<<<<<<<<<<
 *             elementwise_copy(a[indices], out)
 *             return out
 */
  __pyx_tuple__121 = PyTuple_Pack(1, __pyx_kp_s_Output_shape_mismatch); if (unlikely(!__pyx_tuple__121)) __PYX_ERR(0, 3101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__121);
  __Pyx_GIVEREF(__pyx_tuple__121);

  /* "cupy/core/core.pyx":3112
 *     else:
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')             # <<<<<<<<<<<<<<
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')
 */
  __pyx_tuple__122 = PyTuple_Pack(1, __pyx_kp_s_Output_dtype_mismatch); if (unlikely(!__pyx_tuple__122)) __PYX_ERR(0, 3112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__122);
  __Pyx_GIVEREF(__pyx_tuple__122);

  /* "cupy/core/core.pyx":3114
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')             # <<<<<<<<<<<<<<
 * 
 *     cdim = indices.size
 */
  __pyx_tuple__123 = PyTuple_Pack(1, __pyx_kp_s_Output_shape_mismatch); if (unlikely(!__pyx_tuple__123)) __PYX_ERR(0, 3114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__123);
  __Pyx_GIVEREF(__pyx_tuple__123);

  /* "cupy/core/core.pyx":3119
 *     rdim = internal.prod(rshape)
 *     indices = indices.reshape(
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))             # <<<<<<<<<<<<<<
 *     if (li == 0 and ri == 0) or (li is None and ri is None):
 *         return _take_kernel_0axis(
 */
  __pyx_tuple__124 = PyTuple_New(1); if (unlikely(!__pyx_tuple__124)) __PYX_ERR(0, 3119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__124);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__124, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__124);
  __pyx_tuple__125 = PyTuple_New(1); if (unlikely(!__pyx_tuple__125)) __PYX_ERR(0, 3119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__125);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__125, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__125);

  /* "cupy/core/core.pyx":3146
 * 
 *     if ndim == 0:
 *         raise ValueError("requires a.ndim >= 1")             # <<<<<<<<<<<<<<
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):
 *         raise ValueError('Axis overrun')
 */
  __pyx_tuple__126 = PyTuple_Pack(1, __pyx_kp_s_requires_a_ndim_1); if (unlikely(!__pyx_tuple__126)) __PYX_ERR(0, 3146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__126);
  __Pyx_GIVEREF(__pyx_tuple__126);

  /* "cupy/core/core.pyx":3148
 *         raise ValueError("requires a.ndim >= 1")
 *     if not (-ndim <= li < ndim and -ndim <= ri < ndim):
 *         raise ValueError('Axis overrun')             # <<<<<<<<<<<<<<
 * 
 *     if not isinstance(v, ndarray):
 */
  __pyx_tuple__127 = PyTuple_Pack(1, __pyx_kp_s_Axis_overrun); if (unlikely(!__pyx_tuple__127)) __PYX_ERR(0, 3148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__127);
  __Pyx_GIVEREF(__pyx_tuple__127);

  /* "cupy/core/core.pyx":3170
 *     rdim = internal.prod(rshape)
 *     indices = indices._reshape(
 *         (1,) * len(lshape) + indices_shape + (1,) * len(rshape))             # <<<<<<<<<<<<<<
 *     indices = broadcast_to(indices, v_shape)
 * 
 */
  __pyx_tuple__128 = PyTuple_New(1); if (unlikely(!__pyx_tuple__128)) __PYX_ERR(0, 3170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__128);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__128, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__128);
  __pyx_tuple__129 = PyTuple_New(1); if (unlikely(!__pyx_tuple__129)) __PYX_ERR(0, 3170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__129);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__129, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__129);

  /* "cupy/core/core.pyx":3182
 *                           (numpy.int32, numpy.float32,
 *                            numpy.uint32, numpy.uint64, numpy.ulonglong)):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'scatter_add only supports int32, float32, uint32, uint64 as '
 *                 'data type')
 */
  __pyx_tuple__130 = PyTuple_Pack(1, __pyx_kp_s_scatter_add_only_supports_int32); if (unlikely(!__pyx_tuple__130)) __PYX_ERR(0, 3182, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__130);
  __Pyx_GIVEREF(__pyx_tuple__130);

  /* "cupy/core/core.pyx":3188
 *             v, indices, cdim, rdim, adim, a.reduced_view())
 *     else:
 *         raise ValueError('provided op is not supported')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__131 = PyTuple_Pack(1, __pyx_kp_s_provided_op_is_not_supported); if (unlikely(!__pyx_tuple__131)) __PYX_ERR(0, 3188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__131);
  __Pyx_GIVEREF(__pyx_tuple__131);

  /* "cupy/core/core.pyx":3213
 *         _scatter_add_mask_kernel(src, mask, mask_scanned, a)
 *     else:
 *         raise ValueError('provided op is not supported')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__132 = PyTuple_Pack(1, __pyx_kp_s_provided_op_is_not_supported); if (unlikely(!__pyx_tuple__132)) __PYX_ERR(0, 3213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__132);
  __Pyx_GIVEREF(__pyx_tuple__132);

  /* "cupy/core/core.pyx":3260
 *         add(y, value, y)
 *         return
 *     raise ValueError('this op is not supported')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__133 = PyTuple_Pack(1, __pyx_kp_s_this_op_is_not_supported); if (unlikely(!__pyx_tuple__133)) __PYX_ERR(0, 3260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__133);
  __Pyx_GIVEREF(__pyx_tuple__133);

  /* "cupy/core/core.pyx":3287
 * 
 *     diag_size = max(0, min(a.shape[-2], a.shape[-1] - offset))
 *     ret_shape = a.shape[:-2] + (diag_size,)             # <<<<<<<<<<<<<<
 *     if diag_size == 0:
 *         return ndarray(ret_shape, dtype=a.dtype)
 */
  __pyx_slice__134 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__134)) __PYX_ERR(0, 3287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__134);
  __Pyx_GIVEREF(__pyx_slice__134);

  /* "cupy/core/core.pyx":3295
 *     ret = a.view()
 *     ret._set_shape_and_strides(
 *         a.shape[:-2] + (diag_size,),             # <<<<<<<<<<<<<<
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))
 *     return ret
 */
  __pyx_slice__135 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__135)) __PYX_ERR(0, 3295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__135);
  __Pyx_GIVEREF(__pyx_slice__135);

  /* "cupy/core/core.pyx":3296
 *     ret._set_shape_and_strides(
 *         a.shape[:-2] + (diag_size,),
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
  __pyx_slice__136 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__136)) __PYX_ERR(0, 3296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__136);
  __Pyx_GIVEREF(__pyx_slice__136);

  /* "cupy/core/core.pyx":3386
 *     concat_shape = (len(flattened_indexes),) + br.shape
 *     flattened_indexes = _concatenate(
 *         [index._reshape((1,) + index.shape) for index in flattened_indexes],             # <<<<<<<<<<<<<<
 *         axis=0, shape=concat_shape, dtype=flattened_indexes[0].dtype)
 * 
 */
  __pyx_tuple__137 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__137)) __PYX_ERR(0, 3386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__137);
  __Pyx_GIVEREF(__pyx_tuple__137);

  /* "cupy/core/core.pyx":3423
 * 
 *     if out is not None and numpy.result_type(a.dtype, b.dtype) != out.dtype:
 *         raise ValueError('Not supported dtype combination.')             # <<<<<<<<<<<<<<
 * 
 *     if a_ndim == 0 or b_ndim == 0:
 */
  __pyx_tuple__138 = PyTuple_Pack(1, __pyx_kp_s_Not_supported_dtype_combination); if (unlikely(!__pyx_tuple__138)) __PYX_ERR(0, 3423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__138);
  __Pyx_GIVEREF(__pyx_tuple__138);

  /* "cupy/core/core.pyx":3447
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:
 *         raise ValueError('Axis dimension mismatch')             # <<<<<<<<<<<<<<
 * 
 *     if a_axis:
 */
  __pyx_tuple__139 = PyTuple_Pack(1, __pyx_kp_s_Axis_dimension_mismatch); if (unlikely(!__pyx_tuple__139)) __PYX_ERR(0, 3447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__139);
  __Pyx_GIVEREF(__pyx_tuple__139);

  /* "cupy/core/core.pyx":3470
 *     if out is not None:
 *         if k != 0 and out.size != n * m:
 *             raise ValueError('Output array has an invalid size')             # <<<<<<<<<<<<<<
 *         if not out._c_contiguous:
 *             raise ValueError('Output array must be C-contiguous')
 */
  __pyx_tuple__140 = PyTuple_Pack(1, __pyx_kp_s_Output_array_has_an_invalid_size); if (unlikely(!__pyx_tuple__140)) __PYX_ERR(0, 3470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__140);
  __Pyx_GIVEREF(__pyx_tuple__140);

  /* "cupy/core/core.pyx":3472
 *             raise ValueError('Output array has an invalid size')
 *         if not out._c_contiguous:
 *             raise ValueError('Output array must be C-contiguous')             # <<<<<<<<<<<<<<
 * 
 *     return tensordot_core(a, b, out, n, m, k, ret_shape)
 */
  __pyx_tuple__141 = PyTuple_Pack(1, __pyx_kp_s_Output_array_must_be_C_contiguou); if (unlikely(!__pyx_tuple__141)) __PYX_ERR(0, 3472, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__141);
  __Pyx_GIVEREF(__pyx_tuple__141);

  /* "cupy/core/core.pyx":3482
 *     idx = numpy.array([start_adr])
 *     for sh_, st_ in zip(shape, strides):
 *         idx = (idx[:, None] + (numpy.arange(sh_) * st_)[None, :]).ravel()             # <<<<<<<<<<<<<<
 *     idx = idx.astype(numpy.uintp)
 * 
 */
  __pyx_slice__142 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__142)) __PYX_ERR(0, 3482, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__142);
  __Pyx_GIVEREF(__pyx_slice__142);
  __pyx_tuple__143 = PyTuple_Pack(2, __pyx_slice__142, Py_None); if (unlikely(!__pyx_tuple__143)) __PYX_ERR(0, 3482, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__143);
  __Pyx_GIVEREF(__pyx_tuple__143);
  __pyx_slice__144 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__144)) __PYX_ERR(0, 3482, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__144);
  __Pyx_GIVEREF(__pyx_slice__144);
  __pyx_tuple__145 = PyTuple_Pack(2, Py_None, __pyx_slice__144); if (unlikely(!__pyx_tuple__145)) __PYX_ERR(0, 3482, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__145);
  __Pyx_GIVEREF(__pyx_tuple__145);

  /* "cupy/core/core.pyx":3506
 *     cdef ndarray ret
 *     if a.ndim <= 2:
 *         ret = ndarray((1,), dtype=numpy.uintp)             # <<<<<<<<<<<<<<
 *         ret.fill(a.data.ptr)
 *         return ret
 */
  __pyx_tuple__146 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__146)) __PYX_ERR(0, 3506, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__146);
  __Pyx_GIVEREF(__pyx_tuple__146);
  __pyx_tuple__147 = PyTuple_Pack(1, __pyx_tuple__146); if (unlikely(!__pyx_tuple__147)) __PYX_ERR(0, 3506, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__147);
  __Pyx_GIVEREF(__pyx_tuple__147);

  /* "cupy/core/core.pyx":3510
 *         return ret
 *     else:
 *         return _get_all_addresses(a.data.ptr, a.shape[:-2], a.strides[:-2])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_slice__148 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__148)) __PYX_ERR(0, 3510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__148);
  __Pyx_GIVEREF(__pyx_slice__148);
  __pyx_slice__149 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__149)) __PYX_ERR(0, 3510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__149);
  __Pyx_GIVEREF(__pyx_slice__149);

  /* "cupy/core/core.pyx":3546
 *     # ToDo: remove python object .reshape
 *     if out is not None:
 *         raise NotImplementedError('The out array as input is currently not '             # <<<<<<<<<<<<<<
 *                                   'supported')
 * 
 */
  __pyx_tuple__150 = PyTuple_Pack(1, __pyx_kp_s_The_out_array_as_input_is_curren); if (unlikely(!__pyx_tuple__150)) __PYX_ERR(0, 3546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__150);
  __Pyx_GIVEREF(__pyx_tuple__150);

  /* "cupy/core/core.pyx":3556
 *     orig_b_shape = b.shape
 *     if len(orig_a_shape) == 0 or len(orig_b_shape) == 0:
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')             # <<<<<<<<<<<<<<
 * 
 *     ret_dtype = numpy.result_type(a.dtype, b.dtype)
 */
  __pyx_tuple__151 = PyTuple_Pack(1, __pyx_kp_s_Scalar_operands_are_not_allowed); if (unlikely(!__pyx_tuple__151)) __PYX_ERR(0, 3556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__151);
  __Pyx_GIVEREF(__pyx_tuple__151);

  /* "cupy/core/core.pyx":3574
 *         ldout = 1
 *     else:
 *         b_part_outshape = b.shape[-1:]             # <<<<<<<<<<<<<<
 *         ldout = b.shape[-1]
 * 
 */
  __pyx_slice__152 = PySlice_New(__pyx_int_neg_1, Py_None, Py_None); if (unlikely(!__pyx_slice__152)) __PYX_ERR(0, 3574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__152);
  __Pyx_GIVEREF(__pyx_slice__152);

  /* "cupy/core/core.pyx":3581
 *         view = a.view()
 *         view._set_shape_and_strides(
 *             (1,) * (b.ndim - a.ndim) + a.shape,             # <<<<<<<<<<<<<<
 *             (0,) * (b.ndim - a.ndim) + a.strides)
 *         a = view
 */
  __pyx_tuple__153 = PyTuple_New(1); if (unlikely(!__pyx_tuple__153)) __PYX_ERR(0, 3581, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__153);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__153, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__153);

  /* "cupy/core/core.pyx":3582
 *         view._set_shape_and_strides(
 *             (1,) * (b.ndim - a.ndim) + a.shape,
 *             (0,) * (b.ndim - a.ndim) + a.strides)             # <<<<<<<<<<<<<<
 *         a = view
 *     elif a.ndim > b.ndim:
 */
  __pyx_tuple__154 = PyTuple_New(1); if (unlikely(!__pyx_tuple__154)) __PYX_ERR(0, 3582, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__154);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_tuple__154, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_tuple__154);

  /* "cupy/core/core.pyx":3587
 *         view = b.view()
 *         view._set_shape_and_strides(
 *             (1,) * (a.ndim - b.ndim) + b.shape,             # <<<<<<<<<<<<<<
 *             (0,) * (a.ndim - b.ndim) + b.strides)
 *         b = view
 */
  __pyx_tuple__155 = PyTuple_New(1); if (unlikely(!__pyx_tuple__155)) __PYX_ERR(0, 3587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__155);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__155, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__155);

  /* "cupy/core/core.pyx":3588
 *         view._set_shape_and_strides(
 *             (1,) * (a.ndim - b.ndim) + b.shape,
 *             (0,) * (a.ndim - b.ndim) + b.strides)             # <<<<<<<<<<<<<<
 *         b = view
 * 
 */
  __pyx_tuple__156 = PyTuple_New(1); if (unlikely(!__pyx_tuple__156)) __PYX_ERR(0, 3588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__156);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_tuple__156, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_tuple__156);

  /* "cupy/core/core.pyx":3592
 * 
 *     broadcast_pre_shape = numpy.maximum(
 *         numpy.array(a.shape[:-2], numpy.uint64) - 1,             # <<<<<<<<<<<<<<
 *         numpy.array(b.shape[:-2], numpy.uint64) - 1
 *     ) + 1
 */
  __pyx_slice__157 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__157)) __PYX_ERR(0, 3592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__157);
  __Pyx_GIVEREF(__pyx_slice__157);

  /* "cupy/core/core.pyx":3593
 *     broadcast_pre_shape = numpy.maximum(
 *         numpy.array(a.shape[:-2], numpy.uint64) - 1,
 *         numpy.array(b.shape[:-2], numpy.uint64) - 1             # <<<<<<<<<<<<<<
 *     ) + 1
 * 
 */
  __pyx_slice__158 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__158)) __PYX_ERR(0, 3593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__158);
  __Pyx_GIVEREF(__pyx_slice__158);

  /* "cupy/core/core.pyx":3632
 *     out_view_strides = out.strides
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)             # <<<<<<<<<<<<<<
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():
 */
  __pyx_tuple__159 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__159)) __PYX_ERR(0, 3632, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__159);
  __Pyx_GIVEREF(__pyx_tuple__159);

  /* "cupy/core/core.pyx":3633
 *     if a_part_outshape == ():
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)             # <<<<<<<<<<<<<<
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)
 */
  __pyx_tuple__160 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__160)) __PYX_ERR(0, 3633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__160);
  __Pyx_GIVEREF(__pyx_tuple__160);

  /* "cupy/core/core.pyx":3635
 *         out_view_strides += (0,)
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)             # <<<<<<<<<<<<<<
 *         out_view_strides += (0,)
 * 
 */
  __pyx_tuple__161 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__161)) __PYX_ERR(0, 3635, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__161);
  __Pyx_GIVEREF(__pyx_tuple__161);

  /* "cupy/core/core.pyx":3636
 *     if b_part_outshape == ():
 *         out_view_shape += (1,)
 *         out_view_strides += (0,)             # <<<<<<<<<<<<<<
 * 
 *     out_view._set_shape_and_strides(out_view_shape, out_view_strides)
 */
  __pyx_tuple__162 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__162)) __PYX_ERR(0, 3636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__162);
  __Pyx_GIVEREF(__pyx_tuple__162);

  /* "cupy/core/core.pyx":3656
 *     for la_, lb_ in zip(la, lb):
 *         if not (la_ == lb_ or la_ == 1 or lb_ == 1):
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'operands could not be broadcast together with '
 *                 'remapped shapes')
 */
  __pyx_tuple__163 = PyTuple_Pack(1, __pyx_kp_s_operands_could_not_be_broadcast); if (unlikely(!__pyx_tuple__163)) __PYX_ERR(0, 3656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__163);
  __Pyx_GIVEREF(__pyx_tuple__163);

  /* "cupy/core/core.pyx":3823
 * 
 *     if m == 1 and n == 1:
 *         _tensordot_core_mul_sum(a.ravel(), b.ravel(), out.reshape(()))             # <<<<<<<<<<<<<<
 *         if out is not ret:
 *             elementwise_copy(out, ret)
 */
  __pyx_tuple__164 = PyTuple_Pack(1, __pyx_empty_tuple); if (unlikely(!__pyx_tuple__164)) __PYX_ERR(0, 3823, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__164);
  __Pyx_GIVEREF(__pyx_tuple__164);

  /* "cupy/core/core.pyx":3927
 * 
 *     if require_sortable_dtype:
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',             # <<<<<<<<<<<<<<
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 *     else:
 */
  __pyx_tuple__165 = PyTuple_Pack(14, __pyx_kp_s__105, __pyx_kp_s_bb, __pyx_kp_s_BB, __pyx_kp_s_hh, __pyx_kp_s_HH, __pyx_kp_s_ii, __pyx_kp_s_II, __pyx_kp_s_ll, __pyx_kp_s_LL, __pyx_kp_s_qq, __pyx_kp_s_QQ, __pyx_kp_s_ee, __pyx_kp_s_ff, __pyx_kp_s_dd); if (unlikely(!__pyx_tuple__165)) __PYX_ERR(0, 3927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__165);
  __Pyx_GIVEREF(__pyx_tuple__165);

  /* "cupy/core/core.pyx":3930
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 *     else:
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',             # <<<<<<<<<<<<<<
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'FF->?',
 *                'dd->?', 'DD->?')
 */
  __pyx_tuple__166 = PyTuple_Pack(16, __pyx_kp_s__105, __pyx_kp_s_bb, __pyx_kp_s_BB, __pyx_kp_s_hh, __pyx_kp_s_HH, __pyx_kp_s_ii, __pyx_kp_s_II, __pyx_kp_s_ll, __pyx_kp_s_LL, __pyx_kp_s_qq, __pyx_kp_s_QQ, __pyx_kp_s_ee, __pyx_kp_s_ff, __pyx_kp_s_FF, __pyx_kp_s_dd, __pyx_kp_s_DD); if (unlikely(!__pyx_tuple__166)) __PYX_ERR(0, 3930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__166);
  __Pyx_GIVEREF(__pyx_tuple__166);

  /* "cupy/core/core.pyx":4364
 *     name = "inclusive_scan_kernel"
 *     dtype = _get_typename(dtype)
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *     extern "C" __global__ void ${name}(const CArray<${dtype}, 1> src,
 *         CArray<${dtype}, 1> dst){
 */
  __pyx_tuple__167 = PyTuple_Pack(1, __pyx_kp_s_extern_C___global___void_name_c); if (unlikely(!__pyx_tuple__167)) __PYX_ERR(0, 4364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__167);
  __Pyx_GIVEREF(__pyx_tuple__167);

  /* "cupy/core/core.pyx":4411
 *     name = "add_scan_blocked_sum_kernel"
 *     dtype = _get_typename(dtype)
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *     extern "C" __global__ void ${name}(CArray<${dtype}, 1> src_dst){
 *         long long n = src_dst.size();
 */
  __pyx_tuple__168 = PyTuple_Pack(1, __pyx_kp_s_extern_C___global___void_name_C); if (unlikely(!__pyx_tuple__168)) __PYX_ERR(0, 4411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__168);
  __Pyx_GIVEREF(__pyx_tuple__168);

  /* "cupy/core/core.pyx":4433
 *     index_dtype = _get_typename(index_dtype)
 * 
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *     extern "C" __global__ void ${name}(const CArray<${src_dtype}, 1> src,
 *         const CArray<${index_dtype}, 1> scaned_index,
 */
  __pyx_tuple__169 = PyTuple_Pack(1, __pyx_kp_s_extern_C___global___void_name_c_2); if (unlikely(!__pyx_tuple__169)) __PYX_ERR(0, 4433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__169);
  __Pyx_GIVEREF(__pyx_tuple__169);

  /* "cupy/core/core.pyx":4457
 *     dst_dtype = _get_typename(dst_dtype)
 * 
 *     source = string.Template("""             # <<<<<<<<<<<<<<
 *         extern "C" __global__ void ${name}(const CArray<${src_dtype}, 1> src,
 *             CIndexer<${src_ndim}> shape,
 */
  __pyx_tuple__170 = PyTuple_Pack(1, __pyx_kp_s_extern_C___global___void_name_c_3); if (unlikely(!__pyx_tuple__170)) __PYX_ERR(0, 4457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__170);
  __Pyx_GIVEREF(__pyx_tuple__170);

  /* "cupy/core/core.pyx":4498
 *     """
 *     if a.ndim != 1:
 *         raise TypeError("Input array should be 1D array.")             # <<<<<<<<<<<<<<
 * 
 *     block_size = 256
 */
  __pyx_tuple__171 = PyTuple_Pack(1, __pyx_kp_s_Input_array_should_be_1D_array); if (unlikely(!__pyx_tuple__171)) __PYX_ERR(0, 4498, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__171);
  __Pyx_GIVEREF(__pyx_tuple__171);

  /* "cupy/core/core.pyx":4506
 *     else:
 *         if a.size != out.size:
 *             raise ValueError("Provided out is the wrong size")             # <<<<<<<<<<<<<<
 * 
 *     kern_scan = _inclusive_scan_kernel(a.dtype, block_size)
 */
  __pyx_tuple__172 = PyTuple_Pack(1, __pyx_kp_s_Provided_out_is_the_wrong_size); if (unlikely(!__pyx_tuple__172)) __PYX_ERR(0, 4506, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__172);
  __Pyx_GIVEREF(__pyx_tuple__172);

  /* "cupy/core/core.pyx":4533
 *     merge_kernel = 'partition_merge_kernel'
 *     dtype = _get_typename(dtype)
 *     source = string.Template('''             # <<<<<<<<<<<<<<
 *     template<typename T>
 *     __device__ void bitonic_sort_step(CArray<T, 1> a,
 */
  __pyx_tuple__173 = PyTuple_Pack(1, __pyx_kp_s_template_typename_T___device); if (unlikely(!__pyx_tuple__173)) __PYX_ERR(0, 4533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__173);
  __Pyx_GIVEREF(__pyx_tuple__173);

  /* "View.MemoryView":132
 * 
 *         if not self.ndim:
 *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
 * 
 *         if itemsize <= 0:
 */
  __pyx_tuple__174 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__174)) __PYX_ERR(4, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__174);
  __Pyx_GIVEREF(__pyx_tuple__174);

  /* "View.MemoryView":135
 * 
 *         if itemsize <= 0:
 *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
 * 
 *         if not isinstance(format, bytes):
 */
  __pyx_tuple__175 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__175)) __PYX_ERR(4, 135, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__175);
  __Pyx_GIVEREF(__pyx_tuple__175);

  /* "View.MemoryView":138
 * 
 *         if not isinstance(format, bytes):
 *             format = format.encode('ASCII')             # <<<<<<<<<<<<<<
 *         self._format = format  # keep a reference to the byte string
 *         self.format = self._format
 */
  __pyx_tuple__176 = PyTuple_Pack(1, __pyx_n_s_ASCII); if (unlikely(!__pyx_tuple__176)) __PYX_ERR(4, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__176);
  __Pyx_GIVEREF(__pyx_tuple__176);

  /* "View.MemoryView":147
 * 
 *         if not self._shape:
 *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__177 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__177)) __PYX_ERR(4, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__177);
  __Pyx_GIVEREF(__pyx_tuple__177);

  /* "View.MemoryView":175
 *             self.data = <char *>malloc(self.len)
 *             if not self.data:
 *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
 * 
 *             if self.dtype_is_object:
 */
  __pyx_tuple__178 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__178)) __PYX_ERR(4, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__178);
  __Pyx_GIVEREF(__pyx_tuple__178);

  /* "View.MemoryView":191
 *             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__179 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__179)) __PYX_ERR(4, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__179);
  __Pyx_GIVEREF(__pyx_tuple__179);

  /* "(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__180 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__180)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__180);
  __Pyx_GIVEREF(__pyx_tuple__180);

  /* "(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__181 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__181)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__181);
  __Pyx_GIVEREF(__pyx_tuple__181);

  /* "View.MemoryView":413
 *     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__182 = PyTuple_Pack(1, __pyx_kp_s_Cannot_assign_to_read_only_memor); if (unlikely(!__pyx_tuple__182)) __PYX_ERR(4, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__182);
  __Pyx_GIVEREF(__pyx_tuple__182);

  /* "View.MemoryView":490
 *             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__183 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__183)) __PYX_ERR(4, 490, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__183);
  __Pyx_GIVEREF(__pyx_tuple__183);

  /* "View.MemoryView":515
 *     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_STRIDES:
 */
  __pyx_tuple__184 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_writable_memory_vi); if (unlikely(!__pyx_tuple__184)) __PYX_ERR(4, 515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__184);
  __Pyx_GIVEREF(__pyx_tuple__184);

  /* "View.MemoryView":565
 *         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__185 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__185)) __PYX_ERR(4, 565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__185);
  __Pyx_GIVEREF(__pyx_tuple__185);

  /* "View.MemoryView":572
 *     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__186 = PyTuple_New(1); if (unlikely(!__pyx_tuple__186)) __PYX_ERR(4, 572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__186);
  __Pyx_INCREF(__pyx_int_neg_1);
  __Pyx_GIVEREF(__pyx_int_neg_1);
  PyTuple_SET_ITEM(__pyx_tuple__186, 0, __pyx_int_neg_1);
  __Pyx_GIVEREF(__pyx_tuple__186);

  /* "(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__187 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__187)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__187);
  __Pyx_GIVEREF(__pyx_tuple__187);

  /* "(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__188 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__188)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__188);
  __Pyx_GIVEREF(__pyx_tuple__188);

  /* "View.MemoryView":677
 *         if item is Ellipsis:
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
 *                 seen_ellipsis = True
 *             else:
 */
  __pyx_slice__189 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__189)) __PYX_ERR(4, 677, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__189);
  __Pyx_GIVEREF(__pyx_slice__189);

  /* "View.MemoryView":680
 *                 seen_ellipsis = True
 *             else:
 *                 result.append(slice(None))             # <<<<<<<<<<<<<<
 *             have_slices = True
 *         else:
 */
  __pyx_slice__190 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__190)) __PYX_ERR(4, 680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__190);
  __Pyx_GIVEREF(__pyx_slice__190);

  /* "View.MemoryView":691
 *     nslices = ndim - len(result)
 *     if nslices:
 *         result.extend([slice(None)] * nslices)             # <<<<<<<<<<<<<<
 * 
 *     return have_slices or nslices, tuple(result)
 */
  __pyx_slice__191 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__191)) __PYX_ERR(4, 691, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__191);
  __Pyx_GIVEREF(__pyx_slice__191);

  /* "View.MemoryView":698
 *     for suboffset in suboffsets[:ndim]:
 *         if suboffset >= 0:
 *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__192 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__192)) __PYX_ERR(4, 698, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__192);
  __Pyx_GIVEREF(__pyx_tuple__192);

  /* "(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__193 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__193)) __PYX_ERR(4, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__193);
  __Pyx_GIVEREF(__pyx_tuple__193);

  /* "(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__194 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__194)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__194);
  __Pyx_GIVEREF(__pyx_tuple__194);

  /* "cupy/core/core.pyx":46
 *     _AxisError = numpy.AxisError
 * except AttributeError:
 *     class IndexOrValueError(IndexError, ValueError):             # <<<<<<<<<<<<<<
 * 
 *         def __init__(self, *args, **kwargs):
 */
  __pyx_tuple__195 = PyTuple_Pack(2, __pyx_builtin_IndexError, __pyx_builtin_ValueError); if (unlikely(!__pyx_tuple__195)) __PYX_ERR(0, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__195);
  __Pyx_GIVEREF(__pyx_tuple__195);

  /* "cupy/core/core.pyx":48
 *     class IndexOrValueError(IndexError, ValueError):
 * 
 *         def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *             super(IndexOrValueError, self).__init__(*args, **kwargs)
 * 
 */
  __pyx_tuple__196 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__196)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__196);
  __Pyx_GIVEREF(__pyx_tuple__196);
  __pyx_codeobj__197 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__196, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_init, 48, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__197)) __PYX_ERR(0, 48, __pyx_L1_error)

  /* "cupy/core/core.pyx":1621
 *         return int(self.get())
 * 
 *     if sys.version_info < (3,):             # <<<<<<<<<<<<<<
 *         def __long__(self):
 *             # Avoid using long() for flake8
 */
  __pyx_tuple__198 = PyTuple_Pack(1, __pyx_int_3); if (unlikely(!__pyx_tuple__198)) __PYX_ERR(0, 1621, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__198);
  __Pyx_GIVEREF(__pyx_tuple__198);

  /* "cupy/core/elementwise.pxi":39
 * 
 * cdef dict _typenames_base = {
 *     numpy.dtype('float64'): 'double',             # <<<<<<<<<<<<<<
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',
 */
  __pyx_tuple__199 = PyTuple_Pack(1, __pyx_n_s_float64); if (unlikely(!__pyx_tuple__199)) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__199);
  __Pyx_GIVEREF(__pyx_tuple__199);

  /* "cupy/core/elementwise.pxi":40
 * cdef dict _typenames_base = {
 *     numpy.dtype('float64'): 'double',
 *     numpy.dtype('float32'): 'float',             # <<<<<<<<<<<<<<
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('complex128'): 'complex<double>',
 */
  __pyx_tuple__200 = PyTuple_Pack(1, __pyx_n_s_float32); if (unlikely(!__pyx_tuple__200)) __PYX_ERR(1, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__200);
  __Pyx_GIVEREF(__pyx_tuple__200);

  /* "cupy/core/elementwise.pxi":41
 *     numpy.dtype('float64'): 'double',
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',             # <<<<<<<<<<<<<<
 *     numpy.dtype('complex128'): 'complex<double>',
 *     numpy.dtype('complex64'): 'complex<float>',
 */
  __pyx_tuple__201 = PyTuple_Pack(1, __pyx_n_s_float16); if (unlikely(!__pyx_tuple__201)) __PYX_ERR(1, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__201);
  __Pyx_GIVEREF(__pyx_tuple__201);

  /* "cupy/core/elementwise.pxi":42
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('complex128'): 'complex<double>',             # <<<<<<<<<<<<<<
 *     numpy.dtype('complex64'): 'complex<float>',
 *     numpy.dtype('int64'): 'long long',
 */
  __pyx_tuple__202 = PyTuple_Pack(1, __pyx_n_s_complex128); if (unlikely(!__pyx_tuple__202)) __PYX_ERR(1, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__202);
  __Pyx_GIVEREF(__pyx_tuple__202);

  /* "cupy/core/elementwise.pxi":43
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('complex128'): 'complex<double>',
 *     numpy.dtype('complex64'): 'complex<float>',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',
 */
  __pyx_tuple__203 = PyTuple_Pack(1, __pyx_n_s_complex64); if (unlikely(!__pyx_tuple__203)) __PYX_ERR(1, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__203);
  __Pyx_GIVEREF(__pyx_tuple__203);

  /* "cupy/core/elementwise.pxi":44
 *     numpy.dtype('complex128'): 'complex<double>',
 *     numpy.dtype('complex64'): 'complex<float>',
 *     numpy.dtype('int64'): 'long long',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',
 */
  __pyx_tuple__204 = PyTuple_Pack(1, __pyx_n_s_int64); if (unlikely(!__pyx_tuple__204)) __PYX_ERR(1, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__204);
  __Pyx_GIVEREF(__pyx_tuple__204);

  /* "cupy/core/elementwise.pxi":45
 *     numpy.dtype('complex64'): 'complex<float>',
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',
 */
  __pyx_tuple__205 = PyTuple_Pack(1, __pyx_n_s_int32); if (unlikely(!__pyx_tuple__205)) __PYX_ERR(1, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__205);
  __Pyx_GIVEREF(__pyx_tuple__205);

  /* "cupy/core/elementwise.pxi":46
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',
 */
  __pyx_tuple__206 = PyTuple_Pack(1, __pyx_n_s_int16); if (unlikely(!__pyx_tuple__206)) __PYX_ERR(1, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__206);
  __Pyx_GIVEREF(__pyx_tuple__206);

  /* "cupy/core/elementwise.pxi":47
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',
 */
  __pyx_tuple__207 = PyTuple_Pack(1, __pyx_n_s_int8); if (unlikely(!__pyx_tuple__207)) __PYX_ERR(1, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__207);
  __Pyx_GIVEREF(__pyx_tuple__207);

  /* "cupy/core/elementwise.pxi":48
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',
 */
  __pyx_tuple__208 = PyTuple_Pack(1, __pyx_n_s_uint64); if (unlikely(!__pyx_tuple__208)) __PYX_ERR(1, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__208);
  __Pyx_GIVEREF(__pyx_tuple__208);

  /* "cupy/core/elementwise.pxi":49
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',
 */
  __pyx_tuple__209 = PyTuple_Pack(1, __pyx_n_s_uint32); if (unlikely(!__pyx_tuple__209)) __PYX_ERR(1, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__209);
  __Pyx_GIVEREF(__pyx_tuple__209);

  /* "cupy/core/elementwise.pxi":50
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint8'): 'unsigned char',
 *     numpy.dtype('bool'): 'bool',
 */
  __pyx_tuple__210 = PyTuple_Pack(1, __pyx_n_s_uint16); if (unlikely(!__pyx_tuple__210)) __PYX_ERR(1, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__210);
  __Pyx_GIVEREF(__pyx_tuple__210);

  /* "cupy/core/elementwise.pxi":51
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',             # <<<<<<<<<<<<<<
 *     numpy.dtype('bool'): 'bool',
 * }
 */
  __pyx_tuple__211 = PyTuple_Pack(1, __pyx_n_s_uint8); if (unlikely(!__pyx_tuple__211)) __PYX_ERR(1, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__211);
  __Pyx_GIVEREF(__pyx_tuple__211);

  /* "cupy/core/elementwise.pxi":52
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',
 *     numpy.dtype('bool'): 'bool',             # <<<<<<<<<<<<<<
 * }
 * 
 */
  __pyx_tuple__212 = PyTuple_Pack(1, __pyx_n_s_bool_2); if (unlikely(!__pyx_tuple__212)) __PYX_ERR(1, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__212);
  __Pyx_GIVEREF(__pyx_tuple__212);

  /* "cupy/core/elementwise.pxi":287
 * 
 * @util.memoize()
 * def _get_param_info(s, is_const):             # <<<<<<<<<<<<<<
 *     if len(s) == 0:
 *         return ()
 */
  __pyx_tuple__213 = PyTuple_Pack(3, __pyx_n_s_s_2, __pyx_n_s_is_const, __pyx_n_s_i); if (unlikely(!__pyx_tuple__213)) __PYX_ERR(1, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__213);
  __Pyx_GIVEREF(__pyx_tuple__213);
  __pyx_codeobj__214 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__213, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_get_param_info, 287, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__214)) __PYX_ERR(1, 287, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":294
 * 
 * @util.memoize()
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):             # <<<<<<<<<<<<<<
 *     type_dict = {}
 *     if out_args_dtype:
 */
  __pyx_tuple__215 = PyTuple_Pack(11, __pyx_n_s_in_params, __pyx_n_s_out_params, __pyx_n_s_in_args_dtype, __pyx_n_s_out_args_dtype, __pyx_n_s_type_dict, __pyx_n_s_p, __pyx_n_s_a, __pyx_n_s_t, __pyx_n_s_unknown_ctype, __pyx_n_s_in_types, __pyx_n_s_out_types); if (unlikely(!__pyx_tuple__215)) __PYX_ERR(1, 294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__215);
  __Pyx_GIVEREF(__pyx_tuple__215);
  __pyx_codeobj__216 = (PyObject*)__Pyx_PyCode_New(4, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__215, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_decide_params_type, 294, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__216)) __PYX_ERR(1, 294, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":420
 * 
 * @util.memoize(for_each_device=True)
 * def _get_elementwise_kernel(args_info, types, params, operation, name,             # <<<<<<<<<<<<<<
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)
 */
  __pyx_tuple__217 = PyTuple_Pack(15, __pyx_n_s_args_info, __pyx_n_s_types, __pyx_n_s_params, __pyx_n_s_operation, __pyx_n_s_name, __pyx_n_s_preamble, __pyx_n_s_kwargs, __pyx_n_s_kernel_params, __pyx_n_s_types_preamble, __pyx_n_s_op, __pyx_n_s_p, __pyx_n_s_a, __pyx_n_s_fmt, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__217)) __PYX_ERR(1, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__217);
  __Pyx_GIVEREF(__pyx_tuple__217);
  __pyx_codeobj__218 = (PyObject*)__Pyx_PyCode_New(7, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__217, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_get_elementwise_kernel, 420, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__218)) __PYX_ERR(1, 420, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":595
 * 
 * @util.memoize(for_each_device=True)
 * def _get_ufunc_kernel(             # <<<<<<<<<<<<<<
 *         in_types, out_types, routine, args_info, params, name, preamble):
 *     kernel_params = _get_kernel_params(params, args_info)
 */
  __pyx_tuple__219 = PyTuple_Pack(13, __pyx_n_s_in_types, __pyx_n_s_out_types, __pyx_n_s_routine, __pyx_n_s_args_info, __pyx_n_s_params, __pyx_n_s_name, __pyx_n_s_preamble, __pyx_n_s_kernel_params, __pyx_n_s_types, __pyx_n_s_op, __pyx_n_s_i, __pyx_n_s_x, __pyx_n_s_operation); if (unlikely(!__pyx_tuple__219)) __PYX_ERR(1, 595, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__219);
  __Pyx_GIVEREF(__pyx_tuple__219);
  __pyx_codeobj__220 = (PyObject*)__Pyx_PyCode_New(7, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__219, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_get_ufunc_kernel, 595, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__220)) __PYX_ERR(1, 595, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":696
 * 
 * 
 * class ufunc(object):             # <<<<<<<<<<<<<<
 * 
 *     """Universal function.
 */
  __pyx_tuple__221 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__221)) __PYX_ERR(1, 696, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__221);
  __Pyx_GIVEREF(__pyx_tuple__221);

  /* "cupy/core/elementwise.pxi":708
 *     """
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                  default_casting=None):
 *         self.name = name
 */
  __pyx_tuple__222 = PyTuple_Pack(13, __pyx_n_s_self, __pyx_n_s_name, __pyx_n_s_nin, __pyx_n_s_nout, __pyx_n_s_ops, __pyx_n_s_preamble, __pyx_n_s_doc, __pyx_n_s_default_casting, __pyx_n_s_in_params_2, __pyx_n_s_out_params_2, __pyx_n_s_genexpr, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__222)) __PYX_ERR(1, 708, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__222);
  __Pyx_GIVEREF(__pyx_tuple__222);
  __pyx_codeobj__223 = (PyObject*)__Pyx_PyCode_New(8, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__222, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_init, 708, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__223)) __PYX_ERR(1, 708, __pyx_L1_error)
  __pyx_tuple__224 = PyTuple_Pack(3, ((PyObject*)__pyx_kp_s__6), ((PyObject*)__pyx_kp_s__6), ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__224)) __PYX_ERR(1, 708, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__224);
  __Pyx_GIVEREF(__pyx_tuple__224);

  /* "cupy/core/elementwise.pxi":731
 *         self._routine_cache = {}
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<ufunc '%s'>" % self.name
 * 
 */
  __pyx_tuple__225 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__225)) __PYX_ERR(1, 731, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__225);
  __Pyx_GIVEREF(__pyx_tuple__225);
  __pyx_codeobj__226 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__225, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_repr, 731, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__226)) __PYX_ERR(1, 731, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":735
 * 
 *     @property
 *     def types(self):             # <<<<<<<<<<<<<<
 *         """A list of type signatures.
 * 
 */
  __pyx_tuple__228 = PyTuple_Pack(8, __pyx_n_s_self, __pyx_n_s_types, __pyx_n_s_in_types, __pyx_n_s_out_types, __pyx_n_s__227, __pyx_n_s_in_str, __pyx_n_s_out_str, __pyx_n_s_t); if (unlikely(!__pyx_tuple__228)) __PYX_ERR(1, 735, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__228);
  __Pyx_GIVEREF(__pyx_tuple__228);
  __pyx_codeobj__229 = (PyObject*)__Pyx_PyCode_New(1, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__228, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_types, 735, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__229)) __PYX_ERR(1, 735, __pyx_L1_error)

  /* "cupy/core/elementwise.pxi":749
 *         return types
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Applies the universal function to arguments elementwise.
 * 
 */
  __pyx_tuple__230 = PyTuple_Pack(22, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_kwargs, __pyx_n_s_kern, __pyx_n_s_out, __pyx_n_s_dtype, __pyx_n_s_casting, __pyx_n_s_n_args, __pyx_n_s_in_args, __pyx_n_s_out_args, __pyx_n_s_broad, __pyx_n_s_shape, __pyx_n_s_in_types, __pyx_n_s_out_types, __pyx_n_s_routine, __pyx_n_s_ret, __pyx_n_s_inout_args, __pyx_n_s_i, __pyx_n_s_t, __pyx_n_s_x, __pyx_n_s_indexer, __pyx_n_s_args_info); if (unlikely(!__pyx_tuple__230)) __PYX_ERR(1, 749, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__230);
  __Pyx_GIVEREF(__pyx_tuple__230);
  __pyx_codeobj__231 = (PyObject*)__Pyx_PyCode_New(1, 0, 22, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__230, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_elementwise_pxi, __pyx_n_s_call, 749, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__231)) __PYX_ERR(1, 749, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":166
 * 
 * @util.memoize(for_each_device=True)
 * def _get_simple_reduction_function(             # <<<<<<<<<<<<<<
 *         routine, params, args_info, in_arg_dtype, out_arg_dtype, out_types,
 *         name, block_size, identity, input_expr, output_expr, _preamble,
 */
  __pyx_tuple__232 = PyTuple_Pack(16, __pyx_n_s_routine, __pyx_n_s_params, __pyx_n_s_args_info, __pyx_n_s_in_arg_dtype, __pyx_n_s_out_arg_dtype, __pyx_n_s_out_types, __pyx_n_s_name, __pyx_n_s_block_size, __pyx_n_s_identity, __pyx_n_s_input_expr, __pyx_n_s_output_expr, __pyx_n_s_preamble_2, __pyx_n_s_options, __pyx_n_s_reduce_type, __pyx_n_s_t, __pyx_n_s_type_preamble); if (unlikely(!__pyx_tuple__232)) __PYX_ERR(5, 166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__232);
  __Pyx_GIVEREF(__pyx_tuple__232);
  __pyx_codeobj__233 = (PyObject*)__Pyx_PyCode_New(13, 0, 16, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__232, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_reduction_pxi, __pyx_n_s_get_simple_reduction_function, 166, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__233)) __PYX_ERR(5, 166, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":184
 * 
 * 
 * class simple_reduction_function(object):             # <<<<<<<<<<<<<<
 * 
 *     _block_size = 512
 */
  __pyx_tuple__234 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__234)) __PYX_ERR(5, 184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__234);
  __Pyx_GIVEREF(__pyx_tuple__234);

  /* "cupy/core/reduction.pxi":188
 *     _block_size = 512
 * 
 *     def __init__(self, name, ops, identity, preamble):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self._ops = ops
 */
  __pyx_tuple__235 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_name, __pyx_n_s_ops, __pyx_n_s_identity, __pyx_n_s_preamble, __pyx_n_s_in_params, __pyx_n_s_out_params); if (unlikely(!__pyx_tuple__235)) __PYX_ERR(5, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__235);
  __Pyx_GIVEREF(__pyx_tuple__235);
  __pyx_codeobj__236 = (PyObject*)__Pyx_PyCode_New(5, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__235, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_reduction_pxi, __pyx_n_s_init, 188, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__236)) __PYX_ERR(5, 188, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":206
 *         self._routine_cache = {}
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,             # <<<<<<<<<<<<<<
 *                  bint keepdims=False):
 *         cdef list in_args, out_args
 */
  __pyx_tuple__237 = PyTuple_Pack(26, __pyx_n_s_self, __pyx_n_s_a, __pyx_n_s_axis, __pyx_n_s_dtype, __pyx_n_s_out, __pyx_n_s_keepdims, __pyx_n_s_in_args, __pyx_n_s_out_args, __pyx_n_s_in_sahpe, __pyx_n_s_laxis, __pyx_n_s_raxis, __pyx_n_s_a_shape, __pyx_n_s_in_types, __pyx_n_s_out_types, __pyx_n_s_routine, __pyx_n_s_out_shape, __pyx_n_s_in_shape, __pyx_n_s_block_size, __pyx_n_s_in_indexer, __pyx_n_s_out_indexer, __pyx_n_s_clp2_count, __pyx_n_s_block_stride, __pyx_n_s_inout_args, __pyx_n_s_args_info, __pyx_n_s_kern, __pyx_n_s_shared_mem); if (unlikely(!__pyx_tuple__237)) __PYX_ERR(5, 206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__237);
  __Pyx_GIVEREF(__pyx_tuple__237);
  __pyx_codeobj__238 = (PyObject*)__Pyx_PyCode_New(6, 0, 26, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__237, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_reduction_pxi, __pyx_n_s_call, 206, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__238)) __PYX_ERR(5, 206, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":273
 * 
 * @util.memoize(for_each_device=True)
 * def _get_reduction_kernel(             # <<<<<<<<<<<<<<
 *         params, args_info, types,
 *         name, block_size, reduce_type, identity, map_expr, reduce_expr,
 */
  __pyx_tuple__239 = PyTuple_Pack(21, __pyx_n_s_params, __pyx_n_s_args_info, __pyx_n_s_types, __pyx_n_s_name, __pyx_n_s_block_size, __pyx_n_s_reduce_type, __pyx_n_s_identity, __pyx_n_s_map_expr, __pyx_n_s_reduce_expr, __pyx_n_s_post_map_expr, __pyx_n_s_preamble, __pyx_n_s_options, __pyx_n_s_kernel_params, __pyx_n_s_arrays, __pyx_n_s_type_preamble, __pyx_n_s_input_expr, __pyx_n_s_output_expr, __pyx_n_s_p, __pyx_n_s_a, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__239)) __PYX_ERR(5, 273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__239);
  __Pyx_GIVEREF(__pyx_tuple__239);
  __pyx_codeobj__240 = (PyObject*)__Pyx_PyCode_New(12, 0, 21, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__239, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_reduction_pxi, __pyx_n_s_get_reduction_kernel, 273, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__240)) __PYX_ERR(5, 273, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":296
 * 
 * 
 * class ReductionKernel(object):             # <<<<<<<<<<<<<<
 * 
 *     """User-defined reduction kernel.
 */
  __pyx_tuple__241 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__241)) __PYX_ERR(5, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__241);
  __Pyx_GIVEREF(__pyx_tuple__241);

  /* "cupy/core/reduction.pxi":327
 * 
 *     """
 *     def __init__(self, in_params, out_params,             # <<<<<<<<<<<<<<
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,
 */
  __pyx_tuple__242 = PyTuple_Pack(12, __pyx_n_s_self, __pyx_n_s_in_params, __pyx_n_s_out_params, __pyx_n_s_map_expr, __pyx_n_s_reduce_expr, __pyx_n_s_post_map_expr, __pyx_n_s_identity, __pyx_n_s_name, __pyx_n_s_reduce_type, __pyx_n_s_reduce_dims, __pyx_n_s_preamble, __pyx_n_s_options); if (unlikely(!__pyx_tuple__242)) __PYX_ERR(5, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__242);
  __Pyx_GIVEREF(__pyx_tuple__242);
  __pyx_codeobj__243 = (PyObject*)__Pyx_PyCode_New(12, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__242, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_reduction_pxi, __pyx_n_s_init, 327, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__243)) __PYX_ERR(5, 327, __pyx_L1_error)
  __pyx_tuple__244 = PyTuple_Pack(5, ((PyObject*)__pyx_n_s_reduce_kernel), ((PyObject *)Py_None), ((PyObject *)Py_True), ((PyObject*)__pyx_kp_s__6), ((PyObject*)__pyx_empty_tuple)); if (unlikely(!__pyx_tuple__244)) __PYX_ERR(5, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__244);
  __Pyx_GIVEREF(__pyx_tuple__244);

  /* "cupy/core/reduction.pxi":357
 *         self.preamble = preamble
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the reduction kernel.
 * 
 */
  __pyx_tuple__245 = PyTuple_Pack(31, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_kwargs, __pyx_n_s_out, __pyx_n_s_axis, __pyx_n_s_keepdims, __pyx_n_s_stream, __pyx_n_s_n_args, __pyx_n_s_out_args, __pyx_n_s_in_args, __pyx_n_s_broad_shape, __pyx_n_s_in_ndarray_types, __pyx_n_s_out_ndarray_types, __pyx_n_s_in_types, __pyx_n_s_out_types, __pyx_n_s_types, __pyx_n_s_raxis, __pyx_n_s_out_shape, __pyx_n_s_in_shape, __pyx_n_s_block_size, __pyx_n_s_in_indexer, __pyx_n_s_out_indexer, __pyx_n_s_clp2_count, __pyx_n_s_block_stride, __pyx_n_s_inout_args, __pyx_n_s_args_info, __pyx_n_s_kern, __pyx_n_s_shared_mem, __pyx_n_s_a, __pyx_n_s_x, __pyx_n_s_t); if (unlikely(!__pyx_tuple__245)) __PYX_ERR(5, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__245);
  __Pyx_GIVEREF(__pyx_tuple__245);
  __pyx_codeobj__246 = (PyObject*)__Pyx_PyCode_New(1, 0, 31, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__245, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_reduction_pxi, __pyx_n_s_call, 357, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__246)) __PYX_ERR(5, 357, __pyx_L1_error)

  /* "cupy/core/core.pyx":1852
 * elementwise_copy = create_ufunc(
 *     'cupy_copy',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d', 'F->F', 'D->D'),
 *     'out0 = out0_type(in0)', default_casting='unsafe')
 */
  __pyx_tuple__248 = PyTuple_Pack(16, __pyx_kp_s__247, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_kp_s_F_F, __pyx_kp_s_D_D); if (unlikely(!__pyx_tuple__248)) __PYX_ERR(0, 1852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__248);
  __Pyx_GIVEREF(__pyx_tuple__248);

  /* "cupy/core/core.pyx":1850
 * cdef str _id = 'out0 = in0'
 * 
 * elementwise_copy = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_copy',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_tuple__249 = PyTuple_Pack(3, __pyx_n_s_cupy_copy, __pyx_tuple__248, __pyx_kp_s_out0_out0_type_in0); if (unlikely(!__pyx_tuple__249)) __PYX_ERR(0, 1850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__249);
  __Pyx_GIVEREF(__pyx_tuple__249);

  /* "cupy/core/core.pyx":1859
 * elementwise_copy_where = create_ufunc(
 *     'cupy_copy_where',
 *     ('??->?', 'b?->b', 'B?->B', 'h?->h', 'H?->H', 'i?->i', 'I?->I', 'l?->l',             # <<<<<<<<<<<<<<
 *      'L?->L', 'q?->q', 'Q?->Q', 'e?->e', 'f?->f', 'd?->d', 'F?->F', 'D?->D'),
 *     'if (in1) out0 = in0', default_casting='unsafe')
 */
  __pyx_tuple__250 = PyTuple_Pack(16, __pyx_kp_s__105, __pyx_kp_s_b_b_2, __pyx_kp_s_B_B_2, __pyx_kp_s_h_h_2, __pyx_kp_s_H_H_2, __pyx_kp_s_i_i_2, __pyx_kp_s_I_I_2, __pyx_kp_s_l_l_2, __pyx_kp_s_L_L_2, __pyx_kp_s_q_q_2, __pyx_kp_s_Q_Q_2, __pyx_kp_s_e_e_2, __pyx_kp_s_f_f_2, __pyx_kp_s_d_d_2, __pyx_kp_s_F_F_2, __pyx_kp_s_D_D_2); if (unlikely(!__pyx_tuple__250)) __PYX_ERR(0, 1859, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__250);
  __Pyx_GIVEREF(__pyx_tuple__250);

  /* "cupy/core/core.pyx":1857
 * # complex numbers requires out0 = complex<T>(in0)
 * 
 * elementwise_copy_where = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_copy_where',
 *     ('??->?', 'b?->b', 'B?->B', 'h?->h', 'H?->H', 'i?->i', 'I?->I', 'l?->l',
 */
  __pyx_tuple__251 = PyTuple_Pack(3, __pyx_n_s_cupy_copy_where, __pyx_tuple__250, __pyx_kp_s_if_in1_out0_in0); if (unlikely(!__pyx_tuple__251)) __PYX_ERR(0, 1857, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__251);
  __Pyx_GIVEREF(__pyx_tuple__251);

  /* "cupy/core/core.pyx":1984
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, 'my_min_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('f->f', (None, 'my_min_float(a, b)', None, None)),
 *      ('d->d', (None, 'my_min_float(a, b)', None, None))),
 */
  __pyx_tuple__252 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_min_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__252)) __PYX_ERR(0, 1984, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__252);
  __Pyx_GIVEREF(__pyx_tuple__252);
  __pyx_tuple__253 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__252); if (unlikely(!__pyx_tuple__253)) __PYX_ERR(0, 1984, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__253);
  __Pyx_GIVEREF(__pyx_tuple__253);

  /* "cupy/core/core.pyx":1985
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, 'my_min_float(a, b)', None, None)),
 *      ('f->f', (None, 'my_min_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('d->d', (None, 'my_min_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_min(a, b)', 'out0 = a.value',
 */
  __pyx_tuple__254 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_min_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__254)) __PYX_ERR(0, 1985, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__254);
  __Pyx_GIVEREF(__pyx_tuple__254);
  __pyx_tuple__255 = PyTuple_Pack(2, __pyx_kp_s_f_f, __pyx_tuple__254); if (unlikely(!__pyx_tuple__255)) __PYX_ERR(0, 1985, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__255);
  __Pyx_GIVEREF(__pyx_tuple__255);

  /* "cupy/core/core.pyx":1986
 *      ('e->e', (None, 'my_min_float(a, b)', None, None)),
 *      ('f->f', (None, 'my_min_float(a, b)', None, None)),
 *      ('d->d', (None, 'my_min_float(a, b)', None, None))),             # <<<<<<<<<<<<<<
 *     ('min_max_st<type_in0_raw>(in0)', 'my_min(a, b)', 'out0 = a.value',
 *      'min_max_st<type_in0_raw>'),
 */
  __pyx_tuple__256 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_min_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__256)) __PYX_ERR(0, 1986, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__256);
  __Pyx_GIVEREF(__pyx_tuple__256);
  __pyx_tuple__257 = PyTuple_Pack(2, __pyx_kp_s_d_d, __pyx_tuple__256); if (unlikely(!__pyx_tuple__257)) __PYX_ERR(0, 1986, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__257);
  __Pyx_GIVEREF(__pyx_tuple__257);

  /* "cupy/core/core.pyx":1982
 * _amin = create_reduction_func(
 *     'cupy_min',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, 'my_min_float(a, b)', None, None)),
 */
  __pyx_tuple__258 = PyTuple_Pack(14, __pyx_kp_s__247, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_tuple__253, __pyx_tuple__255, __pyx_tuple__257); if (unlikely(!__pyx_tuple__258)) __PYX_ERR(0, 1982, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__258);
  __Pyx_GIVEREF(__pyx_tuple__258);

  /* "cupy/core/core.pyx":1987
 *      ('f->f', (None, 'my_min_float(a, b)', None, None)),
 *      ('d->d', (None, 'my_min_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_min(a, b)', 'out0 = a.value',             # <<<<<<<<<<<<<<
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)
 */
  __pyx_tuple__259 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_type_in0_raw_in0, __pyx_kp_s_my_min_a_b, __pyx_kp_s_out0_a_value, __pyx_kp_s_min_max_st_type_in0_raw); if (unlikely(!__pyx_tuple__259)) __PYX_ERR(0, 1987, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__259);
  __Pyx_GIVEREF(__pyx_tuple__259);

  /* "cupy/core/core.pyx":1996
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, 'my_max_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('f->f', (None, 'my_max_float(a, b)', None, None)),
 *      ('d->d', (None, 'my_max_float(a, b)', None, None))),
 */
  __pyx_tuple__260 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_max_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__260)) __PYX_ERR(0, 1996, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__260);
  __Pyx_GIVEREF(__pyx_tuple__260);
  __pyx_tuple__261 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__260); if (unlikely(!__pyx_tuple__261)) __PYX_ERR(0, 1996, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__261);
  __Pyx_GIVEREF(__pyx_tuple__261);

  /* "cupy/core/core.pyx":1997
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, 'my_max_float(a, b)', None, None)),
 *      ('f->f', (None, 'my_max_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('d->d', (None, 'my_max_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_max(a, b)', 'out0 = a.value',
 */
  __pyx_tuple__262 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_max_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__262)) __PYX_ERR(0, 1997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__262);
  __Pyx_GIVEREF(__pyx_tuple__262);
  __pyx_tuple__263 = PyTuple_Pack(2, __pyx_kp_s_f_f, __pyx_tuple__262); if (unlikely(!__pyx_tuple__263)) __PYX_ERR(0, 1997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__263);
  __Pyx_GIVEREF(__pyx_tuple__263);

  /* "cupy/core/core.pyx":1998
 *      ('e->e', (None, 'my_max_float(a, b)', None, None)),
 *      ('f->f', (None, 'my_max_float(a, b)', None, None)),
 *      ('d->d', (None, 'my_max_float(a, b)', None, None))),             # <<<<<<<<<<<<<<
 *     ('min_max_st<type_in0_raw>(in0)', 'my_max(a, b)', 'out0 = a.value',
 *      'min_max_st<type_in0_raw>'),
 */
  __pyx_tuple__264 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_max_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__264)) __PYX_ERR(0, 1998, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__264);
  __Pyx_GIVEREF(__pyx_tuple__264);
  __pyx_tuple__265 = PyTuple_Pack(2, __pyx_kp_s_d_d, __pyx_tuple__264); if (unlikely(!__pyx_tuple__265)) __PYX_ERR(0, 1998, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__265);
  __Pyx_GIVEREF(__pyx_tuple__265);

  /* "cupy/core/core.pyx":1994
 * _amax = create_reduction_func(
 *     'cupy_max',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, 'my_max_float(a, b)', None, None)),
 */
  __pyx_tuple__266 = PyTuple_Pack(14, __pyx_kp_s__247, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_tuple__261, __pyx_tuple__263, __pyx_tuple__265); if (unlikely(!__pyx_tuple__266)) __PYX_ERR(0, 1994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__266);
  __Pyx_GIVEREF(__pyx_tuple__266);

  /* "cupy/core/core.pyx":1999
 *      ('f->f', (None, 'my_max_float(a, b)', None, None)),
 *      ('d->d', (None, 'my_max_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_max(a, b)', 'out0 = a.value',             # <<<<<<<<<<<<<<
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)
 */
  __pyx_tuple__267 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_type_in0_raw_in0, __pyx_kp_s_my_max_a_b, __pyx_kp_s_out0_a_value, __pyx_kp_s_min_max_st_type_in0_raw); if (unlikely(!__pyx_tuple__267)) __PYX_ERR(0, 1999, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__267);
  __Pyx_GIVEREF(__pyx_tuple__267);

  /* "cupy/core/core.pyx":2006
 * nanmin = create_reduction_func(
 *     'cupy_nanmin',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d'),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_min(a, b)', 'out0 = a.value',
 */
  __pyx_tuple__268 = PyTuple_Pack(14, __pyx_kp_s__247, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d); if (unlikely(!__pyx_tuple__268)) __PYX_ERR(0, 2006, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__268);
  __Pyx_GIVEREF(__pyx_tuple__268);

  /* "cupy/core/core.pyx":2008
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d'),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_min(a, b)', 'out0 = a.value',             # <<<<<<<<<<<<<<
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)
 */
  __pyx_tuple__269 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_type_in0_raw_in0, __pyx_kp_s_my_min_a_b, __pyx_kp_s_out0_a_value, __pyx_kp_s_min_max_st_type_in0_raw); if (unlikely(!__pyx_tuple__269)) __PYX_ERR(0, 2008, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__269);
  __Pyx_GIVEREF(__pyx_tuple__269);

  /* "cupy/core/core.pyx":2015
 * nanmax = create_reduction_func(
 *     'cupy_nanmax',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d'),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_max(a, b)', 'out0 = a.value',
 */
  __pyx_tuple__270 = PyTuple_Pack(14, __pyx_kp_s__247, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d); if (unlikely(!__pyx_tuple__270)) __PYX_ERR(0, 2015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__270);
  __Pyx_GIVEREF(__pyx_tuple__270);

  /* "cupy/core/core.pyx":2017
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d'),
 *     ('min_max_st<type_in0_raw>(in0)', 'my_max(a, b)', 'out0 = a.value',             # <<<<<<<<<<<<<<
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)
 */
  __pyx_tuple__271 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_type_in0_raw_in0, __pyx_kp_s_my_max_a_b, __pyx_kp_s_out0_a_value, __pyx_kp_s_min_max_st_type_in0_raw); if (unlikely(!__pyx_tuple__271)) __PYX_ERR(0, 2017, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__271);
  __Pyx_GIVEREF(__pyx_tuple__271);

  /* "cupy/core/core.pyx":2026
 *     ('?->q', 'B->q', 'h->q', 'H->q', 'i->q', 'I->q', 'l->q', 'L->q',
 *      'q->q', 'Q->q',
 *      ('e->q', (None, 'my_argmin_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('f->q', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('d->q', (None, 'my_argmin_float(a, b)', None, None))),
 */
  __pyx_tuple__272 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmin_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__272)) __PYX_ERR(0, 2026, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__272);
  __Pyx_GIVEREF(__pyx_tuple__272);
  __pyx_tuple__273 = PyTuple_Pack(2, __pyx_kp_s_e_q, __pyx_tuple__272); if (unlikely(!__pyx_tuple__273)) __PYX_ERR(0, 2026, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__273);
  __Pyx_GIVEREF(__pyx_tuple__273);

  /* "cupy/core/core.pyx":2027
 *      'q->q', 'Q->q',
 *      ('e->q', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('f->q', (None, 'my_argmin_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('d->q', (None, 'my_argmin_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmin(a, b)', 'out0 = a.index',
 */
  __pyx_tuple__274 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmin_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__274)) __PYX_ERR(0, 2027, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__274);
  __Pyx_GIVEREF(__pyx_tuple__274);
  __pyx_tuple__275 = PyTuple_Pack(2, __pyx_kp_s_f_q, __pyx_tuple__274); if (unlikely(!__pyx_tuple__275)) __PYX_ERR(0, 2027, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__275);
  __Pyx_GIVEREF(__pyx_tuple__275);

  /* "cupy/core/core.pyx":2028
 *      ('e->q', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('f->q', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('d->q', (None, 'my_argmin_float(a, b)', None, None))),             # <<<<<<<<<<<<<<
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmin(a, b)', 'out0 = a.index',
 *      'min_max_st<type_in0_raw>'),
 */
  __pyx_tuple__276 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmin_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__276)) __PYX_ERR(0, 2028, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__276);
  __Pyx_GIVEREF(__pyx_tuple__276);
  __pyx_tuple__277 = PyTuple_Pack(2, __pyx_kp_s_d_q, __pyx_tuple__276); if (unlikely(!__pyx_tuple__277)) __PYX_ERR(0, 2028, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__277);
  __Pyx_GIVEREF(__pyx_tuple__277);

  /* "cupy/core/core.pyx":2024
 * cdef _argmin = create_reduction_func(
 *     'cupy_argmin',
 *     ('?->q', 'B->q', 'h->q', 'H->q', 'i->q', 'I->q', 'l->q', 'L->q',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->q',
 *      ('e->q', (None, 'my_argmin_float(a, b)', None, None)),
 */
  __pyx_tuple__278 = PyTuple_Pack(13, __pyx_kp_s_q, __pyx_kp_s_B_q, __pyx_kp_s_h_q, __pyx_kp_s_H_q, __pyx_kp_s_i_q, __pyx_kp_s_I_q, __pyx_kp_s_l_q, __pyx_kp_s_L_q, __pyx_kp_s_q_q, __pyx_kp_s_Q_q, __pyx_tuple__273, __pyx_tuple__275, __pyx_tuple__277); if (unlikely(!__pyx_tuple__278)) __PYX_ERR(0, 2024, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__278);
  __Pyx_GIVEREF(__pyx_tuple__278);

  /* "cupy/core/core.pyx":2029
 *      ('f->q', (None, 'my_argmin_float(a, b)', None, None)),
 *      ('d->q', (None, 'my_argmin_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmin(a, b)', 'out0 = a.index',             # <<<<<<<<<<<<<<
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)
 */
  __pyx_tuple__279 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_type_in0_raw_in0__J, __pyx_kp_s_my_argmin_a_b, __pyx_kp_s_out0_a_index, __pyx_kp_s_min_max_st_type_in0_raw); if (unlikely(!__pyx_tuple__279)) __PYX_ERR(0, 2029, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__279);
  __Pyx_GIVEREF(__pyx_tuple__279);

  /* "cupy/core/core.pyx":2038
 *     ('?->q', 'B->q', 'h->q', 'H->q', 'i->q', 'I->q', 'l->q', 'L->q',
 *      'q->q', 'Q->q',
 *      ('e->q', (None, 'my_argmax_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('f->q', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('d->q', (None, 'my_argmax_float(a, b)', None, None))),
 */
  __pyx_tuple__280 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmax_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__280)) __PYX_ERR(0, 2038, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__280);
  __Pyx_GIVEREF(__pyx_tuple__280);
  __pyx_tuple__281 = PyTuple_Pack(2, __pyx_kp_s_e_q, __pyx_tuple__280); if (unlikely(!__pyx_tuple__281)) __PYX_ERR(0, 2038, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__281);
  __Pyx_GIVEREF(__pyx_tuple__281);

  /* "cupy/core/core.pyx":2039
 *      'q->q', 'Q->q',
 *      ('e->q', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('f->q', (None, 'my_argmax_float(a, b)', None, None)),             # <<<<<<<<<<<<<<
 *      ('d->q', (None, 'my_argmax_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmax(a, b)', 'out0 = a.index',
 */
  __pyx_tuple__282 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmax_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__282)) __PYX_ERR(0, 2039, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__282);
  __Pyx_GIVEREF(__pyx_tuple__282);
  __pyx_tuple__283 = PyTuple_Pack(2, __pyx_kp_s_f_q, __pyx_tuple__282); if (unlikely(!__pyx_tuple__283)) __PYX_ERR(0, 2039, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__283);
  __Pyx_GIVEREF(__pyx_tuple__283);

  /* "cupy/core/core.pyx":2040
 *      ('e->q', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('f->q', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('d->q', (None, 'my_argmax_float(a, b)', None, None))),             # <<<<<<<<<<<<<<
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmax(a, b)', 'out0 = a.index',
 *      'min_max_st<type_in0_raw>'),
 */
  __pyx_tuple__284 = PyTuple_Pack(4, Py_None, __pyx_kp_s_my_argmax_float_a_b, Py_None, Py_None); if (unlikely(!__pyx_tuple__284)) __PYX_ERR(0, 2040, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__284);
  __Pyx_GIVEREF(__pyx_tuple__284);
  __pyx_tuple__285 = PyTuple_Pack(2, __pyx_kp_s_d_q, __pyx_tuple__284); if (unlikely(!__pyx_tuple__285)) __PYX_ERR(0, 2040, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__285);
  __Pyx_GIVEREF(__pyx_tuple__285);

  /* "cupy/core/core.pyx":2036
 * cdef _argmax = create_reduction_func(
 *     'cupy_argmax',
 *     ('?->q', 'B->q', 'h->q', 'H->q', 'i->q', 'I->q', 'l->q', 'L->q',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->q',
 *      ('e->q', (None, 'my_argmax_float(a, b)', None, None)),
 */
  __pyx_tuple__286 = PyTuple_Pack(13, __pyx_kp_s_q, __pyx_kp_s_B_q, __pyx_kp_s_h_q, __pyx_kp_s_H_q, __pyx_kp_s_i_q, __pyx_kp_s_I_q, __pyx_kp_s_l_q, __pyx_kp_s_L_q, __pyx_kp_s_q_q, __pyx_kp_s_Q_q, __pyx_tuple__281, __pyx_tuple__283, __pyx_tuple__285); if (unlikely(!__pyx_tuple__286)) __PYX_ERR(0, 2036, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__286);
  __Pyx_GIVEREF(__pyx_tuple__286);

  /* "cupy/core/core.pyx":2041
 *      ('f->q', (None, 'my_argmax_float(a, b)', None, None)),
 *      ('d->q', (None, 'my_argmax_float(a, b)', None, None))),
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmax(a, b)', 'out0 = a.index',             # <<<<<<<<<<<<<<
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)
 */
  __pyx_tuple__287 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_type_in0_raw_in0__J, __pyx_kp_s_my_argmax_a_b, __pyx_kp_s_out0_a_index, __pyx_kp_s_min_max_st_type_in0_raw); if (unlikely(!__pyx_tuple__287)) __PYX_ERR(0, 2041, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__287);
  __Pyx_GIVEREF(__pyx_tuple__287);

  /* "cupy/core/core.pyx":2153
 * # -----------------------------------------------------------------------------
 * 
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):             # <<<<<<<<<<<<<<
 *     for elem in source:
 *         if elem == n:
 */
  __pyx_tuple__288 = PyTuple_Pack(3, __pyx_n_s_source, __pyx_n_s_n, __pyx_n_s_elem); if (unlikely(!__pyx_tuple__288)) __PYX_ERR(0, 2153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__288);
  __Pyx_GIVEREF(__pyx_tuple__288);
  __pyx_codeobj__289 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__288, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_has_element, 2153, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__289)) __PYX_ERR(0, 2153, __pyx_L1_error)

  /* "cupy/core/core.pyx":2228
 * 
 * 
 * def array_split(ndarray ary, indices_or_sections, Py_ssize_t axis):             # <<<<<<<<<<<<<<
 * 
 *     cdef Py_ssize_t i, ndim, size, each_size, index, prev, offset, stride
 */
  __pyx_tuple__290 = PyTuple_Pack(15, __pyx_n_s_ary, __pyx_n_s_indices_or_sections, __pyx_n_s_axis, __pyx_n_s_i, __pyx_n_s_ndim, __pyx_n_s_size, __pyx_n_s_each_size, __pyx_n_s_index, __pyx_n_s_prev, __pyx_n_s_offset, __pyx_n_s_stride, __pyx_n_s_shape, __pyx_n_s_indices, __pyx_n_s_ret, __pyx_n_s_v); if (unlikely(!__pyx_tuple__290)) __PYX_ERR(0, 2228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__290);
  __Pyx_GIVEREF(__pyx_tuple__290);
  __pyx_codeobj__291 = (PyObject*)__Pyx_PyCode_New(3, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__290, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_array_split, 2228, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__291)) __PYX_ERR(0, 2228, __pyx_L1_error)

  /* "cupy/core/core.pyx":2591
 * 
 * 
 * cdef _concatenate_kernel_same_size = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw P x, int64 base',
 *     'T y',
 */
  __pyx_tuple__292 = PyTuple_Pack(4, __pyx_kp_s_raw_P_x_int64_base, __pyx_kp_s_T_y, __pyx_kp_s_ptrdiff_t_middle_i_base_ptrdiff, __pyx_n_s_cupy_concatenate_same_size); if (unlikely(!__pyx_tuple__292)) __PYX_ERR(0, 2591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__292);
  __Pyx_GIVEREF(__pyx_tuple__292);

  /* "cupy/core/core.pyx":2605
 * 
 * 
 * cdef _concatenate_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     '''raw P x, int32 axis, raw int64 cum_sizes, raw int64 x_strides''',
 *     'T y',
 */
  __pyx_tuple__293 = PyTuple_Pack(4, __pyx_kp_s_raw_P_x_int32_axis_raw_int64_cum, __pyx_kp_s_T_y, __pyx_kp_s_ptrdiff_t_axis_ind__ind_get_axi, __pyx_n_s_cupy_concatenate); if (unlikely(!__pyx_tuple__293)) __PYX_ERR(0, 2605, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__293);
  __Pyx_GIVEREF(__pyx_tuple__293);

  /* "cupy/core/core.pyx":2716
 * invert = create_ufunc(
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',             # <<<<<<<<<<<<<<
 *      'l->l', 'L->L', 'q->q', 'Q->Q'),
 *     'out0 = ~in0',
 */
  __pyx_tuple__297 = PyTuple_Pack(2, __pyx_kp_s__247, __pyx_kp_s_out0_in0_2); if (unlikely(!__pyx_tuple__297)) __PYX_ERR(0, 2716, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__297);
  __Pyx_GIVEREF(__pyx_tuple__297);
  __pyx_tuple__298 = PyTuple_Pack(11, __pyx_tuple__297, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q); if (unlikely(!__pyx_tuple__298)) __PYX_ERR(0, 2716, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__298);
  __Pyx_GIVEREF(__pyx_tuple__298);

  /* "cupy/core/core.pyx":2714
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_tuple__299 = PyTuple_Pack(3, __pyx_n_s_cupy_invert, __pyx_tuple__298, __pyx_kp_s_out0_in0_3); if (unlikely(!__pyx_tuple__299)) __PYX_ERR(0, 2714, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__299);
  __Pyx_GIVEREF(__pyx_tuple__299);

  /* "cupy/core/core.pyx":2921
 * 
 * 
 * cdef _take_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 cdim, int32 rdim, int32 adim, S index_range',
 *     'T out',
 */
  __pyx_tuple__302 = PyTuple_Pack(4, __pyx_kp_s_raw_T_a_S_indices_int32_cdim_int, __pyx_kp_s_T_out, __pyx_kp_s_S_wrap_indices_indices_index_ra, __pyx_n_s_cupy_take); if (unlikely(!__pyx_tuple__302)) __PYX_ERR(0, 2921, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__302);
  __Pyx_GIVEREF(__pyx_tuple__302);

  /* "cupy/core/core.pyx":2935
 * 
 * 
 * cdef _take_kernel_0axis = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 rdim, S index_range',
 *     'T out',
 */
  __pyx_tuple__303 = PyTuple_Pack(4, __pyx_kp_s_raw_T_a_S_indices_int32_rdim_S_i, __pyx_kp_s_T_out, __pyx_kp_s_S_wrap_indices_indices_index_ra_2, __pyx_n_s_cupy_take_0axis); if (unlikely(!__pyx_tuple__303)) __PYX_ERR(0, 2935, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__303);
  __Pyx_GIVEREF(__pyx_tuple__303);

  /* "cupy/core/core.pyx":2947
 * 
 * 
 * cdef _choose_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'S a, raw T choices, int32 n_channel',
 *     'T y',
 */
  __pyx_tuple__304 = PyTuple_Pack(4, __pyx_kp_s_S_a_raw_T_choices_int32_n_channe, __pyx_kp_s_T_y, __pyx_kp_s_y_choices_i_n_channel_a, __pyx_n_s_cupy_choose); if (unlikely(!__pyx_tuple__304)) __PYX_ERR(0, 2947, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__304);
  __Pyx_GIVEREF(__pyx_tuple__304);

  /* "cupy/core/core.pyx":2954
 * 
 * 
 * cdef _choose_clip_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'S a, raw T choices, int32 n_channel, int32 n',
 *     'T y',
 */
  __pyx_tuple__305 = PyTuple_Pack(4, __pyx_kp_s_S_a_raw_T_choices_int32_n_channe_2, __pyx_kp_s_T_y, __pyx_kp_s_S_x_a_if_a_0_x_0_else_if_a_n_x, __pyx_n_s_cupy_choose_clip); if (unlikely(!__pyx_tuple__305)) __PYX_ERR(0, 2954, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__305);
  __Pyx_GIVEREF(__pyx_tuple__305);

  /* "cupy/core/core.pyx":2969
 * 
 * 
 * cdef _scatter_update_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'T v, S indices, int32 cdim, int32 rdim, int32 adim',
 *     'raw T a',
 */
  __pyx_tuple__306 = PyTuple_Pack(4, __pyx_kp_s_T_v_S_indices_int32_cdim_int32_r, __pyx_kp_s_raw_T_a, __pyx_kp_s_S_wrap_indices_indices_adim_if, __pyx_n_s_cupy_scatter_update); if (unlikely(!__pyx_tuple__306)) __PYX_ERR(0, 2969, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__306);
  __Pyx_GIVEREF(__pyx_tuple__306);

  /* "cupy/core/core.pyx":2982
 * 
 * 
 * cdef _scatter_add_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T v, S indices, int32 cdim, int32 rdim, int32 adim',
 *     'raw T a',
 */
  __pyx_tuple__307 = PyTuple_Pack(4, __pyx_kp_s_raw_T_v_S_indices_int32_cdim_int, __pyx_kp_s_raw_T_a, __pyx_kp_s_S_wrap_indices_indices_adim_if_2, __pyx_n_s_cupy_scatter_add); if (unlikely(!__pyx_tuple__307)) __PYX_ERR(0, 2982, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__307);
  __Pyx_GIVEREF(__pyx_tuple__307);

  /* "cupy/core/core.pyx":2995
 * 
 * 
 * cdef _scatter_update_mask_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T v, bool mask, S mask_scanned',
 *     'T a',
 */
  __pyx_tuple__308 = PyTuple_Pack(4, __pyx_kp_s_raw_T_v_bool_mask_S_mask_scanned, __pyx_kp_s_T_a, __pyx_kp_s_if_mask_a_v_mask_scanned_1, __pyx_n_s_cupy_scatter_update_mask); if (unlikely(!__pyx_tuple__308)) __PYX_ERR(0, 2995, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__308);
  __Pyx_GIVEREF(__pyx_tuple__308);

  /* "cupy/core/core.pyx":3002
 * 
 * 
 * cdef _scatter_add_mask_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T v, bool mask, S mask_scanned',
 *     'T a',
 */
  __pyx_tuple__309 = PyTuple_Pack(4, __pyx_kp_s_raw_T_v_bool_mask_S_mask_scanned, __pyx_kp_s_T_a, __pyx_kp_s_if_mask_a_a_v_mask_scanned_1, __pyx_n_s_cupy_scatter_add_mask); if (unlikely(!__pyx_tuple__309)) __PYX_ERR(0, 3002, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__309);
  __Pyx_GIVEREF(__pyx_tuple__309);

  /* "cupy/core/core.pyx":3009
 * 
 * 
 * cdef _getitem_mask_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'T a, bool mask, S mask_scanned',
 *     'raw T out',
 */
  __pyx_tuple__310 = PyTuple_Pack(4, __pyx_kp_s_T_a_bool_mask_S_mask_scanned, __pyx_kp_s_raw_T_out, __pyx_kp_s_if_mask_out_mask_scanned_1_a, __pyx_n_s_cupy_getitem_mask); if (unlikely(!__pyx_tuple__310)) __PYX_ERR(0, 3009, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__310);
  __Pyx_GIVEREF(__pyx_tuple__310);

  /* "cupy/core/core.pyx":3770
 * 
 * cdef _cuda_runtime_version = None
 * cdef _tensordot_core_mul_sum = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T y', 'U out',
 *     'static_cast<U>(x) * static_cast<U>(y)',
 */
  __pyx_tuple__311 = PyTuple_Pack(7, __pyx_kp_s_S_x_T_y, __pyx_kp_s_U_out, __pyx_kp_s_static_cast_U_x_static_cast_U_y, __pyx_kp_s_a_b, __pyx_kp_s_out_a, __pyx_kp_s_0, __pyx_n_s_tensordot_core_mul_sum); if (unlikely(!__pyx_tuple__311)) __PYX_ERR(0, 3770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__311);
  __Pyx_GIVEREF(__pyx_tuple__311);

  /* "cupy/core/core.pyx":3996
 * _all = create_reduction_func(
 *     'cupy_all',
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',             # <<<<<<<<<<<<<<
 *      'q->?', 'Q->?', 'e->?', 'f->?', 'd->?', 'F->?', 'D->?'),
 *     ('in0 != type_in0_raw(0)', 'a & b', 'out0 = a', 'bool'),
 */
  __pyx_tuple__318 = PyTuple_Pack(15, __pyx_kp_s__247, __pyx_kp_s_B, __pyx_kp_s_h, __pyx_kp_s_H, __pyx_kp_s_i_2, __pyx_kp_s_I_2, __pyx_kp_s_l, __pyx_kp_s_L, __pyx_kp_s_q_2, __pyx_kp_s_Q, __pyx_kp_s_e_2, __pyx_kp_s_f_2, __pyx_kp_s_d_2, __pyx_kp_s_F_2, __pyx_kp_s_D_2); if (unlikely(!__pyx_tuple__318)) __PYX_ERR(0, 3996, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__318);
  __Pyx_GIVEREF(__pyx_tuple__318);

  /* "cupy/core/core.pyx":3998
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 *      'q->?', 'Q->?', 'e->?', 'f->?', 'd->?', 'F->?', 'D->?'),
 *     ('in0 != type_in0_raw(0)', 'a & b', 'out0 = a', 'bool'),             # <<<<<<<<<<<<<<
 *     'true', '')
 * 
 */
  __pyx_tuple__319 = PyTuple_Pack(4, __pyx_kp_s_in0_type_in0_raw_0, __pyx_kp_s_a_b_2, __pyx_kp_s_out0_a, __pyx_n_s_bool_2); if (unlikely(!__pyx_tuple__319)) __PYX_ERR(0, 3998, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__319);
  __Pyx_GIVEREF(__pyx_tuple__319);

  /* "cupy/core/core.pyx":4004
 * _any = create_reduction_func(
 *     'cupy_any',
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',             # <<<<<<<<<<<<<<
 *      'q->?', 'Q->?', 'e->?', 'f->?', 'd->?', 'F->?', 'D->?'),
 *     ('in0 != type_in0_raw(0)', 'a | b', 'out0 = a', 'bool'),
 */
  __pyx_tuple__320 = PyTuple_Pack(15, __pyx_kp_s__247, __pyx_kp_s_B, __pyx_kp_s_h, __pyx_kp_s_H, __pyx_kp_s_i_2, __pyx_kp_s_I_2, __pyx_kp_s_l, __pyx_kp_s_L, __pyx_kp_s_q_2, __pyx_kp_s_Q, __pyx_kp_s_e_2, __pyx_kp_s_f_2, __pyx_kp_s_d_2, __pyx_kp_s_F_2, __pyx_kp_s_D_2); if (unlikely(!__pyx_tuple__320)) __PYX_ERR(0, 4004, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__320);
  __Pyx_GIVEREF(__pyx_tuple__320);

  /* "cupy/core/core.pyx":4006
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 *      'q->?', 'Q->?', 'e->?', 'f->?', 'd->?', 'F->?', 'D->?'),
 *     ('in0 != type_in0_raw(0)', 'a | b', 'out0 = a', 'bool'),             # <<<<<<<<<<<<<<
 *     'false', '')
 * 
 */
  __pyx_tuple__321 = PyTuple_Pack(4, __pyx_kp_s_in0_type_in0_raw_0, __pyx_kp_s_a_b_3, __pyx_kp_s_out0_a, __pyx_n_s_bool_2); if (unlikely(!__pyx_tuple__321)) __PYX_ERR(0, 4006, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__321);
  __Pyx_GIVEREF(__pyx_tuple__321);

  /* "cupy/core/core.pyx":4018
 *     ('?->l', 'b->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, None, None, 'float')),             # <<<<<<<<<<<<<<
 *      'f->f', 'd->d', 'F->F', 'D->D'),
 *     ('in0', 'a + b', 'out0 = type_out0_raw(a)', None), 0)
 */
  __pyx_tuple__322 = PyTuple_Pack(4, Py_None, Py_None, Py_None, __pyx_n_s_float); if (unlikely(!__pyx_tuple__322)) __PYX_ERR(0, 4018, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__322);
  __Pyx_GIVEREF(__pyx_tuple__322);
  __pyx_tuple__323 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__322); if (unlikely(!__pyx_tuple__323)) __PYX_ERR(0, 4018, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__323);
  __Pyx_GIVEREF(__pyx_tuple__323);

  /* "cupy/core/core.pyx":4016
 * _sum_auto_dtype = create_reduction_func(
 *     'cupy_sum',
 *     ('?->l', 'b->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, None, None, 'float')),
 */
  __pyx_tuple__324 = PyTuple_Pack(16, __pyx_kp_s_l_2, __pyx_kp_s_b_l, __pyx_kp_s_B_L, __pyx_kp_s_h_l, __pyx_kp_s_H_L, __pyx_kp_s_i_l, __pyx_kp_s_I_L, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_tuple__323, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_kp_s_F_F, __pyx_kp_s_D_D); if (unlikely(!__pyx_tuple__324)) __PYX_ERR(0, 4016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__324);
  __Pyx_GIVEREF(__pyx_tuple__324);

  /* "cupy/core/core.pyx":4020
 *      ('e->e', (None, None, None, 'float')),
 *      'f->f', 'd->d', 'F->F', 'D->D'),
 *     ('in0', 'a + b', 'out0 = type_out0_raw(a)', None), 0)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__325 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b, __pyx_kp_s_out0_type_out0_raw_a, Py_None); if (unlikely(!__pyx_tuple__325)) __PYX_ERR(0, 4020, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__325);
  __Pyx_GIVEREF(__pyx_tuple__325);

  /* "cupy/core/core.pyx":4027
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, None, None, 'float')),             # <<<<<<<<<<<<<<
 *      'f->f', 'd->d', 'F->F', 'D->D'),
 *     ('in0', 'a + b', 'out0 = type_out0_raw(a)', None), 0)
 */
  __pyx_tuple__326 = PyTuple_Pack(4, Py_None, Py_None, Py_None, __pyx_n_s_float); if (unlikely(!__pyx_tuple__326)) __PYX_ERR(0, 4027, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__326);
  __Pyx_GIVEREF(__pyx_tuple__326);
  __pyx_tuple__327 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__326); if (unlikely(!__pyx_tuple__327)) __PYX_ERR(0, 4027, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__327);
  __Pyx_GIVEREF(__pyx_tuple__327);

  /* "cupy/core/core.pyx":4025
 * _sum_keep_dtype = create_reduction_func(
 *     'cupy_sum_with_dtype',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, None, None, 'float')),
 */
  __pyx_tuple__328 = PyTuple_Pack(16, __pyx_kp_s__247, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_tuple__327, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_kp_s_F_F, __pyx_kp_s_D_D); if (unlikely(!__pyx_tuple__328)) __PYX_ERR(0, 4025, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__328);
  __Pyx_GIVEREF(__pyx_tuple__328);

  /* "cupy/core/core.pyx":4029
 *      ('e->e', (None, None, None, 'float')),
 *      'f->f', 'd->d', 'F->F', 'D->D'),
 *     ('in0', 'a + b', 'out0 = type_out0_raw(a)', None), 0)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__329 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b, __pyx_kp_s_out0_type_out0_raw_a, Py_None); if (unlikely(!__pyx_tuple__329)) __PYX_ERR(0, 4029, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__329);
  __Pyx_GIVEREF(__pyx_tuple__329);

  /* "cupy/core/core.pyx":4036
 *     ('?->l', 'b->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, None, None, 'float')),             # <<<<<<<<<<<<<<
 *      'f->f', 'd->d', 'F->F', 'D->D'),
 *     ('in0', 'a * b', 'out0 = type_out0_raw(a)', None), 1)
 */
  __pyx_tuple__330 = PyTuple_Pack(4, Py_None, Py_None, Py_None, __pyx_n_s_float); if (unlikely(!__pyx_tuple__330)) __PYX_ERR(0, 4036, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__330);
  __Pyx_GIVEREF(__pyx_tuple__330);
  __pyx_tuple__331 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__330); if (unlikely(!__pyx_tuple__331)) __PYX_ERR(0, 4036, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__331);
  __Pyx_GIVEREF(__pyx_tuple__331);

  /* "cupy/core/core.pyx":4034
 * _prod_auto_dtype = create_reduction_func(
 *     'cupy_prod',
 *     ('?->l', 'b->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, None, None, 'float')),
 */
  __pyx_tuple__332 = PyTuple_Pack(16, __pyx_kp_s_l_2, __pyx_kp_s_b_l, __pyx_kp_s_B_L, __pyx_kp_s_h_l, __pyx_kp_s_H_L, __pyx_kp_s_i_l, __pyx_kp_s_I_L, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_tuple__331, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_kp_s_F_F, __pyx_kp_s_D_D); if (unlikely(!__pyx_tuple__332)) __PYX_ERR(0, 4034, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__332);
  __Pyx_GIVEREF(__pyx_tuple__332);

  /* "cupy/core/core.pyx":4038
 *      ('e->e', (None, None, None, 'float')),
 *      'f->f', 'd->d', 'F->F', 'D->D'),
 *     ('in0', 'a * b', 'out0 = type_out0_raw(a)', None), 1)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__333 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b_4, __pyx_kp_s_out0_type_out0_raw_a, Py_None); if (unlikely(!__pyx_tuple__333)) __PYX_ERR(0, 4038, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__333);
  __Pyx_GIVEREF(__pyx_tuple__333);

  /* "cupy/core/core.pyx":4045
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, None, None, 'float')),             # <<<<<<<<<<<<<<
 *      'f->f', 'd->d', 'F->F', 'D->D'),
 *     ('in0', 'a * b', 'out0 = type_out0_raw(a)', None), 1)
 */
  __pyx_tuple__334 = PyTuple_Pack(4, Py_None, Py_None, Py_None, __pyx_n_s_float); if (unlikely(!__pyx_tuple__334)) __PYX_ERR(0, 4045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__334);
  __Pyx_GIVEREF(__pyx_tuple__334);
  __pyx_tuple__335 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__334); if (unlikely(!__pyx_tuple__335)) __PYX_ERR(0, 4045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__335);
  __Pyx_GIVEREF(__pyx_tuple__335);

  /* "cupy/core/core.pyx":4043
 * _prod_keep_dtype = create_reduction_func(
 *     'cupy_prod_with_dtype',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q',
 *      ('e->e', (None, None, None, 'float')),
 */
  __pyx_tuple__336 = PyTuple_Pack(16, __pyx_kp_s__247, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_tuple__335, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_kp_s_F_F, __pyx_kp_s_D_D); if (unlikely(!__pyx_tuple__336)) __PYX_ERR(0, 4043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__336);
  __Pyx_GIVEREF(__pyx_tuple__336);

  /* "cupy/core/core.pyx":4047
 *      ('e->e', (None, None, None, 'float')),
 *      'f->f', 'd->d', 'F->F', 'D->D'),
 *     ('in0', 'a * b', 'out0 = type_out0_raw(a)', None), 1)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__337 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b_4, __pyx_kp_s_out0_type_out0_raw_a, Py_None); if (unlikely(!__pyx_tuple__337)) __PYX_ERR(0, 4047, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__337);
  __Pyx_GIVEREF(__pyx_tuple__337);

  /* "cupy/core/core.pyx":4074
 *     ('b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L', 'q->q',
 *      'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->F', 'out0 = conj(in0)'),             # <<<<<<<<<<<<<<
 *      ('D->D', 'out0 = conj(in0)')),
 *     'out0 = in0',
 */
  __pyx_tuple__339 = PyTuple_Pack(2, __pyx_kp_s_F_F, __pyx_kp_s_out0_conj_in0); if (unlikely(!__pyx_tuple__339)) __PYX_ERR(0, 4074, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__339);
  __Pyx_GIVEREF(__pyx_tuple__339);

  /* "cupy/core/core.pyx":4075
 *      'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->F', 'out0 = conj(in0)'),
 *      ('D->D', 'out0 = conj(in0)')),             # <<<<<<<<<<<<<<
 *     'out0 = in0',
 *     doc='''Returns the complex conjugate, element-wise.
 */
  __pyx_tuple__340 = PyTuple_Pack(2, __pyx_kp_s_D_D, __pyx_kp_s_out0_conj_in0); if (unlikely(!__pyx_tuple__340)) __PYX_ERR(0, 4075, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__340);
  __Pyx_GIVEREF(__pyx_tuple__340);

  /* "cupy/core/core.pyx":4072
 * conj = create_ufunc(
 *     'cupy_conj',
 *     ('b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L', 'q->q',             # <<<<<<<<<<<<<<
 *      'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->F', 'out0 = conj(in0)'),
 */
  __pyx_tuple__341 = PyTuple_Pack(15, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_tuple__339, __pyx_tuple__340); if (unlikely(!__pyx_tuple__341)) __PYX_ERR(0, 4072, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__341);
  __Pyx_GIVEREF(__pyx_tuple__341);

  /* "cupy/core/core.pyx":4070
 * 
 * 
 * conj = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_conj',
 *     ('b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L', 'q->q',
 */
  __pyx_tuple__342 = PyTuple_Pack(3, __pyx_n_s_cupy_conj, __pyx_tuple__341, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__342)) __PYX_ERR(0, 4070, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__342);
  __Pyx_GIVEREF(__pyx_tuple__342);

  /* "cupy/core/core.pyx":4087
 *     'cupy_angle',
 *     ('?->d', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = arg(in0)'),             # <<<<<<<<<<<<<<
 *      ('D->d', 'out0 = arg(in0)')),
 *     'out0 = in0 >= 0 ? 0 : M_PI',
 */
  __pyx_tuple__343 = PyTuple_Pack(2, __pyx_kp_s_F_f, __pyx_kp_s_out0_arg_in0); if (unlikely(!__pyx_tuple__343)) __PYX_ERR(0, 4087, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__343);
  __Pyx_GIVEREF(__pyx_tuple__343);

  /* "cupy/core/core.pyx":4088
 *     ('?->d', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = arg(in0)'),
 *      ('D->d', 'out0 = arg(in0)')),             # <<<<<<<<<<<<<<
 *     'out0 = in0 >= 0 ? 0 : M_PI',
 *     doc='''Returns the angle of the complex argument.
 */
  __pyx_tuple__344 = PyTuple_Pack(2, __pyx_kp_s_D_d, __pyx_kp_s_out0_arg_in0); if (unlikely(!__pyx_tuple__344)) __PYX_ERR(0, 4088, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__344);
  __Pyx_GIVEREF(__pyx_tuple__344);

  /* "cupy/core/core.pyx":4086
 * angle = create_ufunc(
 *     'cupy_angle',
 *     ('?->d', 'e->e', 'f->f', 'd->d',             # <<<<<<<<<<<<<<
 *      ('F->f', 'out0 = arg(in0)'),
 *      ('D->d', 'out0 = arg(in0)')),
 */
  __pyx_tuple__345 = PyTuple_Pack(6, __pyx_kp_s_d_3, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_tuple__343, __pyx_tuple__344); if (unlikely(!__pyx_tuple__345)) __PYX_ERR(0, 4086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__345);
  __Pyx_GIVEREF(__pyx_tuple__345);

  /* "cupy/core/core.pyx":4084
 * 
 * 
 * angle = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_angle',
 *     ('?->d', 'e->e', 'f->f', 'd->d',
 */
  __pyx_tuple__346 = PyTuple_Pack(3, __pyx_n_s_cupy_angle, __pyx_tuple__345, __pyx_kp_s_out0_in0_0_0_M_PI); if (unlikely(!__pyx_tuple__346)) __PYX_ERR(0, 4084, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__346);
  __Pyx_GIVEREF(__pyx_tuple__346);

  /* "cupy/core/core.pyx":4101
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = in0.real()'),             # <<<<<<<<<<<<<<
 *      ('D->d', 'out0 = in0.real()')),
 *     'out0 = in0',
 */
  __pyx_tuple__347 = PyTuple_Pack(2, __pyx_kp_s_F_f, __pyx_kp_s_out0_in0_real); if (unlikely(!__pyx_tuple__347)) __PYX_ERR(0, 4101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__347);
  __Pyx_GIVEREF(__pyx_tuple__347);

  /* "cupy/core/core.pyx":4102
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = in0.real()'),
 *      ('D->d', 'out0 = in0.real()')),             # <<<<<<<<<<<<<<
 *     'out0 = in0',
 *     doc='''Returns the real part of the elements of the array.
 */
  __pyx_tuple__348 = PyTuple_Pack(2, __pyx_kp_s_D_d, __pyx_kp_s_out0_in0_real); if (unlikely(!__pyx_tuple__348)) __PYX_ERR(0, 4102, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__348);
  __Pyx_GIVEREF(__pyx_tuple__348);

  /* "cupy/core/core.pyx":4099
 * real = create_ufunc(
 *     'cupy_real',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = in0.real()'),
 */
  __pyx_tuple__349 = PyTuple_Pack(16, __pyx_kp_s__247, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_tuple__347, __pyx_tuple__348); if (unlikely(!__pyx_tuple__349)) __PYX_ERR(0, 4099, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__349);
  __Pyx_GIVEREF(__pyx_tuple__349);

  /* "cupy/core/core.pyx":4097
 * 
 * 
 * real = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_real',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_tuple__350 = PyTuple_Pack(3, __pyx_n_s_cupy_real, __pyx_tuple__349, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__350)) __PYX_ERR(0, 4097, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__350);
  __Pyx_GIVEREF(__pyx_tuple__350);

  /* "cupy/core/core.pyx":4112
 * _real_setter = create_ufunc(
 *     'cupy_real_setter',
 *     ('f->F', 'd->D'),             # <<<<<<<<<<<<<<
 *     'out0.real(in0)',
 *     doc='''Sets the real part of the elements of the array.
 */
  __pyx_tuple__351 = PyTuple_Pack(2, __pyx_kp_s_f_F, __pyx_kp_s_d_D); if (unlikely(!__pyx_tuple__351)) __PYX_ERR(0, 4112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__351);
  __Pyx_GIVEREF(__pyx_tuple__351);

  /* "cupy/core/core.pyx":4110
 *     ''')
 * 
 * _real_setter = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_real_setter',
 *     ('f->F', 'd->D'),
 */
  __pyx_tuple__352 = PyTuple_Pack(3, __pyx_n_s_cupy_real_setter, __pyx_tuple__351, __pyx_kp_s_out0_real_in0); if (unlikely(!__pyx_tuple__352)) __PYX_ERR(0, 4110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__352);
  __Pyx_GIVEREF(__pyx_tuple__352);

  /* "cupy/core/core.pyx":4122
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = in0.imag()'),             # <<<<<<<<<<<<<<
 *      ('D->d', 'out0 = in0.imag()')),
 *     'out0 = 0',
 */
  __pyx_tuple__353 = PyTuple_Pack(2, __pyx_kp_s_F_f, __pyx_kp_s_out0_in0_imag); if (unlikely(!__pyx_tuple__353)) __PYX_ERR(0, 4122, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__353);
  __Pyx_GIVEREF(__pyx_tuple__353);

  /* "cupy/core/core.pyx":4123
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = in0.imag()'),
 *      ('D->d', 'out0 = in0.imag()')),             # <<<<<<<<<<<<<<
 *     'out0 = 0',
 *     doc='''Returns the imaginary part of the elements of the array.
 */
  __pyx_tuple__354 = PyTuple_Pack(2, __pyx_kp_s_D_d, __pyx_kp_s_out0_in0_imag); if (unlikely(!__pyx_tuple__354)) __PYX_ERR(0, 4123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__354);
  __Pyx_GIVEREF(__pyx_tuple__354);

  /* "cupy/core/core.pyx":4120
 * imag = create_ufunc(
 *     'cupy_imag',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',             # <<<<<<<<<<<<<<
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d',
 *      ('F->f', 'out0 = in0.imag()'),
 */
  __pyx_tuple__355 = PyTuple_Pack(16, __pyx_kp_s__247, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_tuple__353, __pyx_tuple__354); if (unlikely(!__pyx_tuple__355)) __PYX_ERR(0, 4120, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__355);
  __Pyx_GIVEREF(__pyx_tuple__355);

  /* "cupy/core/core.pyx":4118
 * 
 * 
 * imag = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_imag',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_tuple__356 = PyTuple_Pack(3, __pyx_n_s_cupy_imag, __pyx_tuple__355, __pyx_kp_s_out0_0); if (unlikely(!__pyx_tuple__356)) __PYX_ERR(0, 4118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__356);
  __Pyx_GIVEREF(__pyx_tuple__356);

  /* "cupy/core/core.pyx":4134
 * _imag_setter = create_ufunc(
 *     'cupy_imag_setter',
 *     ('f->F', 'd->D'),             # <<<<<<<<<<<<<<
 *     'out0.imag(in0)',
 *     doc='''Sets the imaginary part of the elements of the array.
 */
  __pyx_tuple__357 = PyTuple_Pack(2, __pyx_kp_s_f_F, __pyx_kp_s_d_D); if (unlikely(!__pyx_tuple__357)) __PYX_ERR(0, 4134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__357);
  __Pyx_GIVEREF(__pyx_tuple__357);

  /* "cupy/core/core.pyx":4132
 * 
 * 
 * _imag_setter = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_imag_setter',
 *     ('f->F', 'd->D'),
 */
  __pyx_tuple__358 = PyTuple_Pack(3, __pyx_n_s_cupy_imag_setter, __pyx_tuple__357, __pyx_kp_s_out0_imag_in0); if (unlikely(!__pyx_tuple__358)) __PYX_ERR(0, 4132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__358);
  __Pyx_GIVEREF(__pyx_tuple__358);

  /* "cupy/core/core.pyx":4142
 * negative = create_ufunc(
 *     'cupy_negative',
 *     (('?->?', 'out0 = !in0'),             # <<<<<<<<<<<<<<
 *      'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d', 'F->F', 'D->D'),
 */
  __pyx_tuple__359 = PyTuple_Pack(2, __pyx_kp_s__247, __pyx_kp_s_out0_in0_2); if (unlikely(!__pyx_tuple__359)) __PYX_ERR(0, 4142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__359);
  __Pyx_GIVEREF(__pyx_tuple__359);
  __pyx_tuple__360 = PyTuple_Pack(16, __pyx_tuple__359, __pyx_kp_s_b_b, __pyx_kp_s_B_B, __pyx_kp_s_h_h, __pyx_kp_s_H_H, __pyx_kp_s_i_i, __pyx_kp_s_I_I, __pyx_kp_s_l_l, __pyx_kp_s_L_L, __pyx_kp_s_q_q, __pyx_kp_s_Q_Q, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_kp_s_F_F, __pyx_kp_s_D_D); if (unlikely(!__pyx_tuple__360)) __PYX_ERR(0, 4142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__360);
  __Pyx_GIVEREF(__pyx_tuple__360);

  /* "cupy/core/core.pyx":4140
 * 
 * 
 * negative = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_negative',
 *     (('?->?', 'out0 = !in0'),
 */
  __pyx_tuple__361 = PyTuple_Pack(3, __pyx_n_s_cupy_negative, __pyx_tuple__360, __pyx_kp_s_out0_in0_4); if (unlikely(!__pyx_tuple__361)) __PYX_ERR(0, 4140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__361);
  __Pyx_GIVEREF(__pyx_tuple__361);

  /* "cupy/core/core.pyx":4166
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = in0 / in1'),             # <<<<<<<<<<<<<<
 *      ('ff->f', 'out0 = in0 / in1'),
 *      ('dd->d', 'out0 = in0 / in1'),
 */
  __pyx_tuple__363 = PyTuple_Pack(2, __pyx_kp_s_ee_e, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__363)) __PYX_ERR(0, 4166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__363);
  __Pyx_GIVEREF(__pyx_tuple__363);

  /* "cupy/core/core.pyx":4167
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = in0 / in1'),
 *      ('ff->f', 'out0 = in0 / in1'),             # <<<<<<<<<<<<<<
 *      ('dd->d', 'out0 = in0 / in1'),
 *      ('FF->F', 'out0 = in0 / in1'),
 */
  __pyx_tuple__364 = PyTuple_Pack(2, __pyx_kp_s_ff_f, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__364)) __PYX_ERR(0, 4167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__364);
  __Pyx_GIVEREF(__pyx_tuple__364);

  /* "cupy/core/core.pyx":4168
 *      ('ee->e', 'out0 = in0 / in1'),
 *      ('ff->f', 'out0 = in0 / in1'),
 *      ('dd->d', 'out0 = in0 / in1'),             # <<<<<<<<<<<<<<
 *      ('FF->F', 'out0 = in0 / in1'),
 *      ('DD->D', 'out0 = in0 / in1')),
 */
  __pyx_tuple__365 = PyTuple_Pack(2, __pyx_kp_s_dd_d, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__365)) __PYX_ERR(0, 4168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__365);
  __Pyx_GIVEREF(__pyx_tuple__365);

  /* "cupy/core/core.pyx":4169
 *      ('ff->f', 'out0 = in0 / in1'),
 *      ('dd->d', 'out0 = in0 / in1'),
 *      ('FF->F', 'out0 = in0 / in1'),             # <<<<<<<<<<<<<<
 *      ('DD->D', 'out0 = in0 / in1')),
 *     'out0 = in1 == 0 ? 0 : floor((double)in0 / (double)in1)',
 */
  __pyx_tuple__366 = PyTuple_Pack(2, __pyx_kp_s_FF_F, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__366)) __PYX_ERR(0, 4169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__366);
  __Pyx_GIVEREF(__pyx_tuple__366);

  /* "cupy/core/core.pyx":4170
 *      ('dd->d', 'out0 = in0 / in1'),
 *      ('FF->F', 'out0 = in0 / in1'),
 *      ('DD->D', 'out0 = in0 / in1')),             # <<<<<<<<<<<<<<
 *     'out0 = in1 == 0 ? 0 : floor((double)in0 / (double)in1)',
 *     doc='''Divides arguments elementwise.
 */
  __pyx_tuple__367 = PyTuple_Pack(2, __pyx_kp_s_DD_D, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__367)) __PYX_ERR(0, 4170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__367);
  __Pyx_GIVEREF(__pyx_tuple__367);

  /* "cupy/core/core.pyx":4164
 * divide = create_ufunc(
 *     'cupy_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',             # <<<<<<<<<<<<<<
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = in0 / in1'),
 */
  __pyx_tuple__368 = PyTuple_Pack(15, __pyx_kp_s_bb_b, __pyx_kp_s_BB_B, __pyx_kp_s_hh_h, __pyx_kp_s_HH_H, __pyx_kp_s_ii_i, __pyx_kp_s_II_I, __pyx_kp_s_ll_l, __pyx_kp_s_LL_L, __pyx_kp_s_qq_q, __pyx_kp_s_QQ_Q, __pyx_tuple__363, __pyx_tuple__364, __pyx_tuple__365, __pyx_tuple__366, __pyx_tuple__367); if (unlikely(!__pyx_tuple__368)) __PYX_ERR(0, 4164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__368);
  __Pyx_GIVEREF(__pyx_tuple__368);

  /* "cupy/core/core.pyx":4162
 * 
 * 
 * divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_tuple__369 = PyTuple_Pack(3, __pyx_n_s_cupy_divide, __pyx_tuple__368, __pyx_kp_s_out0_in1_0_0_floor_double_in0_do); if (unlikely(!__pyx_tuple__369)) __PYX_ERR(0, 4162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__369);
  __Pyx_GIVEREF(__pyx_tuple__369);

  /* "cupy/core/core.pyx":4183
 *     ('??->b', 'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 *      'LL->L', 'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = powf(in0, in1)'),             # <<<<<<<<<<<<<<
 *      ('ff->f', 'out0 = powf(in0, in1)'),
 *      ('dd->d', 'out0 = pow(in0, in1)'),
 */
  __pyx_tuple__370 = PyTuple_Pack(2, __pyx_kp_s_ee_e, __pyx_kp_s_out0_powf_in0_in1); if (unlikely(!__pyx_tuple__370)) __PYX_ERR(0, 4183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__370);
  __Pyx_GIVEREF(__pyx_tuple__370);

  /* "cupy/core/core.pyx":4184
 *      'LL->L', 'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = powf(in0, in1)'),
 *      ('ff->f', 'out0 = powf(in0, in1)'),             # <<<<<<<<<<<<<<
 *      ('dd->d', 'out0 = pow(in0, in1)'),
 *      ('FF->F', 'out0 = pow(in0, in1)'),
 */
  __pyx_tuple__371 = PyTuple_Pack(2, __pyx_kp_s_ff_f, __pyx_kp_s_out0_powf_in0_in1); if (unlikely(!__pyx_tuple__371)) __PYX_ERR(0, 4184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__371);
  __Pyx_GIVEREF(__pyx_tuple__371);

  /* "cupy/core/core.pyx":4185
 *      ('ee->e', 'out0 = powf(in0, in1)'),
 *      ('ff->f', 'out0 = powf(in0, in1)'),
 *      ('dd->d', 'out0 = pow(in0, in1)'),             # <<<<<<<<<<<<<<
 *      ('FF->F', 'out0 = pow(in0, in1)'),
 *      ('DD->D', 'out0 = pow(in0, in1)')),
 */
  __pyx_tuple__372 = PyTuple_Pack(2, __pyx_kp_s_dd_d, __pyx_kp_s_out0_pow_in0_in1); if (unlikely(!__pyx_tuple__372)) __PYX_ERR(0, 4185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__372);
  __Pyx_GIVEREF(__pyx_tuple__372);

  /* "cupy/core/core.pyx":4186
 *      ('ff->f', 'out0 = powf(in0, in1)'),
 *      ('dd->d', 'out0 = pow(in0, in1)'),
 *      ('FF->F', 'out0 = pow(in0, in1)'),             # <<<<<<<<<<<<<<
 *      ('DD->D', 'out0 = pow(in0, in1)')),
 *     'out0 = rint(pow((double)in0, (double)in1))',
 */
  __pyx_tuple__373 = PyTuple_Pack(2, __pyx_kp_s_FF_F, __pyx_kp_s_out0_pow_in0_in1); if (unlikely(!__pyx_tuple__373)) __PYX_ERR(0, 4186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__373);
  __Pyx_GIVEREF(__pyx_tuple__373);

  /* "cupy/core/core.pyx":4187
 *      ('dd->d', 'out0 = pow(in0, in1)'),
 *      ('FF->F', 'out0 = pow(in0, in1)'),
 *      ('DD->D', 'out0 = pow(in0, in1)')),             # <<<<<<<<<<<<<<
 *     'out0 = rint(pow((double)in0, (double)in1))',
 *     doc='''Computes ``x1 ** x2`` elementwise.
 */
  __pyx_tuple__374 = PyTuple_Pack(2, __pyx_kp_s_DD_D, __pyx_kp_s_out0_pow_in0_in1); if (unlikely(!__pyx_tuple__374)) __PYX_ERR(0, 4187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__374);
  __Pyx_GIVEREF(__pyx_tuple__374);

  /* "cupy/core/core.pyx":4181
 * power = create_ufunc(
 *     'cupy_power',
 *     ('??->b', 'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',             # <<<<<<<<<<<<<<
 *      'LL->L', 'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = powf(in0, in1)'),
 */
  __pyx_tuple__375 = PyTuple_Pack(16, __pyx_kp_s_b_2, __pyx_kp_s_bb_b, __pyx_kp_s_BB_B, __pyx_kp_s_hh_h, __pyx_kp_s_HH_H, __pyx_kp_s_ii_i, __pyx_kp_s_II_I, __pyx_kp_s_ll_l, __pyx_kp_s_LL_L, __pyx_kp_s_qq_q, __pyx_kp_s_QQ_Q, __pyx_tuple__370, __pyx_tuple__371, __pyx_tuple__372, __pyx_tuple__373, __pyx_tuple__374); if (unlikely(!__pyx_tuple__375)) __PYX_ERR(0, 4181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__375);
  __Pyx_GIVEREF(__pyx_tuple__375);

  /* "cupy/core/core.pyx":4179
 * 
 * 
 * power = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_power',
 *     ('??->b', 'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 */
  __pyx_tuple__376 = PyTuple_Pack(3, __pyx_n_s_cupy_power, __pyx_tuple__375, __pyx_kp_s_out0_rint_pow_double_in0_double); if (unlikely(!__pyx_tuple__376)) __PYX_ERR(0, 4179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__376);
  __Pyx_GIVEREF(__pyx_tuple__376);

  /* "cupy/core/core.pyx":4207
 * true_divide = create_ufunc(
 *     'cupy_true_divide',
 *     ('bb->d', 'BB->d', 'hh->d', 'HH->d', 'ii->d', 'II->d', 'll->d', 'LL->d',             # <<<<<<<<<<<<<<
 *      'qq->d', 'QQ->d', 'ee->e', 'ff->f', 'dd->d', 'FF->F', 'DD->D'),
 *     'out0 = (out0_type)in0 / (out0_type)in1',
 */
  __pyx_tuple__378 = PyTuple_Pack(15, __pyx_kp_s_bb_d, __pyx_kp_s_BB_d, __pyx_kp_s_hh_d, __pyx_kp_s_HH_d, __pyx_kp_s_ii_d, __pyx_kp_s_II_d, __pyx_kp_s_ll_d, __pyx_kp_s_LL_d, __pyx_kp_s_qq_d, __pyx_kp_s_QQ_d, __pyx_kp_s_ee_e, __pyx_kp_s_ff_f, __pyx_kp_s_dd_d, __pyx_kp_s_FF_F, __pyx_kp_s_DD_D); if (unlikely(!__pyx_tuple__378)) __PYX_ERR(0, 4207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__378);
  __Pyx_GIVEREF(__pyx_tuple__378);

  /* "cupy/core/core.pyx":4205
 * 
 * 
 * true_divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_true_divide',
 *     ('bb->d', 'BB->d', 'hh->d', 'HH->d', 'ii->d', 'II->d', 'll->d', 'LL->d',
 */
  __pyx_tuple__379 = PyTuple_Pack(3, __pyx_n_s_cupy_true_divide, __pyx_tuple__378, __pyx_kp_s_out0_out0_type_in0_out0_type_in1); if (unlikely(!__pyx_tuple__379)) __PYX_ERR(0, 4205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__379);
  __Pyx_GIVEREF(__pyx_tuple__379);

  /* "cupy/core/core.pyx":4223
 * floor_divide = create_ufunc(
 *     'cupy_floor_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',             # <<<<<<<<<<<<<<
 *      'qq->q', 'QQ->Q', 'ee->e', 'ff->f', 'dd->d'),
 *     'out0 = _floor_divide(in0, in1)',
 */
  __pyx_tuple__380 = PyTuple_Pack(13, __pyx_kp_s_bb_b, __pyx_kp_s_BB_B, __pyx_kp_s_hh_h, __pyx_kp_s_HH_H, __pyx_kp_s_ii_i, __pyx_kp_s_II_I, __pyx_kp_s_ll_l, __pyx_kp_s_LL_L, __pyx_kp_s_qq_q, __pyx_kp_s_QQ_Q, __pyx_kp_s_ee_e, __pyx_kp_s_ff_f, __pyx_kp_s_dd_d); if (unlikely(!__pyx_tuple__380)) __PYX_ERR(0, 4223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__380);
  __Pyx_GIVEREF(__pyx_tuple__380);

  /* "cupy/core/core.pyx":4221
 * 
 * 
 * floor_divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_floor_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_tuple__381 = PyTuple_Pack(3, __pyx_n_s_cupy_floor_divide, __pyx_tuple__380, __pyx_kp_s_out0__floor_divide_in0_in1); if (unlikely(!__pyx_tuple__381)) __PYX_ERR(0, 4221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__381);
  __Pyx_GIVEREF(__pyx_tuple__381);

  /* "cupy/core/core.pyx":4237
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = in0 - _floor_divide(in0, in1) * in1'),             # <<<<<<<<<<<<<<
 *      ('ff->f', 'out0 = in0 - _floor_divide(in0, in1) * in1'),
 *      ('dd->d', 'out0 = in0 - _floor_divide(in0, in1) * in1')),
 */
  __pyx_tuple__382 = PyTuple_Pack(2, __pyx_kp_s_ee_e, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i); if (unlikely(!__pyx_tuple__382)) __PYX_ERR(0, 4237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__382);
  __Pyx_GIVEREF(__pyx_tuple__382);

  /* "cupy/core/core.pyx":4238
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = in0 - _floor_divide(in0, in1) * in1'),
 *      ('ff->f', 'out0 = in0 - _floor_divide(in0, in1) * in1'),             # <<<<<<<<<<<<<<
 *      ('dd->d', 'out0 = in0 - _floor_divide(in0, in1) * in1')),
 *     'out0 = (in0 - _floor_divide(in0, in1) * in1) * (in1 != 0)',
 */
  __pyx_tuple__383 = PyTuple_Pack(2, __pyx_kp_s_ff_f, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i); if (unlikely(!__pyx_tuple__383)) __PYX_ERR(0, 4238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__383);
  __Pyx_GIVEREF(__pyx_tuple__383);

  /* "cupy/core/core.pyx":4239
 *      ('ee->e', 'out0 = in0 - _floor_divide(in0, in1) * in1'),
 *      ('ff->f', 'out0 = in0 - _floor_divide(in0, in1) * in1'),
 *      ('dd->d', 'out0 = in0 - _floor_divide(in0, in1) * in1')),             # <<<<<<<<<<<<<<
 *     'out0 = (in0 - _floor_divide(in0, in1) * in1) * (in1 != 0)',
 *     doc='''Computes the remainder of Python division elementwise.
 */
  __pyx_tuple__384 = PyTuple_Pack(2, __pyx_kp_s_dd_d, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i); if (unlikely(!__pyx_tuple__384)) __PYX_ERR(0, 4239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__384);
  __Pyx_GIVEREF(__pyx_tuple__384);

  /* "cupy/core/core.pyx":4235
 * remainder = create_ufunc(
 *     'cupy_remainder',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',             # <<<<<<<<<<<<<<
 *      'qq->q', 'QQ->Q',
 *      ('ee->e', 'out0 = in0 - _floor_divide(in0, in1) * in1'),
 */
  __pyx_tuple__385 = PyTuple_Pack(13, __pyx_kp_s_bb_b, __pyx_kp_s_BB_B, __pyx_kp_s_hh_h, __pyx_kp_s_HH_H, __pyx_kp_s_ii_i, __pyx_kp_s_II_I, __pyx_kp_s_ll_l, __pyx_kp_s_LL_L, __pyx_kp_s_qq_q, __pyx_kp_s_QQ_Q, __pyx_tuple__382, __pyx_tuple__383, __pyx_tuple__384); if (unlikely(!__pyx_tuple__385)) __PYX_ERR(0, 4235, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__385);
  __Pyx_GIVEREF(__pyx_tuple__385);

  /* "cupy/core/core.pyx":4233
 * 
 * 
 * remainder = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_remainder',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_tuple__386 = PyTuple_Pack(3, __pyx_n_s_cupy_remainder, __pyx_tuple__385, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i_2); if (unlikely(!__pyx_tuple__386)) __PYX_ERR(0, 4233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__386);
  __Pyx_GIVEREF(__pyx_tuple__386);

  /* "cupy/core/core.pyx":4250
 * absolute = create_ufunc(
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),             # <<<<<<<<<<<<<<
 *      'b->b', ('B->B', 'out0 = in0'), 'h->h', ('H->H', 'out0 = in0'),
 *      'i->i', ('I->I', 'out0 = in0'), 'l->l', ('L->L', 'out0 = in0'),
 */
  __pyx_tuple__387 = PyTuple_Pack(2, __pyx_kp_s__247, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__387)) __PYX_ERR(0, 4250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__387);
  __Pyx_GIVEREF(__pyx_tuple__387);

  /* "cupy/core/core.pyx":4251
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),
 *      'b->b', ('B->B', 'out0 = in0'), 'h->h', ('H->H', 'out0 = in0'),             # <<<<<<<<<<<<<<
 *      'i->i', ('I->I', 'out0 = in0'), 'l->l', ('L->L', 'out0 = in0'),
 *      'q->q', ('Q->Q', 'out0 = in0'),
 */
  __pyx_tuple__388 = PyTuple_Pack(2, __pyx_kp_s_B_B, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__388)) __PYX_ERR(0, 4251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__388);
  __Pyx_GIVEREF(__pyx_tuple__388);
  __pyx_tuple__389 = PyTuple_Pack(2, __pyx_kp_s_H_H, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__389)) __PYX_ERR(0, 4251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__389);
  __Pyx_GIVEREF(__pyx_tuple__389);

  /* "cupy/core/core.pyx":4252
 *     (('?->?', 'out0 = in0'),
 *      'b->b', ('B->B', 'out0 = in0'), 'h->h', ('H->H', 'out0 = in0'),
 *      'i->i', ('I->I', 'out0 = in0'), 'l->l', ('L->L', 'out0 = in0'),             # <<<<<<<<<<<<<<
 *      'q->q', ('Q->Q', 'out0 = in0'),
 *      ('e->e', 'out0 = fabsf(in0)'),
 */
  __pyx_tuple__390 = PyTuple_Pack(2, __pyx_kp_s_I_I, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__390)) __PYX_ERR(0, 4252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__390);
  __Pyx_GIVEREF(__pyx_tuple__390);
  __pyx_tuple__391 = PyTuple_Pack(2, __pyx_kp_s_L_L, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__391)) __PYX_ERR(0, 4252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__391);
  __Pyx_GIVEREF(__pyx_tuple__391);

  /* "cupy/core/core.pyx":4253
 *      'b->b', ('B->B', 'out0 = in0'), 'h->h', ('H->H', 'out0 = in0'),
 *      'i->i', ('I->I', 'out0 = in0'), 'l->l', ('L->L', 'out0 = in0'),
 *      'q->q', ('Q->Q', 'out0 = in0'),             # <<<<<<<<<<<<<<
 *      ('e->e', 'out0 = fabsf(in0)'),
 *      ('f->f', 'out0 = fabsf(in0)'),
 */
  __pyx_tuple__392 = PyTuple_Pack(2, __pyx_kp_s_Q_Q, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__392)) __PYX_ERR(0, 4253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__392);
  __Pyx_GIVEREF(__pyx_tuple__392);

  /* "cupy/core/core.pyx":4254
 *      'i->i', ('I->I', 'out0 = in0'), 'l->l', ('L->L', 'out0 = in0'),
 *      'q->q', ('Q->Q', 'out0 = in0'),
 *      ('e->e', 'out0 = fabsf(in0)'),             # <<<<<<<<<<<<<<
 *      ('f->f', 'out0 = fabsf(in0)'),
 *      ('d->d', 'out0 = fabs(in0)'),
 */
  __pyx_tuple__393 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_kp_s_out0_fabsf_in0); if (unlikely(!__pyx_tuple__393)) __PYX_ERR(0, 4254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__393);
  __Pyx_GIVEREF(__pyx_tuple__393);

  /* "cupy/core/core.pyx":4255
 *      'q->q', ('Q->Q', 'out0 = in0'),
 *      ('e->e', 'out0 = fabsf(in0)'),
 *      ('f->f', 'out0 = fabsf(in0)'),             # <<<<<<<<<<<<<<
 *      ('d->d', 'out0 = fabs(in0)'),
 *      ('F->f', 'out0 = abs(in0)'),
 */
  __pyx_tuple__394 = PyTuple_Pack(2, __pyx_kp_s_f_f, __pyx_kp_s_out0_fabsf_in0); if (unlikely(!__pyx_tuple__394)) __PYX_ERR(0, 4255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__394);
  __Pyx_GIVEREF(__pyx_tuple__394);

  /* "cupy/core/core.pyx":4256
 *      ('e->e', 'out0 = fabsf(in0)'),
 *      ('f->f', 'out0 = fabsf(in0)'),
 *      ('d->d', 'out0 = fabs(in0)'),             # <<<<<<<<<<<<<<
 *      ('F->f', 'out0 = abs(in0)'),
 *      ('D->d', 'out0 = abs(in0)')),
 */
  __pyx_tuple__395 = PyTuple_Pack(2, __pyx_kp_s_d_d, __pyx_kp_s_out0_fabs_in0); if (unlikely(!__pyx_tuple__395)) __PYX_ERR(0, 4256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__395);
  __Pyx_GIVEREF(__pyx_tuple__395);

  /* "cupy/core/core.pyx":4257
 *      ('f->f', 'out0 = fabsf(in0)'),
 *      ('d->d', 'out0 = fabs(in0)'),
 *      ('F->f', 'out0 = abs(in0)'),             # <<<<<<<<<<<<<<
 *      ('D->d', 'out0 = abs(in0)')),
 *     'out0 = in0 > 0 ? in0 : -in0',
 */
  __pyx_tuple__396 = PyTuple_Pack(2, __pyx_kp_s_F_f, __pyx_kp_s_out0_abs_in0); if (unlikely(!__pyx_tuple__396)) __PYX_ERR(0, 4257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__396);
  __Pyx_GIVEREF(__pyx_tuple__396);

  /* "cupy/core/core.pyx":4258
 *      ('d->d', 'out0 = fabs(in0)'),
 *      ('F->f', 'out0 = abs(in0)'),
 *      ('D->d', 'out0 = abs(in0)')),             # <<<<<<<<<<<<<<
 *     'out0 = in0 > 0 ? in0 : -in0',
 *     doc='''Elementwise absolute value function.
 */
  __pyx_tuple__397 = PyTuple_Pack(2, __pyx_kp_s_D_d, __pyx_kp_s_out0_abs_in0); if (unlikely(!__pyx_tuple__397)) __PYX_ERR(0, 4258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__397);
  __Pyx_GIVEREF(__pyx_tuple__397);

  /* "cupy/core/core.pyx":4250
 * absolute = create_ufunc(
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),             # <<<<<<<<<<<<<<
 *      'b->b', ('B->B', 'out0 = in0'), 'h->h', ('H->H', 'out0 = in0'),
 *      'i->i', ('I->I', 'out0 = in0'), 'l->l', ('L->L', 'out0 = in0'),
 */
  __pyx_tuple__398 = PyTuple_Pack(16, __pyx_tuple__387, __pyx_kp_s_b_b, __pyx_tuple__388, __pyx_kp_s_h_h, __pyx_tuple__389, __pyx_kp_s_i_i, __pyx_tuple__390, __pyx_kp_s_l_l, __pyx_tuple__391, __pyx_kp_s_q_q, __pyx_tuple__392, __pyx_tuple__393, __pyx_tuple__394, __pyx_tuple__395, __pyx_tuple__396, __pyx_tuple__397); if (unlikely(!__pyx_tuple__398)) __PYX_ERR(0, 4250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__398);
  __Pyx_GIVEREF(__pyx_tuple__398);

  /* "cupy/core/core.pyx":4248
 * 
 * 
 * absolute = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),
 */
  __pyx_tuple__399 = PyTuple_Pack(3, __pyx_n_s_cupy_absolute, __pyx_tuple__398, __pyx_kp_s_out0_in0_0_in0_in0); if (unlikely(!__pyx_tuple__399)) __PYX_ERR(0, 4248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__399);
  __Pyx_GIVEREF(__pyx_tuple__399);

  /* "cupy/core/core.pyx":4269
 * sqrt = create_ufunc(
 *     'cupy_sqrt',
 *     ('e->e', 'f->f', 'd->d', 'F->F', 'D->D'),             # <<<<<<<<<<<<<<
 *     'out0 = sqrt(in0)')
 * 
 */
  __pyx_tuple__400 = PyTuple_Pack(5, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_kp_s_F_F, __pyx_kp_s_D_D); if (unlikely(!__pyx_tuple__400)) __PYX_ERR(0, 4269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__400);
  __Pyx_GIVEREF(__pyx_tuple__400);

  /* "cupy/core/core.pyx":4275
 * _clip = create_ufunc(
 *     'cupy_clip',
 *     ('???->?', 'bbb->b', 'BBB->B', 'hhh->h', 'HHH->H', 'iii->i', 'III->I',             # <<<<<<<<<<<<<<
 *      'lll->l', 'LLL->L', 'qqq->q', 'QQQ->Q', 'eee->e', 'fff->f', 'ddd->d'),
 *     'out0 = in0 < in1 ? in1 : (in0 > in2 ? in2 : in0)')
 */
  __pyx_tuple__402 = PyTuple_Pack(14, __pyx_kp_s__401, __pyx_kp_s_bbb_b, __pyx_kp_s_BBB_B, __pyx_kp_s_hhh_h, __pyx_kp_s_HHH_H, __pyx_kp_s_iii_i, __pyx_kp_s_III_I, __pyx_kp_s_lll_l, __pyx_kp_s_LLL_L, __pyx_kp_s_qqq_q, __pyx_kp_s_QQQ_Q, __pyx_kp_s_eee_e, __pyx_kp_s_fff_f, __pyx_kp_s_ddd_d); if (unlikely(!__pyx_tuple__402)) __PYX_ERR(0, 4275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__402);
  __Pyx_GIVEREF(__pyx_tuple__402);

  /* "cupy/core/core.pyx":4315
 * 
 * 
 * cdef _var_core = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T mean, T alpha', 'T out',
 *     '(x - mean) * (x - mean)',
 */
  __pyx_tuple__403 = PyTuple_Pack(7, __pyx_kp_s_S_x_T_mean_T_alpha, __pyx_kp_s_T_out, __pyx_kp_s_x_mean_x_mean, __pyx_kp_s_a_b, __pyx_kp_s_out_alpha_a, __pyx_kp_s_0, __pyx_n_s_var_core); if (unlikely(!__pyx_tuple__403)) __PYX_ERR(0, 4315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__403);
  __Pyx_GIVEREF(__pyx_tuple__403);

  /* "cupy/core/core.pyx":4320
 *     'a + b', 'out = alpha * a', '0', '_var_core')
 * 
 * cdef _var_core_out = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T mean, T alpha', 'U out',
 *     '(x - mean) * (x - mean)',
 */
  __pyx_tuple__404 = PyTuple_Pack(7, __pyx_kp_s_S_x_T_mean_T_alpha, __pyx_kp_s_U_out, __pyx_kp_s_x_mean_x_mean, __pyx_kp_s_a_b, __pyx_kp_s_out_alpha_a, __pyx_kp_s_0, __pyx_n_s_var_core); if (unlikely(!__pyx_tuple__404)) __PYX_ERR(0, 4320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__404);
  __Pyx_GIVEREF(__pyx_tuple__404);

  /* "cupy/core/core.pyx":4330
 *     ('?->d', 'B->d', 'h->d', 'H->d', 'i->d', 'I->d', 'l->d', 'L->d',
 *      'q->d', 'Q->d',
 *      ('e->e', (None, None, None, 'float')),             # <<<<<<<<<<<<<<
 *      'f->f', 'd->d', 'F->F', 'D->D'),
 *     ('in0', 'a + b',
 */
  __pyx_tuple__405 = PyTuple_Pack(4, Py_None, Py_None, Py_None, __pyx_n_s_float); if (unlikely(!__pyx_tuple__405)) __PYX_ERR(0, 4330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__405);
  __Pyx_GIVEREF(__pyx_tuple__405);
  __pyx_tuple__406 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__405); if (unlikely(!__pyx_tuple__406)) __PYX_ERR(0, 4330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__406);
  __Pyx_GIVEREF(__pyx_tuple__406);

  /* "cupy/core/core.pyx":4328
 * cdef _mean = create_reduction_func(
 *     'cupy_mean',
 *     ('?->d', 'B->d', 'h->d', 'H->d', 'i->d', 'I->d', 'l->d', 'L->d',             # <<<<<<<<<<<<<<
 *      'q->d', 'Q->d',
 *      ('e->e', (None, None, None, 'float')),
 */
  __pyx_tuple__407 = PyTuple_Pack(15, __pyx_kp_s_d_3, __pyx_kp_s_B_d, __pyx_kp_s_h_d, __pyx_kp_s_H_d, __pyx_kp_s_i_d, __pyx_kp_s_I_d, __pyx_kp_s_l_d, __pyx_kp_s_L_d, __pyx_kp_s_q_d, __pyx_kp_s_Q_d, __pyx_tuple__406, __pyx_kp_s_f_f, __pyx_kp_s_d_d, __pyx_kp_s_F_F, __pyx_kp_s_D_D); if (unlikely(!__pyx_tuple__407)) __PYX_ERR(0, 4328, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__407);
  __Pyx_GIVEREF(__pyx_tuple__407);

  /* "cupy/core/core.pyx":4332
 *      ('e->e', (None, None, None, 'float')),
 *      'f->f', 'd->d', 'F->F', 'D->D'),
 *     ('in0', 'a + b',             # <<<<<<<<<<<<<<
 *      'out0 = a / _type_reduce(_in_ind.size() / _out_ind.size())', None))
 * 
 */
  __pyx_tuple__408 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b, __pyx_kp_s_out0_a__type_reduce__in_ind_size, Py_None); if (unlikely(!__pyx_tuple__408)) __PYX_ERR(0, 4332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__408);
  __Pyx_GIVEREF(__pyx_tuple__408);

  /* "cupy/core/core.pyx":4341
 * 
 * @util.memoize(for_each_device=True)
 * def _inclusive_scan_kernel(dtype, block_size):             # <<<<<<<<<<<<<<
 *     """return Prefix Sum(Scan) cuda kernel
 * 
 */
  __pyx_tuple__409 = PyTuple_Pack(5, __pyx_n_s_dtype, __pyx_n_s_block_size, __pyx_n_s_name, __pyx_n_s_source, __pyx_n_s_module_2); if (unlikely(!__pyx_tuple__409)) __PYX_ERR(0, 4341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__409);
  __Pyx_GIVEREF(__pyx_tuple__409);
  __pyx_codeobj__410 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__409, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_inclusive_scan_kernel_2, 4341, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__410)) __PYX_ERR(0, 4341, __pyx_L1_error)

  /* "cupy/core/core.pyx":4408
 * 
 * @util.memoize(for_each_device=True)
 * def _add_scan_blocked_sum_kernel(dtype):             # <<<<<<<<<<<<<<
 *     name = "add_scan_blocked_sum_kernel"
 *     dtype = _get_typename(dtype)
 */
  __pyx_tuple__411 = PyTuple_Pack(4, __pyx_n_s_dtype, __pyx_n_s_name, __pyx_n_s_source, __pyx_n_s_module_2); if (unlikely(!__pyx_tuple__411)) __PYX_ERR(0, 4408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__411);
  __Pyx_GIVEREF(__pyx_tuple__411);
  __pyx_codeobj__412 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__411, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_add_scan_blocked_sum_kernel_2, 4408, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__412)) __PYX_ERR(0, 4408, __pyx_L1_error)

  /* "cupy/core/core.pyx":4428
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_1d_kernel(src_dtype, index_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_1d_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */
  __pyx_tuple__413 = PyTuple_Pack(5, __pyx_n_s_src_dtype, __pyx_n_s_index_dtype, __pyx_n_s_name, __pyx_n_s_source, __pyx_n_s_module_2); if (unlikely(!__pyx_tuple__413)) __PYX_ERR(0, 4428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__413);
  __Pyx_GIVEREF(__pyx_tuple__413);
  __pyx_codeobj__414 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__413, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_nonzero_1d_kernel, 4428, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__414)) __PYX_ERR(0, 4428, __pyx_L1_error)

  /* "cupy/core/core.pyx":4451
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */
  __pyx_tuple__415 = PyTuple_Pack(7, __pyx_n_s_src_dtype, __pyx_n_s_src_ndim, __pyx_n_s_index_dtype, __pyx_n_s_dst_dtype, __pyx_n_s_name, __pyx_n_s_source, __pyx_n_s_module_2); if (unlikely(!__pyx_tuple__415)) __PYX_ERR(0, 4451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__415);
  __Pyx_GIVEREF(__pyx_tuple__415);
  __pyx_codeobj__416 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__415, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_nonzero_kernel, 4451, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__416)) __PYX_ERR(0, 4451, __pyx_L1_error)

  /* "cupy/core/core.pyx":4529
 * 
 * @util.memoize(for_each_device=True)
 * def _partition_kernel(dtype):             # <<<<<<<<<<<<<<
 *     name = 'partition_kernel'
 *     merge_kernel = 'partition_merge_kernel'
 */
  __pyx_tuple__417 = PyTuple_Pack(5, __pyx_n_s_dtype, __pyx_n_s_name, __pyx_n_s_merge_kernel, __pyx_n_s_source, __pyx_n_s_module_2); if (unlikely(!__pyx_tuple__417)) __PYX_ERR(0, 4529, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__417);
  __Pyx_GIVEREF(__pyx_tuple__417);
  __pyx_codeobj__418 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__417, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_core_core_pyx, __pyx_n_s_partition_kernel, 4529, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__418)) __PYX_ERR(0, 4529, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x6d47339:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_tuple__419 = 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__419)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__419);
  __Pyx_GIVEREF(__pyx_tuple__419);
  __pyx_codeobj__420 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__419, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Indexer, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__420)) __PYX_ERR(4, 1, __pyx_L1_error)
  __pyx_tuple__421 = 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__421)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__421);
  __Pyx_GIVEREF(__pyx_tuple__421);
  __pyx_codeobj__422 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__421, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_ParameterInfo, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__422)) __PYX_ERR(4, 1, __pyx_L1_error)
  __pyx_tuple__423 = 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__423)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__423);
  __Pyx_GIVEREF(__pyx_tuple__423);
  __pyx_codeobj__424 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__423, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_ElementwiseKernel, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__424)) __PYX_ERR(4, 1, __pyx_L1_error)
  __pyx_tuple__425 = 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__425)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__425);
  __Pyx_GIVEREF(__pyx_tuple__425);
  __pyx_codeobj__426 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__425, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_broadcast, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__426)) __PYX_ERR(4, 1, __pyx_L1_error)

  /* "View.MemoryView":285
 *         return self.name
 * 
 * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")
 */
  __pyx_tuple__427 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__427)) __PYX_ERR(4, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__427);
  __Pyx_GIVEREF(__pyx_tuple__427);

  /* "View.MemoryView":286
 * 
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
 * cdef indirect = Enum("<strided and indirect>")
 * 
 */
  __pyx_tuple__428 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__428)) __PYX_ERR(4, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__428);
  __Pyx_GIVEREF(__pyx_tuple__428);

  /* "View.MemoryView":287
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__429 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__429)) __PYX_ERR(4, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__429);
  __Pyx_GIVEREF(__pyx_tuple__429);

  /* "View.MemoryView":290
 * 
 * 
 * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")
 * 
 */
  __pyx_tuple__430 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__430)) __PYX_ERR(4, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__430);
  __Pyx_GIVEREF(__pyx_tuple__430);

  /* "View.MemoryView":291
 * 
 * cdef contiguous = Enum("<contiguous and direct>")
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__431 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__431)) __PYX_ERR(4, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__431);
  __Pyx_GIVEREF(__pyx_tuple__431);

  /* "(tree fragment)":1
 * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xb068931:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_tuple__432 = 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__432)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__432);
  __Pyx_GIVEREF(__pyx_tuple__432);
  __pyx_codeobj__433 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__432, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__433)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  __pyx_umethod_PyDict_Type_get.type = (PyObject*)&PyDict_Type;
  __pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type;
  __pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type;
  __pyx_umethod_PyList_Type_index.type = (PyObject*)&PyList_Type;
  __pyx_umethod_PyString_Type_split.type = (PyObject*)&PyString_Type;
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_float_0_ = PyFloat_FromDouble(0.); if (unlikely(!__pyx_float_0_)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_1_ = PyFloat_FromDouble(1.); if (unlikely(!__pyx_float_1_)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_0_0 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_float_0_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_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_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_70 = PyInt_FromLong(70); if (unlikely(!__pyx_int_70)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_256 = PyInt_FromLong(256); if (unlikely(!__pyx_int_256)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_512 = PyInt_FromLong(512); if (unlikely(!__pyx_int_512)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1024 = PyInt_FromLong(1024); if (unlikely(!__pyx_int_1024)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_7500 = PyInt_FromLong(7500); if (unlikely(!__pyx_int_7500)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_8000 = PyInt_FromLong(8000); if (unlikely(!__pyx_int_8000)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_9000 = PyInt_FromLong(9000); if (unlikely(!__pyx_int_9000)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_5472103 = PyInt_FromLong(5472103L); if (unlikely(!__pyx_int_5472103)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_114586425 = PyInt_FromLong(114586425L); if (unlikely(!__pyx_int_114586425)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_121017544 = PyInt_FromLong(121017544L); if (unlikely(!__pyx_int_121017544)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_131642003 = PyInt_FromLong(131642003L); if (unlikely(!__pyx_int_131642003)) __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_2147483647 = PyInt_FromLong(2147483647L); if (unlikely(!__pyx_int_2147483647)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2147483648 = PyInt_FromString((char *)"2147483648", 0, 0); if (unlikely(!__pyx_int_2147483648)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_4294967296 = PyInt_FromString((char *)"4294967296", 0, 0); if (unlikely(!__pyx_int_4294967296)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_9223372036854775808 = PyInt_FromString((char *)"9223372036854775808", 0, 0); if (unlikely(!__pyx_int_9223372036854775808)) __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)
  __pyx_int_neg_2 = PyInt_FromLong(-2); if (unlikely(!__pyx_int_neg_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_modinit_global_init_code(void); /*proto*/
static int __Pyx_modinit_variable_export_code(void); /*proto*/
static int __Pyx_modinit_function_export_code(void); /*proto*/
static int __Pyx_modinit_type_init_code(void); /*proto*/
static int __Pyx_modinit_type_import_code(void); /*proto*/
static int __Pyx_modinit_variable_import_code(void); /*proto*/
static 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 ---*/
  __pyx_v_4cupy_4core_4core__cupy_header_list = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__cupy_header = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__cupy_extra_header_list = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__header_path_cache = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__header_source = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__typenames_base = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__typenames = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__python_scalar_type = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__numpy_scalar_type = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__python_scalar_type_set = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__numpy_scalar_type_set = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__kind_score = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__python_type_to_numpy_type = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__int_type = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__id = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__divmod_float = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__min_max_preamble = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__argmin = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__argmax = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__concatenate_kernel_same_size = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__concatenate_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__take_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__take_kernel_0axis = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__choose_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__choose_clip_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__scatter_update_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__scatter_add_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__scatter_update_mask_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__scatter_add_mask_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__getitem_mask_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__cuda_runtime_version = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__tensordot_core_mul_sum = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__var_core = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__var_core_out = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__mean = Py_None; Py_INCREF(Py_None);
  __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i = Py_None; Py_INCREF(Py_None);
  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 ---*/
  if (__Pyx_ExportFunction("ascontiguousarray", (void (*)(void))__pyx_f_4cupy_4core_4core_ascontiguousarray, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  __pyx_vtabptr_4cupy_4core_4core_ndarray = &__pyx_vtable_4cupy_4core_4core_ndarray;
  __pyx_vtable_4cupy_4core_4core_ndarray.tolist = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_tolist;
  __pyx_vtable_4cupy_4core_4core_ndarray.tofile = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tofile *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_tofile;
  __pyx_vtable_4cupy_4core_4core_ndarray.dump = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_dump;
  __pyx_vtable_4cupy_4core_4core_ndarray.dumps = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_dumps;
  __pyx_vtable_4cupy_4core_4core_ndarray.astype = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_astype;
  __pyx_vtable_4cupy_4core_4core_ndarray.copy = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_copy;
  __pyx_vtable_4cupy_4core_4core_ndarray.view = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_view;
  __pyx_vtable_4cupy_4core_4core_ndarray.fill = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_fill;
  __pyx_vtable_4cupy_4core_4core_ndarray._reshape = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t> , int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray__reshape;
  __pyx_vtable_4cupy_4core_4core_ndarray._transpose = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t> , int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray__transpose;
  __pyx_vtable_4cupy_4core_4core_ndarray.swapaxes = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, Py_ssize_t, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_swapaxes;
  __pyx_vtable_4cupy_4core_4core_ndarray.flatten = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_flatten;
  __pyx_vtable_4cupy_4core_4core_ndarray.ravel = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_ravel;
  __pyx_vtable_4cupy_4core_4core_ndarray.squeeze = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_squeeze *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_squeeze;
  __pyx_vtable_4cupy_4core_4core_ndarray.take = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_take *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_take;
  __pyx_vtable_4cupy_4core_4core_ndarray.repeat = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_repeat;
  __pyx_vtable_4cupy_4core_4core_ndarray.choose = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_choose *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_choose;
  __pyx_vtable_4cupy_4core_4core_ndarray.diagonal = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_diagonal *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_diagonal;
  __pyx_vtable_4cupy_4core_4core_ndarray.max = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_max *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_max;
  __pyx_vtable_4cupy_4core_4core_ndarray.argmax = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmax *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_argmax;
  __pyx_vtable_4cupy_4core_4core_ndarray.min = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_min *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_min;
  __pyx_vtable_4cupy_4core_4core_ndarray.argmin = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmin *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_argmin;
  __pyx_vtable_4cupy_4core_4core_ndarray.clip = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_clip;
  __pyx_vtable_4cupy_4core_4core_ndarray.trace = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_trace *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_trace;
  __pyx_vtable_4cupy_4core_4core_ndarray.sum = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_sum;
  __pyx_vtable_4cupy_4core_4core_ndarray.mean = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_mean *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_mean;
  __pyx_vtable_4cupy_4core_4core_ndarray.var = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_var *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_var;
  __pyx_vtable_4cupy_4core_4core_ndarray.std = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_std *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_std;
  __pyx_vtable_4cupy_4core_4core_ndarray.prod = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_prod;
  __pyx_vtable_4cupy_4core_4core_ndarray.all = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_all *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_all;
  __pyx_vtable_4cupy_4core_4core_ndarray.any = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_any;
  __pyx_vtable_4cupy_4core_4core_ndarray.conj = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_conj;
  __pyx_vtable_4cupy_4core_4core_ndarray.get = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_get *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_get;
  __pyx_vtable_4cupy_4core_4core_ndarray.set = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_set;
  __pyx_vtable_4cupy_4core_4core_ndarray.reduced_view = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_reduced_view *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_reduced_view;
  __pyx_vtable_4cupy_4core_4core_ndarray._update_c_contiguity = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray__update_c_contiguity;
  __pyx_vtable_4cupy_4core_4core_ndarray._update_f_contiguity = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray__update_f_contiguity;
  __pyx_vtable_4cupy_4core_4core_ndarray._update_contiguity = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray__update_contiguity;
  __pyx_vtable_4cupy_4core_4core_ndarray._set_shape_and_strides = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  &, std::vector<Py_ssize_t>  &, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray__set_shape_and_strides;
  __pyx_vtable_4cupy_4core_4core_ndarray.get_pointer = (struct __pyx_obj_4cupy_4cuda_8function_CPointer *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *))__pyx_f_4cupy_4core_4core_7ndarray_get_pointer;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_ndarray) < 0) __PYX_ERR(0, 71, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_ndarray.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core_ndarray.tp_dictoffset && __pyx_type_4cupy_4core_4core_ndarray.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core_ndarray.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_4cupy_4core_4core_ndarray, "__getitem__"); if (unlikely(!wrapper)) __PYX_ERR(0, 71, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_4cupy_4core_4core_7ndarray_158__getitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_4cupy_4core_4core_7ndarray_158__getitem__.doc = __pyx_doc_4cupy_4core_4core_7ndarray_158__getitem__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4cupy_4core_4core_7ndarray_158__getitem__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_4cupy_4core_4core_ndarray, "__setitem__"); if (unlikely(!wrapper)) __PYX_ERR(0, 71, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_4cupy_4core_4core_7ndarray_160__setitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_4cupy_4core_4core_7ndarray_160__setitem__.doc = __pyx_doc_4cupy_4core_4core_7ndarray_160__setitem__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4cupy_4core_4core_7ndarray_160__setitem__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_4cupy_4core_4core_ndarray.tp_dict, __pyx_vtabptr_4cupy_4core_4core_ndarray) < 0) __PYX_ERR(0, 71, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "ndarray", (PyObject *)&__pyx_type_4cupy_4core_4core_ndarray) < 0) __PYX_ERR(0, 71, __pyx_L1_error)
  if (__pyx_type_4cupy_4core_4core_ndarray.tp_weaklistoffset == 0) __pyx_type_4cupy_4core_4core_ndarray.tp_weaklistoffset = offsetof(struct __pyx_obj_4cupy_4core_4core_ndarray, __weakref__);
  __pyx_ptype_4cupy_4core_4core_ndarray = &__pyx_type_4cupy_4core_4core_ndarray;
  __pyx_vtabptr_4cupy_4core_4core_Indexer = &__pyx_vtable_4cupy_4core_4core_Indexer;
  __pyx_vtable_4cupy_4core_4core_Indexer.get_pointer = (struct __pyx_obj_4cupy_4cuda_8function_CPointer *(*)(struct __pyx_obj_4cupy_4core_4core_Indexer *))__pyx_f_4cupy_4core_4core_7Indexer_get_pointer;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_Indexer) < 0) __PYX_ERR(2, 50, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_Indexer.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core_Indexer.tp_dictoffset && __pyx_type_4cupy_4core_4core_Indexer.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core_Indexer.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4cupy_4core_4core_Indexer.tp_dict, __pyx_vtabptr_4cupy_4core_4core_Indexer) < 0) __PYX_ERR(2, 50, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Indexer", (PyObject *)&__pyx_type_4cupy_4core_4core_Indexer) < 0) __PYX_ERR(2, 50, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_4core_4core_Indexer) < 0) __PYX_ERR(2, 50, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_Indexer = &__pyx_type_4cupy_4core_4core_Indexer;
  __pyx_ptype_4cupy_4cuda_8function_CPointer = __Pyx_ImportType("cupy.cuda.function", "CPointer", sizeof(struct __pyx_obj_4cupy_4cuda_8function_CPointer), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_8function_CPointer)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_CArray.tp_base = __pyx_ptype_4cupy_4cuda_8function_CPointer;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_CArray) < 0) __PYX_ERR(2, 17, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_CArray.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core_CArray.tp_dictoffset && __pyx_type_4cupy_4core_4core_CArray.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core_CArray.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "CArray", (PyObject *)&__pyx_type_4cupy_4core_4core_CArray) < 0) __PYX_ERR(2, 17, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_4core_4core_CArray) < 0) __PYX_ERR(2, 17, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_CArray = &__pyx_type_4cupy_4core_4core_CArray;
  __pyx_type_4cupy_4core_4core_CIndexer.tp_base = __pyx_ptype_4cupy_4cuda_8function_CPointer;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_CIndexer) < 0) __PYX_ERR(2, 38, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_CIndexer.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core_CIndexer.tp_dictoffset && __pyx_type_4cupy_4core_4core_CIndexer.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core_CIndexer.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "CIndexer", (PyObject *)&__pyx_type_4cupy_4core_4core_CIndexer) < 0) __PYX_ERR(2, 38, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_4core_4core_CIndexer) < 0) __PYX_ERR(2, 38, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_CIndexer = &__pyx_type_4cupy_4core_4core_CIndexer;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_ParameterInfo) < 0) __PYX_ERR(1, 249, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_ParameterInfo.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core_ParameterInfo.tp_dictoffset && __pyx_type_4cupy_4core_4core_ParameterInfo.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core_ParameterInfo.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "ParameterInfo", (PyObject *)&__pyx_type_4cupy_4core_4core_ParameterInfo) < 0) __PYX_ERR(1, 249, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_4core_4core_ParameterInfo) < 0) __PYX_ERR(1, 249, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_ParameterInfo = &__pyx_type_4cupy_4core_4core_ParameterInfo;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_ElementwiseKernel) < 0) __PYX_ERR(1, 442, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_ElementwiseKernel.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core_ElementwiseKernel.tp_dictoffset && __pyx_type_4cupy_4core_4core_ElementwiseKernel.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core_ElementwiseKernel.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_4cupy_4core_4core_ElementwiseKernel, "__call__"); if (unlikely(!wrapper)) __PYX_ERR(1, 442, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_4cupy_4core_4core_17ElementwiseKernel_2__call__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_4cupy_4core_4core_17ElementwiseKernel_2__call__.doc = __pyx_doc_4cupy_4core_4core_17ElementwiseKernel_2__call__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4cupy_4core_4core_17ElementwiseKernel_2__call__;
    }
  }
  #endif
  if (PyObject_SetAttrString(__pyx_m, "ElementwiseKernel", (PyObject *)&__pyx_type_4cupy_4core_4core_ElementwiseKernel) < 0) __PYX_ERR(1, 442, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_4core_4core_ElementwiseKernel) < 0) __PYX_ERR(1, 442, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_ElementwiseKernel = &__pyx_type_4cupy_4core_4core_ElementwiseKernel;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_broadcast) < 0) __PYX_ERR(0, 2277, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core_broadcast.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core_broadcast.tp_dictoffset && __pyx_type_4cupy_4core_4core_broadcast.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core_broadcast.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttrString(__pyx_m, "broadcast", (PyObject *)&__pyx_type_4cupy_4core_4core_broadcast) < 0) __PYX_ERR(0, 2277, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_4core_4core_broadcast) < 0) __PYX_ERR(0, 2277, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_broadcast = &__pyx_type_4cupy_4core_4core_broadcast;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel) < 0) __PYX_ERR(1, 420, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel.tp_dictoffset && __pyx_type_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel = &__pyx_type_4cupy_4core_4core___pyx_scope_struct___get_elementwise_kernel;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct_1_genexpr) < 0) __PYX_ERR(1, 424, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct_1_genexpr.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core___pyx_scope_struct_1_genexpr.tp_dictoffset && __pyx_type_4cupy_4core_4core___pyx_scope_struct_1_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core___pyx_scope_struct_1_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct_1_genexpr = &__pyx_type_4cupy_4core_4core___pyx_scope_struct_1_genexpr;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct_2___init__) < 0) __PYX_ERR(1, 708, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct_2___init__.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core___pyx_scope_struct_2___init__.tp_dictoffset && __pyx_type_4cupy_4core_4core___pyx_scope_struct_2___init__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core___pyx_scope_struct_2___init__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct_2___init__ = &__pyx_type_4cupy_4core_4core___pyx_scope_struct_2___init__;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct_3_genexpr) < 0) __PYX_ERR(1, 722, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct_3_genexpr.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core___pyx_scope_struct_3_genexpr.tp_dictoffset && __pyx_type_4cupy_4core_4core___pyx_scope_struct_3_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core___pyx_scope_struct_3_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct_3_genexpr = &__pyx_type_4cupy_4core_4core___pyx_scope_struct_3_genexpr;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct_4_genexpr) < 0) __PYX_ERR(1, 725, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct_4_genexpr.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core___pyx_scope_struct_4_genexpr.tp_dictoffset && __pyx_type_4cupy_4core_4core___pyx_scope_struct_4_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core___pyx_scope_struct_4_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct_4_genexpr = &__pyx_type_4cupy_4core_4core___pyx_scope_struct_4_genexpr;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel) < 0) __PYX_ERR(5, 273, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel.tp_dictoffset && __pyx_type_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel = &__pyx_type_4cupy_4core_4core___pyx_scope_struct_5__get_reduction_kernel;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct_6_genexpr) < 0) __PYX_ERR(5, 281, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct_6_genexpr.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core___pyx_scope_struct_6_genexpr.tp_dictoffset && __pyx_type_4cupy_4core_4core___pyx_scope_struct_6_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core___pyx_scope_struct_6_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct_6_genexpr = &__pyx_type_4cupy_4core_4core___pyx_scope_struct_6_genexpr;
  __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(4, 104, __pyx_L1_error)
  __pyx_type___pyx_array.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(4, 104, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_array) < 0) __PYX_ERR(4, 104, __pyx_L1_error)
  __pyx_array_type = &__pyx_type___pyx_array;
  if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(4, 278, __pyx_L1_error)
  __pyx_type___pyx_MemviewEnum.tp_print = 0;
  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(4, 278, __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(4, 329, __pyx_L1_error)
  __pyx_type___pyx_memoryview.tp_print = 0;
  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(4, 329, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(4, 329, __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(4, 960, __pyx_L1_error)
  __pyx_type___pyx_memoryviewslice.tp_print = 0;
  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(4, 960, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(4, 960, __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
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __pyx_ptype_4cupy_4cuda_6device_Device = __Pyx_ImportType("cupy.cuda.device", "Device", sizeof(struct __pyx_obj_4cupy_4cuda_6device_Device), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6device_Device)) __PYX_ERR(6, 7, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6device_Device = (struct __pyx_vtabstruct_4cupy_4cuda_6device_Device*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6device_Device->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6device_Device)) __PYX_ERR(6, 7, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_Memory = __Pyx_ImportType("cupy.cuda.memory", "Memory", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_Memory), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_Memory)) __PYX_ERR(7, 7, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer = __Pyx_ImportType("cupy.cuda.memory", "MemoryPointer", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_MemoryPointer)) __PYX_ERR(7, 15, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6memory_MemoryPointer = (struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6memory_MemoryPointer->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6memory_MemoryPointer)) __PYX_ERR(7, 15, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_SingleDeviceMemoryPool = __Pyx_ImportType("cupy.cuda.memory", "SingleDeviceMemoryPool", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_SingleDeviceMemoryPool), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_SingleDeviceMemoryPool)) __PYX_ERR(7, 41, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6memory_SingleDeviceMemoryPool = (struct __pyx_vtabstruct_4cupy_4cuda_6memory_SingleDeviceMemoryPool*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6memory_SingleDeviceMemoryPool->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6memory_SingleDeviceMemoryPool)) __PYX_ERR(7, 41, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_MemoryPool = __Pyx_ImportType("cupy.cuda.memory", "MemoryPool", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_MemoryPool)) __PYX_ERR(7, 85, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6memory_MemoryPool = (struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPool*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6memory_MemoryPool->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6memory_MemoryPool)) __PYX_ERR(7, 85, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_8function_Function = __Pyx_ImportType("cupy.cuda.function", "Function", sizeof(struct __pyx_obj_4cupy_4cuda_8function_Function), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_8function_Function)) __PYX_ERR(8, 5, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_8function_Function = (struct __pyx_vtabstruct_4cupy_4cuda_8function_Function*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_8function_Function->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_8function_Function)) __PYX_ERR(8, 5, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_8function_Module = __Pyx_ImportType("cupy.cuda.function", "Module", sizeof(struct __pyx_obj_4cupy_4cuda_8function_Module), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_8function_Module)) __PYX_ERR(8, 15, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_8function_Module = (struct __pyx_vtabstruct_4cupy_4cuda_8function_Module*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_8function_Module->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_8function_Module)) __PYX_ERR(8, 15, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_8function_LinkState = __Pyx_ImportType("cupy.cuda.function", "LinkState", sizeof(struct __pyx_obj_4cupy_4cuda_8function_LinkState), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_8function_LinkState)) __PYX_ERR(8, 26, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_8function_LinkState = (struct __pyx_vtabstruct_4cupy_4cuda_8function_LinkState*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_8function_LinkState->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_8function_LinkState)) __PYX_ERR(8, 26, __pyx_L1_error)
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", 
  #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(9, 9, __pyx_L1_error)
  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) __PYX_ERR(10, 8, __pyx_L1_error)
  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) __PYX_ERR(11, 15, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer = __Pyx_ImportType("cupy.cuda.pinned_memory", "PinnedMemoryPointer", sizeof(struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer)) __PYX_ERR(12, 2, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer = (struct __pyx_vtabstruct_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer)) __PYX_ERR(12, 2, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPool = __Pyx_ImportType("cupy.cuda.pinned_memory", "PinnedMemoryPool", sizeof(struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPool), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPool)) __PYX_ERR(12, 22, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_13pinned_memory_PinnedMemoryPool = (struct __pyx_vtabstruct_4cupy_4cuda_13pinned_memory_PinnedMemoryPool*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPool->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_13pinned_memory_PinnedMemoryPool)) __PYX_ERR(12, 22, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_7runtime_PointerAttributes = __Pyx_ImportType("cupy.cuda.runtime", "PointerAttributes", sizeof(struct __pyx_obj_4cupy_4cuda_7runtime_PointerAttributes), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_7runtime_PointerAttributes)) __PYX_ERR(13, 5, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __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
  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;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("cupy.cuda.device"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "get_device_id", (void (**)(void))&__pyx_f_4cupy_4cuda_6device_get_device_id, "int (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "get_cublas_handle", (void (**)(void))&__pyx_f_4cupy_4cuda_6device_get_cublas_handle, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "get_compute_capability", (void (**)(void))&__pyx_f_4cupy_4cuda_6device_get_compute_capability, "PyObject *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = __Pyx_ImportModule("cupy.cuda.memory"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_2, "alloc", (void (**)(void))&__pyx_f_4cupy_4cuda_6memory_alloc, "struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *(Py_ssize_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_ImportModule("cupy.core._dtype"); if (!__pyx_t_3) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "get_dtype", (void (**)(void))&__pyx_f_4cupy_4core_6_dtype_get_dtype, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_ImportModule("cupy.core.internal"); if (!__pyx_t_4) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "prod", (void (**)(void))&__pyx_f_4cupy_4core_8internal_prod, "Py_ssize_t (PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_8internal_prod *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "prod_ssize_t", (void (**)(void))&__pyx_f_4cupy_4core_8internal_prod_ssize_t, "Py_ssize_t (std::vector<Py_ssize_t>  &, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_8internal_prod_ssize_t *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "get_size", (void (**)(void))&__pyx_f_4cupy_4core_8internal_get_size, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "vector_equal", (void (**)(void))&__pyx_f_4cupy_4core_8internal_vector_equal, "int (std::vector<Py_ssize_t>  &, std::vector<Py_ssize_t>  &, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "get_reduced_dims", (void (**)(void))&__pyx_f_4cupy_4core_8internal_get_reduced_dims, "void (std::vector<Py_ssize_t>  &, std::vector<Py_ssize_t>  &, Py_ssize_t, std::vector<Py_ssize_t>  &, std::vector<Py_ssize_t>  &)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "get_contiguous_strides", (void (**)(void))&__pyx_f_4cupy_4core_8internal_get_contiguous_strides, "std::vector<Py_ssize_t>  (std::vector<Py_ssize_t>  &, Py_ssize_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "get_c_contiguity", (void (**)(void))&__pyx_f_4cupy_4core_8internal_get_c_contiguity, "int (std::vector<Py_ssize_t>  &, std::vector<Py_ssize_t>  &, Py_ssize_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "infer_unknown_dimension", (void (**)(void))&__pyx_f_4cupy_4core_8internal_infer_unknown_dimension, "std::vector<Py_ssize_t>  (std::vector<Py_ssize_t>  &, Py_ssize_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "complete_slice", (void (**)(void))&__pyx_f_4cupy_4core_8internal_complete_slice, "PyObject *(PyObject *, Py_ssize_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "complete_slice_list", (void (**)(void))&__pyx_f_4cupy_4core_8internal_complete_slice_list, "PyObject *(PyObject *, Py_ssize_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __Pyx_ImportModule("cupy.cuda.cublas"); if (!__pyx_t_5) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_5, "setMathMode", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_setMathMode, "PyObject *(size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_5, "sgemm", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_sgemm, "PyObject *(size_t, int, int, int, int, int, float, size_t, int, size_t, int, float, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_5, "dgemm", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_dgemm, "PyObject *(size_t, int, int, int, int, int, double, size_t, int, size_t, int, double, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_5, "cgemm", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_cgemm, "PyObject *(size_t, int, int, int, int, int, __pyx_t_float_complex, size_t, int, size_t, int, __pyx_t_float_complex, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_5, "zgemm", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_zgemm, "PyObject *(size_t, int, int, int, int, int, __pyx_t_double_complex, size_t, int, size_t, int, __pyx_t_double_complex, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_5, "sgemmEx", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_sgemmEx, "PyObject *(size_t, int, int, int, int, int, float, size_t, int, int, size_t, int, int, float, size_t, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_5, "gemmEx", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_gemmEx, "PyObject *(size_t, int, int, int, int, int, size_t, size_t, int, int, size_t, int, int, size_t, size_t, int, int, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_ImportModule("cupy.cuda.pinned_memory"); if (!__pyx_t_6) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "_add_to_watch_list", (void (**)(void))&__pyx_f_4cupy_4cuda_13pinned_memory__add_to_watch_list, "PyObject *(PyObject *, PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "alloc_pinned_memory", (void (**)(void))&__pyx_f_4cupy_4cuda_13pinned_memory_alloc_pinned_memory, "struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *(Py_ssize_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_7 = __Pyx_ImportModule("cupy.cuda.runtime"); if (!__pyx_t_7) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_7, "runtimeGetVersion", (void (**)(void))&__pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion, "int (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_8 = __Pyx_ImportModule("cupy.cuda.stream"); if (!__pyx_t_8) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_8, "get_current_stream_ptr", (void (**)(void))&__pyx_f_4cupy_4cuda_6stream_get_current_stream_ptr, "size_t (void)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_8, "get_current_stream", (void (**)(void))&__pyx_f_4cupy_4cuda_6stream_get_current_stream, "PyObject *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_RefNannyFinishContext();
  return -1;
}


#if PY_MAJOR_VERSION < 3
#ifdef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC void
#else
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#endif
#else
#ifdef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#endif
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__)
    #define CYTHON_SMALL_CODE __attribute__((optimize("Os")))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initcore(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initcore(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_core(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_core(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        result = PyDict_SetItemString(moddict, to_name, value);
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    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__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static int __pyx_pymod_exec_core(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  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;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14 = NULL;
  PY_LONG_LONG __pyx_t_15;
  struct __pyx_opt_args_4cupy_4core_4core_create_ufunc __pyx_t_16;
  struct __pyx_opt_args_4cupy_4core_4core_create_reduction_func __pyx_t_17;
  struct __pyx_opt_args_4cupy_4core_4core__create_bit_op __pyx_t_18;
  struct __pyx_opt_args_4cupy_4core_4core_create_comparison __pyx_t_19;
  static PyThread_type_lock __pyx_t_20[8];
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
  #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_core(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __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(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #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("core", __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)
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  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_cupy__core__core) {
    if (PyObject_SetAttrString(__pyx_m, "__name__", __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, "cupy.core.core")) {
      if (unlikely(PyDict_SetItemString(modules, "cupy.core.core", __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();
  if (unlikely(__Pyx_modinit_function_export_code() != 0)) goto __pyx_L1_error;
  if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
  if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
  (void)__Pyx_modinit_variable_import_code();
  if (unlikely(__Pyx_modinit_function_import_code() != 0)) goto __pyx_L1_error;
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "cupy/core/core.pyx":4
 * 
 * from __future__ import division
 * import sys             # <<<<<<<<<<<<<<
 * 
 * import numpy
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":6
 * import sys
 * 
 * import numpy             # <<<<<<<<<<<<<<
 * import six
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); 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_numpy, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":7
 * 
 * import numpy
 * import six             # <<<<<<<<<<<<<<
 * 
 * import cupy
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_six, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":9
 * import six
 * 
 * import cupy             # <<<<<<<<<<<<<<
 * from cupy.core import flags
 * from cupy.cuda import device
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_cupy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_cupy, __pyx_t_1) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":10
 * 
 * import cupy
 * from cupy.core import flags             # <<<<<<<<<<<<<<
 * from cupy.cuda import device
 * from cupy.cuda import stream
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_flags);
  __Pyx_GIVEREF(__pyx_n_s_flags);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_flags);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy_core, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __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_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_flags, __pyx_t_1) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":11
 * import cupy
 * from cupy.core import flags
 * from cupy.cuda import device             # <<<<<<<<<<<<<<
 * from cupy.cuda import stream
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_device);
  __Pyx_GIVEREF(__pyx_n_s_device);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_device);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_cupy_cuda, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_device); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_device, __pyx_t_2) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":12
 * from cupy.core import flags
 * from cupy.cuda import device
 * from cupy.cuda import stream             # <<<<<<<<<<<<<<
 * 
 * try:
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_stream);
  __Pyx_GIVEREF(__pyx_n_s_stream);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_stream);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy_cuda, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __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_stream); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_stream, __pyx_t_1) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":14
 * from cupy.cuda import stream
 * 
 * try:             # <<<<<<<<<<<<<<
 *     from cupy.cuda import thrust
 * except ImportError:
 */
  {
    __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:*/ {

      /* "cupy/core/core.pyx":15
 * 
 * try:
 *     from cupy.cuda import thrust             # <<<<<<<<<<<<<<
 * except ImportError:
 *     pass
 */
      __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L2_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_n_s_thrust);
      __Pyx_GIVEREF(__pyx_n_s_thrust);
      PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_thrust);
      __pyx_t_1 = __Pyx_Import(__pyx_n_s_cupy_cuda, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L2_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_thrust); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L2_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_thrust, __pyx_t_2) < 0) __PYX_ERR(0, 15, __pyx_L2_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":14
 * from cupy.cuda import stream
 * 
 * try:             # <<<<<<<<<<<<<<
 *     from cupy.cuda import thrust
 * except ImportError:
 */
    }
    __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_L7_try_end;
    __pyx_L2_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":16
 * try:
 *     from cupy.cuda import thrust
 * except ImportError:             # <<<<<<<<<<<<<<
 *     pass
 * from cupy import util
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError);
    if (__pyx_t_6) {
      __Pyx_ErrRestore(0,0,0);
      goto __pyx_L3_exception_handled;
    }
    goto __pyx_L4_except_error;
    __pyx_L4_except_error:;

    /* "cupy/core/core.pyx":14
 * from cupy.cuda import stream
 * 
 * try:             # <<<<<<<<<<<<<<
 *     from cupy.cuda import thrust
 * except ImportError:
 */
    __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_L3_exception_handled:;
    __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);
    __pyx_L7_try_end:;
  }

  /* "cupy/core/core.pyx":18
 * except ImportError:
 *     pass
 * from cupy import util             # <<<<<<<<<<<<<<
 * 
 * cimport cpython
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_util);
  __Pyx_GIVEREF(__pyx_n_s_util);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_util);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __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_util); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_1) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":43
 * 
 * 
 * try:             # <<<<<<<<<<<<<<
 *     _AxisError = numpy.AxisError
 * except AttributeError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "cupy/core/core.pyx":44
 * 
 * try:
 *     _AxisError = numpy.AxisError             # <<<<<<<<<<<<<<
 * except AttributeError:
 *     class IndexOrValueError(IndexError, ValueError):
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L8_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_AxisError_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L8_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_AxisError, __pyx_t_1) < 0) __PYX_ERR(0, 44, __pyx_L8_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":43
 * 
 * 
 * try:             # <<<<<<<<<<<<<<
 *     _AxisError = numpy.AxisError
 * except AttributeError:
 */
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L13_try_end;
    __pyx_L8_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":45
 * try:
 *     _AxisError = numpy.AxisError
 * except AttributeError:             # <<<<<<<<<<<<<<
 *     class IndexOrValueError(IndexError, ValueError):
 * 
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("cupy.core.core", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_7) < 0) __PYX_ERR(0, 45, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_7);

      /* "cupy/core/core.pyx":46
 *     _AxisError = numpy.AxisError
 * except AttributeError:
 *     class IndexOrValueError(IndexError, ValueError):             # <<<<<<<<<<<<<<
 * 
 *         def __init__(self, *args, **kwargs):
 */
      __pyx_t_8 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__195); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 46, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_Py3MetaclassPrepare(__pyx_t_8, __pyx_tuple__195, __pyx_n_s_IndexOrValueError, __pyx_n_s_IndexOrValueError, (PyObject *) NULL, __pyx_n_s_cupy_core_core, (PyObject *) NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 46, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_9);

      /* "cupy/core/core.pyx":48
 *     class IndexOrValueError(IndexError, ValueError):
 * 
 *         def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *             super(IndexOrValueError, self).__init__(*args, **kwargs)
 * 
 */
      __pyx_t_10 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_17IndexOrValueError_1__init__, 0, __pyx_n_s_IndexOrValueError___init, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__197)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 48, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_init, __pyx_t_10) < 0) __PYX_ERR(0, 48, __pyx_L10_except_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

      /* "cupy/core/core.pyx":46
 *     _AxisError = numpy.AxisError
 * except AttributeError:
 *     class IndexOrValueError(IndexError, ValueError):             # <<<<<<<<<<<<<<
 * 
 *         def __init__(self, *args, **kwargs):
 */
      __pyx_t_10 = __Pyx_Py3ClassCreate(__pyx_t_8, __pyx_n_s_IndexOrValueError, __pyx_tuple__195, __pyx_t_9, NULL, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 46, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_IndexOrValueError, __pyx_t_10) < 0) __PYX_ERR(0, 46, __pyx_L10_except_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":51
 *             super(IndexOrValueError, self).__init__(*args, **kwargs)
 * 
 *     _AxisError = IndexOrValueError             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_IndexOrValueError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 51, __pyx_L10_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_AxisError, __pyx_t_8) < 0) __PYX_ERR(0, 51, __pyx_L10_except_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L9_exception_handled;
    }
    goto __pyx_L10_except_error;
    __pyx_L10_except_error:;

    /* "cupy/core/core.pyx":43
 * 
 * 
 * try:             # <<<<<<<<<<<<<<
 *     _AxisError = numpy.AxisError
 * except AttributeError:
 */
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L9_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    __pyx_L13_try_end:;
  }

  /* "cupy/core/core.pyx":104
 *     """
 * 
 *     def __init__(self, shape, dtype=float, memptr=None, order='C'):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t x, itemsize
 *         self._shape = internal.get_size(shape)
 */
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __pyx_k__3 = ((PyObject *)(&PyFloat_Type));
  __Pyx_GIVEREF((&PyFloat_Type));

  /* "cupy/core/core.pyx":236
 *             return self._transpose(vector.vector[Py_ssize_t]())
 * 
 *     __array_priority__ = 100             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray->tp_dict, __pyx_n_s_array_priority, __pyx_int_100) < 0) __PYX_ERR(0, 236, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_ndarray);

  /* "cupy/core/core.pyx":1621
 *         return int(self.get())
 * 
 *     if sys.version_info < (3,):             # <<<<<<<<<<<<<<
 *         def __long__(self):
 *             # Avoid using long() for flake8
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1621, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_version_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1621, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_RichCompare(__pyx_t_2, __pyx_tuple__198, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1621, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 1621, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_11) {

    /* "cupy/core/core.pyx":1622
 * 
 *     if sys.version_info < (3,):
 *         def __long__(self):             # <<<<<<<<<<<<<<
 *             # Avoid using long() for flake8
 *             return self.get().__long__()
 */
  }

  /* "cupy/core/carray.pxi":1
 * import os             # <<<<<<<<<<<<<<
 * 
 * from cupy import cuda
 */
  __pyx_t_7 = __Pyx_Import(__pyx_n_s_os, 0, -1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_7) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/carray.pxi":3
 * import os
 * 
 * from cupy import cuda             # <<<<<<<<<<<<<<
 * 
 * from cupy.cuda cimport function
 */
  __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_n_s_cuda);
  __Pyx_GIVEREF(__pyx_n_s_cuda);
  PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_cuda);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy, __pyx_t_7, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_cuda); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_cuda, __pyx_t_7) < 0) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/carray.pxi":8
 * from cupy.cuda cimport runtime
 * 
 * import warnings             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_warnings, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_2) < 0) __PYX_ERR(2, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/carray.pxi":66
 * 
 * 
 * cdef list _cupy_header_list = [             # <<<<<<<<<<<<<<
 *     'cupy/complex.cuh',
 *     'cupy/carray.cuh',
 */
  __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_cuh);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_cuh);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_kp_s_cupy_complex_cuh);
  __Pyx_INCREF(__pyx_kp_s_cupy_carray_cuh);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_carray_cuh);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_kp_s_cupy_carray_cuh);
  __Pyx_INCREF(__pyx_kp_s_cupy_atomics_cuh);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_atomics_cuh);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_kp_s_cupy_atomics_cuh);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cupy_header_list);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cupy_header_list, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/carray.pxi":72
 * ]
 * cdef str _cupy_header = ''.join(
 *     ['#include <%s>\n' % i for i in _cupy_header_list])             # <<<<<<<<<<<<<<
 * 
 * # This is indirect include header list.
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(__pyx_v_4cupy_4core_4core__cupy_header_list == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(2, 72, __pyx_L1_error)
  }
  __pyx_t_7 = __pyx_v_4cupy_4core_4core__cupy_header_list; __Pyx_INCREF(__pyx_t_7); __pyx_t_12 = 0;
  for (;;) {
    if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_7)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_12); __Pyx_INCREF(__pyx_t_1); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(2, 72, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_7, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 72, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_i, __pyx_t_1) < 0) __PYX_ERR(2, 72, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 72, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_include_s, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 72, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_8))) __PYX_ERR(2, 72, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/carray.pxi":71
 *     'cupy/atomics.cuh',
 * ]
 * cdef str _cupy_header = ''.join(             # <<<<<<<<<<<<<<
 *     ['#include <%s>\n' % i for i in _cupy_header_list])
 * 
 */
  __pyx_t_7 = __Pyx_PyString_Join(__pyx_kp_s__6, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_7)->tp_name), 0))) __PYX_ERR(2, 71, __pyx_L1_error)
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cupy_header);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cupy_header, ((PyObject*)__pyx_t_7));
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/carray.pxi":76
 * # This is indirect include header list.
 * # These header files are subject to a hash key.
 * cdef list _cupy_extra_header_list = [             # <<<<<<<<<<<<<<
 *     'cupy/complex/complex.h',
 *     'cupy/complex/math_private.h',
 */
  __pyx_t_7 = PyList_New(20); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_complex_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_complex_h);
  PyList_SET_ITEM(__pyx_t_7, 0, __pyx_kp_s_cupy_complex_complex_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_math_private_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_math_private_h);
  PyList_SET_ITEM(__pyx_t_7, 1, __pyx_kp_s_cupy_complex_math_private_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_complex_inl_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_complex_inl_h);
  PyList_SET_ITEM(__pyx_t_7, 2, __pyx_kp_s_cupy_complex_complex_inl_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_arithmetic_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_arithmetic_h);
  PyList_SET_ITEM(__pyx_t_7, 3, __pyx_kp_s_cupy_complex_arithmetic_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_cproj_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_cproj_h);
  PyList_SET_ITEM(__pyx_t_7, 4, __pyx_kp_s_cupy_complex_cproj_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_cexp_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_cexp_h);
  PyList_SET_ITEM(__pyx_t_7, 5, __pyx_kp_s_cupy_complex_cexp_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_cexpf_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_cexpf_h);
  PyList_SET_ITEM(__pyx_t_7, 6, __pyx_kp_s_cupy_complex_cexpf_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_clog_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_clog_h);
  PyList_SET_ITEM(__pyx_t_7, 7, __pyx_kp_s_cupy_complex_clog_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_clogf_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_clogf_h);
  PyList_SET_ITEM(__pyx_t_7, 8, __pyx_kp_s_cupy_complex_clogf_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_cpow_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_cpow_h);
  PyList_SET_ITEM(__pyx_t_7, 9, __pyx_kp_s_cupy_complex_cpow_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_ccosh_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_ccosh_h);
  PyList_SET_ITEM(__pyx_t_7, 10, __pyx_kp_s_cupy_complex_ccosh_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_ccoshf_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_ccoshf_h);
  PyList_SET_ITEM(__pyx_t_7, 11, __pyx_kp_s_cupy_complex_ccoshf_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_csinh_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_csinh_h);
  PyList_SET_ITEM(__pyx_t_7, 12, __pyx_kp_s_cupy_complex_csinh_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_csinhf_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_csinhf_h);
  PyList_SET_ITEM(__pyx_t_7, 13, __pyx_kp_s_cupy_complex_csinhf_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_ctanh_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_ctanh_h);
  PyList_SET_ITEM(__pyx_t_7, 14, __pyx_kp_s_cupy_complex_ctanh_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_ctanhf_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_ctanhf_h);
  PyList_SET_ITEM(__pyx_t_7, 15, __pyx_kp_s_cupy_complex_ctanhf_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_csqrt_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_csqrt_h);
  PyList_SET_ITEM(__pyx_t_7, 16, __pyx_kp_s_cupy_complex_csqrt_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_csqrtf_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_csqrtf_h);
  PyList_SET_ITEM(__pyx_t_7, 17, __pyx_kp_s_cupy_complex_csqrtf_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_catrig_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_catrig_h);
  PyList_SET_ITEM(__pyx_t_7, 18, __pyx_kp_s_cupy_complex_catrig_h);
  __Pyx_INCREF(__pyx_kp_s_cupy_complex_catrigf_h);
  __Pyx_GIVEREF(__pyx_kp_s_cupy_complex_catrigf_h);
  PyList_SET_ITEM(__pyx_t_7, 19, __pyx_kp_s_cupy_complex_catrigf_h);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cupy_extra_header_list);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cupy_extra_header_list, ((PyObject*)__pyx_t_7));
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/carray.pxi":99
 * ]
 * 
 * cdef str _header_path_cache = None             # <<<<<<<<<<<<<<
 * cdef str _header_source = None
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__header_path_cache);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__header_path_cache, ((PyObject*)Py_None));
  __Pyx_GIVEREF(Py_None);

  /* "cupy/core/carray.pxi":100
 * 
 * cdef str _header_path_cache = None
 * cdef str _header_source = None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__header_source);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__header_source, ((PyObject*)Py_None));
  __Pyx_GIVEREF(Py_None);

  /* "cupy/core/elementwise.pxi":1
 * import string             # <<<<<<<<<<<<<<
 * 
 * import numpy
 */
  __pyx_t_7 = __Pyx_Import(__pyx_n_s_string, 0, -1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_string, __pyx_t_7) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":3
 * import string
 * 
 * import numpy             # <<<<<<<<<<<<<<
 * import six
 * 
 */
  __pyx_t_7 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_7) < 0) __PYX_ERR(1, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":4
 * 
 * import numpy
 * import six             # <<<<<<<<<<<<<<
 * 
 * from cupy.core import _dtype
 */
  __pyx_t_7 = __Pyx_Import(__pyx_n_s_six, 0, -1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_7) < 0) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":6
 * import six
 * 
 * from cupy.core import _dtype             # <<<<<<<<<<<<<<
 * from cupy.cuda import compiler
 * from cupy import util
 */
  __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_n_s_dtype_2);
  __Pyx_GIVEREF(__pyx_n_s_dtype_2);
  PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_dtype_2);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy_core, __pyx_t_7, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_dtype_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_dtype_2, __pyx_t_7) < 0) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":7
 * 
 * from cupy.core import _dtype
 * from cupy.cuda import compiler             # <<<<<<<<<<<<<<
 * from cupy import util
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_compiler);
  __Pyx_GIVEREF(__pyx_n_s_compiler);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_compiler);
  __pyx_t_7 = __Pyx_Import(__pyx_n_s_cupy_cuda, __pyx_t_2, -1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_compiler); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_compiler, __pyx_t_2) < 0) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":8
 * from cupy.core import _dtype
 * from cupy.cuda import compiler
 * from cupy import util             # <<<<<<<<<<<<<<
 * 
 * from cupy.cuda cimport device
 */
  __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_n_s_util);
  __Pyx_GIVEREF(__pyx_n_s_util);
  PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_util);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy, __pyx_t_7, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_util); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_7) < 0) __PYX_ERR(1, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":39
 * 
 * cdef dict _typenames_base = {
 *     numpy.dtype('float64'): 'double',             # <<<<<<<<<<<<<<
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(14); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__199, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_7, __pyx_n_s_double) < 0) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":40
 * cdef dict _typenames_base = {
 *     numpy.dtype('float64'): 'double',
 *     numpy.dtype('float32'): 'float',             # <<<<<<<<<<<<<<
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('complex128'): 'complex<double>',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__200, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_7, __pyx_n_s_float) < 0) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":41
 *     numpy.dtype('float64'): 'double',
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',             # <<<<<<<<<<<<<<
 *     numpy.dtype('complex128'): 'complex<double>',
 *     numpy.dtype('complex64'): 'complex<float>',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__201, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_7, __pyx_n_s_float16) < 0) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":42
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('complex128'): 'complex<double>',             # <<<<<<<<<<<<<<
 *     numpy.dtype('complex64'): 'complex<float>',
 *     numpy.dtype('int64'): 'long long',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__202, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_7, __pyx_kp_s_complex_double) < 0) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":43
 *     numpy.dtype('float16'): 'float16',
 *     numpy.dtype('complex128'): 'complex<double>',
 *     numpy.dtype('complex64'): 'complex<float>',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__203, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_7, __pyx_kp_s_complex_float) < 0) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":44
 *     numpy.dtype('complex128'): 'complex<double>',
 *     numpy.dtype('complex64'): 'complex<float>',
 *     numpy.dtype('int64'): 'long long',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__204, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_7, __pyx_kp_s_long_long) < 0) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":45
 *     numpy.dtype('complex64'): 'complex<float>',
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__205, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_7, __pyx_n_s_int) < 0) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":46
 *     numpy.dtype('int64'): 'long long',
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',             # <<<<<<<<<<<<<<
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__206, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_7, __pyx_n_s_short) < 0) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":47
 *     numpy.dtype('int32'): 'int',
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__207, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_7, __pyx_kp_s_signed_char) < 0) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":48
 *     numpy.dtype('int16'): 'short',
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__208, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_7, __pyx_kp_s_unsigned_long_long) < 0) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":49
 *     numpy.dtype('int8'): 'signed char',
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__209, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_7, __pyx_kp_s_unsigned_int) < 0) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":50
 *     numpy.dtype('uint64'): 'unsigned long long',
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',             # <<<<<<<<<<<<<<
 *     numpy.dtype('uint8'): 'unsigned char',
 *     numpy.dtype('bool'): 'bool',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__210, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_7, __pyx_kp_s_unsigned_short) < 0) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":51
 *     numpy.dtype('uint32'): 'unsigned int',
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',             # <<<<<<<<<<<<<<
 *     numpy.dtype('bool'): 'bool',
 * }
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__211, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_7, __pyx_kp_s_unsigned_char) < 0) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":52
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',
 *     numpy.dtype('bool'): 'bool',             # <<<<<<<<<<<<<<
 * }
 * 
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__212, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_7, __pyx_n_s_bool_2) < 0) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__typenames_base);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__typenames_base, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":55
 * }
 * 
 * cdef dict _typenames = {             # <<<<<<<<<<<<<<
 *     numpy.dtype(i).type: _typenames_base[numpy.dtype(i)]
 *     for i in _dtype.all_type_chars}
 */
  { /* enter inner scope */
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 55, __pyx_L21_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "cupy/core/elementwise.pxi":57
 * cdef dict _typenames = {
 *     numpy.dtype(i).type: _typenames_base[numpy.dtype(i)]
 *     for i in _dtype.all_type_chars}             # <<<<<<<<<<<<<<
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtype_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 57, __pyx_L21_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_all_type_chars); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 57, __pyx_L21_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) {
      __pyx_t_7 = __pyx_t_8; __Pyx_INCREF(__pyx_t_7); __pyx_t_12 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_12 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 57, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_13 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 57, __pyx_L21_error)
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_8 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_12); __Pyx_INCREF(__pyx_t_8); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(1, 57, __pyx_L21_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_7, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 57, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        } else {
          if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_12); __Pyx_INCREF(__pyx_t_8); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(1, 57, __pyx_L21_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_7, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 57, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        }
      } else {
        __pyx_t_8 = __pyx_t_13(__pyx_t_7);
        if (unlikely(!__pyx_t_8)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(1, 57, __pyx_L21_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_8);
      }
      __Pyx_XGOTREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
      __Pyx_DECREF_SET(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      __pyx_t_8 = 0;

      /* "cupy/core/elementwise.pxi":56
 * 
 * cdef dict _typenames = {
 *     numpy.dtype(i).type: _typenames_base[numpy.dtype(i)]             # <<<<<<<<<<<<<<
 *     for i in _dtype.all_type_chars}
 * 
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 56, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 56, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_1) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 56, __pyx_L21_error)
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i};
          __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 56, __pyx_L21_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i};
          __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 56, __pyx_L21_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        {
          __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 56, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); __pyx_t_1 = NULL;
          __Pyx_INCREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
          __Pyx_GIVEREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
          PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 56, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 56, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(__pyx_v_4cupy_4core_4core__typenames_base == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(1, 56, __pyx_L21_error)
      }
      __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 56, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 56, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 56, __pyx_L21_error)
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_1)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i};
          __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 56, __pyx_L21_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i};
          __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 56, __pyx_L21_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        {
          __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 56, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
          __Pyx_GIVEREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
          PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_14, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 56, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_4cupy_4core_4core__typenames_base, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 56, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(PyDict_SetItem(__pyx_t_2, (PyObject*)__pyx_t_9, (PyObject*)__pyx_t_1))) __PYX_ERR(1, 56, __pyx_L21_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/core/elementwise.pxi":57
 * cdef dict _typenames = {
 *     numpy.dtype(i).type: _typenames_base[numpy.dtype(i)]
 *     for i in _dtype.all_type_chars}             # <<<<<<<<<<<<<<
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)
 */
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
    __Pyx_DECREF_SET(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i, Py_None);
    goto __pyx_L24_exit_scope;
    __pyx_L21_error:;
    __Pyx_GOTREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
    __Pyx_DECREF_SET(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i, Py_None);
    goto __pyx_L1_error;
    __pyx_L24_exit_scope:;
  } /* exit inner scope */
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__typenames);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__typenames, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":59
 *     for i in _dtype.all_type_chars}
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)             # <<<<<<<<<<<<<<
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type
 *                                        for i in _dtype.all_type_chars])
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_integer_types); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyFloat_Type)));
  __Pyx_INCREF(((PyObject*)&PyBool_Type));
  __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject*)&PyBool_Type));
  __Pyx_INCREF(((PyObject *)(&PyComplex_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyComplex_Type)));
  PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)(&PyComplex_Type)));
  __pyx_t_1 = PyNumber_Add(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 59, __pyx_L1_error)
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__python_scalar_type);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__python_scalar_type, ((PyObject*)__pyx_t_1));
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":60
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type             # <<<<<<<<<<<<<<
 *                                        for i in _dtype.all_type_chars])
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":61
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type
 *                                        for i in _dtype.all_type_chars])             # <<<<<<<<<<<<<<
 * 
 * cdef set _python_scalar_type_set = set(_python_scalar_type)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtype_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_all_type_chars); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_7)) || PyTuple_CheckExact(__pyx_t_7)) {
    __pyx_t_2 = __pyx_t_7; __Pyx_INCREF(__pyx_t_2); __pyx_t_12 = 0;
    __pyx_t_13 = NULL;
  } else {
    __pyx_t_12 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_13 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 61, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  for (;;) {
    if (likely(!__pyx_t_13)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_12); __Pyx_INCREF(__pyx_t_7); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(1, 61, __pyx_L1_error)
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_2, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 61, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      } else {
        if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_12); __Pyx_INCREF(__pyx_t_7); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(1, 61, __pyx_L1_error)
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_2, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 61, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      }
    } else {
      __pyx_t_7 = __pyx_t_13(__pyx_t_2);
      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, 61, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_7);
    }
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_i, __pyx_t_7) < 0) __PYX_ERR(1, 61, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":60
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type             # <<<<<<<<<<<<<<
 *                                        for i in _dtype.all_type_chars])
 * 
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 60, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 60, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 60, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_14 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_14)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_14);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_14) {
      __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 60, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_7);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_9};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 60, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_9};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 60, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 60, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_14); __pyx_t_14 = NULL;
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 60, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_type); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 60, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_8))) __PYX_ERR(1, 60, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/elementwise.pxi":61
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type
 *                                        for i in _dtype.all_type_chars])             # <<<<<<<<<<<<<<
 * 
 * cdef set _python_scalar_type_set = set(_python_scalar_type)
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":60
 * 
 * cdef tuple _python_scalar_type = six.integer_types + (float, bool, complex)
 * cdef tuple _numpy_scalar_type = tuple([numpy.dtype(i).type             # <<<<<<<<<<<<<<
 *                                        for i in _dtype.all_type_chars])
 * 
 */
  __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__numpy_scalar_type);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__numpy_scalar_type, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":63
 *                                        for i in _dtype.all_type_chars])
 * 
 * cdef set _python_scalar_type_set = set(_python_scalar_type)             # <<<<<<<<<<<<<<
 * cdef set _numpy_scalar_type_set = set(_numpy_scalar_type)
 * 
 */
  __pyx_t_2 = PySet_New(__pyx_v_4cupy_4core_4core__python_scalar_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__python_scalar_type_set);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__python_scalar_type_set, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":64
 * 
 * cdef set _python_scalar_type_set = set(_python_scalar_type)
 * cdef set _numpy_scalar_type_set = set(_numpy_scalar_type)             # <<<<<<<<<<<<<<
 * 
 * cdef dict _kind_score = {
 */
  __pyx_t_2 = PySet_New(__pyx_v_4cupy_4core_4core__numpy_scalar_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 64, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__numpy_scalar_type_set);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__numpy_scalar_type_set, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":67
 * 
 * cdef dict _kind_score = {
 *     'b': 0,             # <<<<<<<<<<<<<<
 *     'u': 1,
 *     'i': 1,
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_b, __pyx_int_0) < 0) __PYX_ERR(1, 67, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_u, __pyx_int_1) < 0) __PYX_ERR(1, 67, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_i, __pyx_int_1) < 0) __PYX_ERR(1, 67, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_f, __pyx_int_2) < 0) __PYX_ERR(1, 67, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_c, __pyx_int_3) < 0) __PYX_ERR(1, 67, __pyx_L1_error)
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__kind_score);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__kind_score, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":76
 * 
 * cdef dict _python_type_to_numpy_type = {
 *     float: numpy.dtype(float).type,             # <<<<<<<<<<<<<<
 *     complex: numpy.dtype(complex).type,
 *     bool: numpy.dtype(bool).type,
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, ((PyObject *)(&PyFloat_Type))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_type); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)(&PyFloat_Type)), __pyx_t_8) < 0) __PYX_ERR(1, 76, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":77
 * cdef dict _python_type_to_numpy_type = {
 *     float: numpy.dtype(float).type,
 *     complex: numpy.dtype(complex).type,             # <<<<<<<<<<<<<<
 *     bool: numpy.dtype(bool).type,
 * }
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 77, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 77, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)(&PyComplex_Type))); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 77, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 77, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)(&PyComplex_Type)), __pyx_t_1) < 0) __PYX_ERR(1, 76, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":78
 *     float: numpy.dtype(float).type,
 *     complex: numpy.dtype(complex).type,
 *     bool: numpy.dtype(bool).type,             # <<<<<<<<<<<<<<
 * }
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, ((PyObject*)&PyBool_Type)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_type); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject*)&PyBool_Type), __pyx_t_8) < 0) __PYX_ERR(1, 76, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__python_type_to_numpy_type);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__python_type_to_numpy_type, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":82
 * 
 * 
 * _int_iinfo = numpy.iinfo(int)             # <<<<<<<<<<<<<<
 * cdef long long _int_min = _int_iinfo.min
 * cdef long long _int_max = _int_iinfo.max
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 82, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 82, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, ((PyObject *)(&PyInt_Type))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 82, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_int_iinfo, __pyx_t_2) < 0) __PYX_ERR(1, 82, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":83
 * 
 * _int_iinfo = numpy.iinfo(int)
 * cdef long long _int_min = _int_iinfo.min             # <<<<<<<<<<<<<<
 * cdef long long _int_max = _int_iinfo.max
 * cdef _int_type = _int_iinfo.dtype.type
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_int_iinfo); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_min); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_15 = __Pyx_PyInt_As_PY_LONG_LONG(__pyx_t_8); if (unlikely((__pyx_t_15 == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 83, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_4cupy_4core_4core__int_min = __pyx_t_15;

  /* "cupy/core/elementwise.pxi":84
 * _int_iinfo = numpy.iinfo(int)
 * cdef long long _int_min = _int_iinfo.min
 * cdef long long _int_max = _int_iinfo.max             # <<<<<<<<<<<<<<
 * cdef _int_type = _int_iinfo.dtype.type
 * 
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_int_iinfo); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_max); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_15 = __Pyx_PyInt_As_PY_LONG_LONG(__pyx_t_2); if (unlikely((__pyx_t_15 == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 84, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_4cupy_4core_4core__int_max = __pyx_t_15;

  /* "cupy/core/elementwise.pxi":85
 * cdef long long _int_min = _int_iinfo.min
 * cdef long long _int_max = _int_iinfo.max
 * cdef _int_type = _int_iinfo.dtype.type             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_int_iinfo); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__int_type);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__int_type, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":286
 * 
 * 
 * @util.memoize()             # <<<<<<<<<<<<<<
 * def _get_param_info(s, is_const):
 *     if len(s) == 0:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_memoize); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":287
 * 
 * @util.memoize()
 * def _get_param_info(s, is_const):             # <<<<<<<<<<<<<<
 *     if len(s) == 0:
 *         return ()
 */
  __pyx_t_8 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_23_get_param_info, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/elementwise.pxi":286
 * 
 * 
 * @util.memoize()             # <<<<<<<<<<<<<<
 * def _get_param_info(s, is_const):
 *     if len(s) == 0:
 */
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_param_info, __pyx_t_1) < 0) __PYX_ERR(1, 287, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":293
 * 
 * 
 * @util.memoize()             # <<<<<<<<<<<<<<
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):
 *     type_dict = {}
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_memoize); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":294
 * 
 * @util.memoize()
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):             # <<<<<<<<<<<<<<
 *     type_dict = {}
 *     if out_args_dtype:
 */
  __pyx_t_8 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_25_decide_params_type, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/elementwise.pxi":293
 * 
 * 
 * @util.memoize()             # <<<<<<<<<<<<<<
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):
 *     type_dict = {}
 */
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_decide_params_type, __pyx_t_2) < 0) __PYX_ERR(1, 294, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":419
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_elementwise_kernel(args_info, types, params, operation, name,
 *                             preamble, kwargs):
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_memoize); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(1, 419, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":420
 * 
 * @util.memoize(for_each_device=True)
 * def _get_elementwise_kernel(args_info, types, params, operation, name,             # <<<<<<<<<<<<<<
 *                             preamble, kwargs):
 *     kernel_params = _get_kernel_params(params, args_info)
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_27_get_elementwise_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/elementwise.pxi":419
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_elementwise_kernel(args_info, types, params, operation, name,
 *                             preamble, kwargs):
 */
  __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_elementwise_kernel, __pyx_t_8) < 0) __PYX_ERR(1, 420, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":594
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_ufunc_kernel(
 *         in_types, out_types, routine, args_info, params, name, preamble):
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_memoize); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(1, 594, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":595
 * 
 * @util.memoize(for_each_device=True)
 * def _get_ufunc_kernel(             # <<<<<<<<<<<<<<
 *         in_types, out_types, routine, args_info, params, name, preamble):
 *     kernel_params = _get_kernel_params(params, args_info)
 */
  __pyx_t_8 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_29_get_ufunc_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 595, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/elementwise.pxi":594
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_ufunc_kernel(
 *         in_types, out_types, routine, args_info, params, name, preamble):
 */
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_ufunc_kernel, __pyx_t_2) < 0) __PYX_ERR(1, 595, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":696
 * 
 * 
 * class ufunc(object):             # <<<<<<<<<<<<<<
 * 
 *     """Universal function.
 */
  __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__221); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 696, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_tuple__221, __pyx_n_s_ufunc, __pyx_n_s_ufunc, (PyObject *) NULL, __pyx_n_s_cupy_core_core, __pyx_kp_s_Universal_function_Attributes_uf); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 696, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/elementwise.pxi":708
 *     """
 * 
 *     def __init__(self, name, nin, nout, ops, preamble='', doc='',             # <<<<<<<<<<<<<<
 *                  default_casting=None):
 *         self.name = name
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_5ufunc_1__init__, 0, __pyx_n_s_ufunc___init, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__223)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 708, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_tuple__224);
  if (__Pyx_SetNameInClass(__pyx_t_8, __pyx_n_s_init, __pyx_t_1) < 0) __PYX_ERR(1, 708, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":731
 *         self._routine_cache = {}
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<ufunc '%s'>" % self.name
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_5ufunc_3__repr__, 0, __pyx_n_s_ufunc___repr, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__226)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 731, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_SetNameInClass(__pyx_t_8, __pyx_n_s_repr, __pyx_t_1) < 0) __PYX_ERR(1, 731, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":735
 * 
 *     @property
 *     def types(self):             # <<<<<<<<<<<<<<
 *         """A list of type signatures.
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_5ufunc_5types, 0, __pyx_n_s_ufunc_types, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__229)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 735, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":734
 *         return "<ufunc '%s'>" % self.name
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def types(self):
 *         """A list of type signatures.
 */
  __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_property, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 734, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_8, __pyx_n_s_types, __pyx_t_7) < 0) __PYX_ERR(1, 735, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":749
 *         return types
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Applies the universal function to arguments elementwise.
 * 
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_5ufunc_7__call__, 0, __pyx_n_s_ufunc___call, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__231)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 749, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__Pyx_SetNameInClass(__pyx_t_8, __pyx_n_s_call, __pyx_t_7) < 0) __PYX_ERR(1, 749, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/elementwise.pxi":696
 * 
 * 
 * class ufunc(object):             # <<<<<<<<<<<<<<
 * 
 *     """Universal function.
 */
  __pyx_t_7 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_ufunc, __pyx_tuple__221, __pyx_t_8, NULL, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 696, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ufunc, __pyx_t_7) < 0) __PYX_ERR(1, 696, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":1
 * import collections             # <<<<<<<<<<<<<<
 * import string
 * 
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_collections, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_collections, __pyx_t_2) < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":2
 * import collections
 * import string             # <<<<<<<<<<<<<<
 * 
 * import numpy
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_string, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_string, __pyx_t_2) < 0) __PYX_ERR(5, 2, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":4
 * import string
 * 
 * import numpy             # <<<<<<<<<<<<<<
 * 
 * from cupy.cuda import compiler
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_2) < 0) __PYX_ERR(5, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":6
 * import numpy
 * 
 * from cupy.cuda import compiler             # <<<<<<<<<<<<<<
 * from cupy import util
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_compiler);
  __Pyx_GIVEREF(__pyx_n_s_compiler);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_compiler);
  __pyx_t_8 = __Pyx_Import(__pyx_n_s_cupy_cuda, __pyx_t_2, -1); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_8, __pyx_n_s_compiler); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_compiler, __pyx_t_2) < 0) __PYX_ERR(5, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/reduction.pxi":7
 * 
 * from cupy.cuda import compiler
 * from cupy import util             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_n_s_util);
  __Pyx_GIVEREF(__pyx_n_s_util);
  PyList_SET_ITEM(__pyx_t_8, 0, __pyx_n_s_util);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy, __pyx_t_8, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_util); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_8) < 0) __PYX_ERR(5, 7, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":165
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_simple_reduction_function(
 *         routine, params, args_info, in_arg_dtype, out_arg_dtype, out_types,
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_memoize); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(5, 165, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":166
 * 
 * @util.memoize(for_each_device=True)
 * def _get_simple_reduction_function(             # <<<<<<<<<<<<<<
 *         routine, params, args_info, in_arg_dtype, out_arg_dtype, out_types,
 *         name, block_size, identity, input_expr, output_expr, _preamble,
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_43_get_simple_reduction_function, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":165
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_simple_reduction_function(
 *         routine, params, args_info, in_arg_dtype, out_arg_dtype, out_types,
 */
  __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_simple_reduction_function, __pyx_t_8) < 0) __PYX_ERR(5, 166, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/reduction.pxi":184
 * 
 * 
 * class simple_reduction_function(object):             # <<<<<<<<<<<<<<
 * 
 *     _block_size = 512
 */
  __pyx_t_8 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__234); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_8, __pyx_tuple__234, __pyx_n_s_simple_reduction_function, __pyx_n_s_simple_reduction_function, (PyObject *) NULL, __pyx_n_s_cupy_core_core, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":186
 * class simple_reduction_function(object):
 * 
 *     _block_size = 512             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, name, ops, identity, preamble):
 */
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_block_size_2, __pyx_int_512) < 0) __PYX_ERR(5, 186, __pyx_L1_error)

  /* "cupy/core/reduction.pxi":188
 *     _block_size = 512
 * 
 *     def __init__(self, name, ops, identity, preamble):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self._ops = ops
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_25simple_reduction_function_1__init__, 0, __pyx_n_s_simple_reduction_function___init, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__236)); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_init, __pyx_t_7) < 0) __PYX_ERR(5, 188, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/reduction.pxi":207
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,
 *                  bint keepdims=False):             # <<<<<<<<<<<<<<
 *         cdef list in_args, out_args
 *         cdef tuple in_sahpe, laxis, raxis
 */
  __pyx_t_7 = __Pyx_PyBool_FromLong(((int)0)); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/reduction.pxi":206
 *         self._routine_cache = {}
 * 
 *     def __call__(self, ndarray a, axis=None, dtype=None, ndarray out=None,             # <<<<<<<<<<<<<<
 *                  bint keepdims=False):
 *         cdef list in_args, out_args
 */
  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_None));
  __Pyx_INCREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)Py_None));
  __Pyx_INCREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)Py_None));
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_25simple_reduction_function_3__call__, 0, __pyx_n_s_simple_reduction_function___call, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__238)); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, __pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_call, __pyx_t_7) < 0) __PYX_ERR(5, 206, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/reduction.pxi":184
 * 
 * 
 * class simple_reduction_function(object):             # <<<<<<<<<<<<<<
 * 
 *     _block_size = 512
 */
  __pyx_t_7 = __Pyx_Py3ClassCreate(__pyx_t_8, __pyx_n_s_simple_reduction_function, __pyx_tuple__234, __pyx_t_2, NULL, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_simple_reduction_function, __pyx_t_7) < 0) __PYX_ERR(5, 184, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/reduction.pxi":272
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_reduction_kernel(
 *         params, args_info, types,
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_memoize); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(5, 272, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/reduction.pxi":273
 * 
 * @util.memoize(for_each_device=True)
 * def _get_reduction_kernel(             # <<<<<<<<<<<<<<
 *         params, args_info, types,
 *         name, block_size, reduce_type, identity, map_expr, reduce_expr,
 */
  __pyx_t_8 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_45_get_reduction_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/reduction.pxi":272
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_reduction_kernel(
 *         params, args_info, types,
 */
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_reduction_kernel, __pyx_t_2) < 0) __PYX_ERR(5, 273, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":296
 * 
 * 
 * class ReductionKernel(object):             # <<<<<<<<<<<<<<
 * 
 *     """User-defined reduction kernel.
 */
  __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__241); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_tuple__241, __pyx_n_s_ReductionKernel, __pyx_n_s_ReductionKernel, (PyObject *) NULL, __pyx_n_s_cupy_core_core, __pyx_kp_s_User_defined_reduction_kernel_Th); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/reduction.pxi":327
 * 
 *     """
 *     def __init__(self, in_params, out_params,             # <<<<<<<<<<<<<<
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_15ReductionKernel_1__init__, 0, __pyx_n_s_ReductionKernel___init, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__243)); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, __pyx_tuple__244);
  if (__Pyx_SetNameInClass(__pyx_t_8, __pyx_n_s_init, __pyx_t_7) < 0) __PYX_ERR(5, 327, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/reduction.pxi":357
 *         self.preamble = preamble
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the reduction kernel.
 * 
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_15ReductionKernel_3__call__, 0, __pyx_n_s_ReductionKernel___call, NULL, __pyx_n_s_cupy_core_core, __pyx_d, ((PyObject *)__pyx_codeobj__246)); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__Pyx_SetNameInClass(__pyx_t_8, __pyx_n_s_call, __pyx_t_7) < 0) __PYX_ERR(5, 357, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/reduction.pxi":296
 * 
 * 
 * class ReductionKernel(object):             # <<<<<<<<<<<<<<
 * 
 *     """User-defined reduction kernel.
 */
  __pyx_t_7 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_ReductionKernel, __pyx_tuple__241, __pyx_t_8, NULL, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ReductionKernel, __pyx_t_7) < 0) __PYX_ERR(5, 296, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":1848
 * # =============================================================================
 * 
 * cdef str _id = 'out0 = in0'             # <<<<<<<<<<<<<<
 * 
 * elementwise_copy = create_ufunc(
 */
  __Pyx_INCREF(__pyx_kp_s_out0_in0);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__id);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__id, __pyx_kp_s_out0_in0);
  __Pyx_GIVEREF(__pyx_kp_s_out0_in0);

  /* "cupy/core/core.pyx":1850
 * cdef str _id = 'out0 = in0'
 * 
 * elementwise_copy = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_copy',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/core.pyx":1854
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d', 'F->F', 'D->D'),
 *     'out0 = out0_type(in0)', default_casting='unsafe')             # <<<<<<<<<<<<<<
 * # complex numbers requires out0 = complex<T>(in0)
 * 
 */
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_default_casting, __pyx_n_s_unsafe) < 0) __PYX_ERR(0, 1854, __pyx_L1_error)

  /* "cupy/core/core.pyx":1850
 * cdef str _id = 'out0 = in0'
 * 
 * elementwise_copy = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_copy',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__249, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_elementwise_copy, __pyx_t_7) < 0) __PYX_ERR(0, 1850, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":1857
 * # complex numbers requires out0 = complex<T>(in0)
 * 
 * elementwise_copy_where = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_copy_where',
 *     ('??->?', 'b?->b', 'B?->B', 'h?->h', 'H?->H', 'i?->i', 'I?->I', 'l?->l',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1857, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/core.pyx":1861
 *     ('??->?', 'b?->b', 'B?->B', 'h?->h', 'H?->H', 'i?->i', 'I?->I', 'l?->l',
 *      'L?->L', 'q?->q', 'Q?->Q', 'e?->e', 'f?->f', 'd?->d', 'F?->F', 'D?->D'),
 *     'if (in1) out0 = in0', default_casting='unsafe')             # <<<<<<<<<<<<<<
 * 
 * cdef str _divmod_float = '''
 */
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1861, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_default_casting, __pyx_n_s_unsafe) < 0) __PYX_ERR(0, 1861, __pyx_L1_error)

  /* "cupy/core/core.pyx":1857
 * # complex numbers requires out0 = complex<T>(in0)
 * 
 * elementwise_copy_where = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_copy_where',
 *     ('??->?', 'b?->b', 'B?->B', 'h?->h', 'H?->H', 'i?->i', 'I?->I', 'l?->l',
 */
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__251, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1857, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_elementwise_copy_where, __pyx_t_2) < 0) __PYX_ERR(0, 1857, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":1863
 *     'if (in1) out0 = in0', default_casting='unsafe')
 * 
 * cdef str _divmod_float = '''             # <<<<<<<<<<<<<<
 *     out0_type a = _floor_divide(in0, in1);
 *     out0 = a;
 */
  __Pyx_INCREF(__pyx_kp_s_out0_type_a__floor_divide_in0_i);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__divmod_float);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__divmod_float, __pyx_kp_s_out0_type_a__floor_divide_in0_i);
  __Pyx_GIVEREF(__pyx_kp_s_out0_type_a__floor_divide_in0_i);

  /* "cupy/core/core.pyx":1873
 *     ('bb->bb', 'BB->BB', 'hh->hh', 'HH->HH', 'ii->ii', 'II->II', 'll->ll',
 *      'LL->LL', 'qq->qq', 'QQ->QQ',
 *      ('ee->ee', _divmod_float),             # <<<<<<<<<<<<<<
 *      ('ff->ff', _divmod_float),
 *      ('dd->dd', _divmod_float)),
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1873, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_kp_s_ee_ee);
  __Pyx_GIVEREF(__pyx_kp_s_ee_ee);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_s_ee_ee);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__divmod_float);
  __Pyx_GIVEREF(__pyx_v_4cupy_4core_4core__divmod_float);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_4cupy_4core_4core__divmod_float);

  /* "cupy/core/core.pyx":1874
 *      'LL->LL', 'qq->qq', 'QQ->QQ',
 *      ('ee->ee', _divmod_float),
 *      ('ff->ff', _divmod_float),             # <<<<<<<<<<<<<<
 *      ('dd->dd', _divmod_float)),
 *     '''
 */
  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1874, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_kp_s_ff_ff);
  __Pyx_GIVEREF(__pyx_kp_s_ff_ff);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_kp_s_ff_ff);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__divmod_float);
  __Pyx_GIVEREF(__pyx_v_4cupy_4core_4core__divmod_float);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_4cupy_4core_4core__divmod_float);

  /* "cupy/core/core.pyx":1875
 *      ('ee->ee', _divmod_float),
 *      ('ff->ff', _divmod_float),
 *      ('dd->dd', _divmod_float)),             # <<<<<<<<<<<<<<
 *     '''
 *     if (in1 == 0) {
 */
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1875, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_kp_s_dd_dd);
  __Pyx_GIVEREF(__pyx_kp_s_dd_dd);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_kp_s_dd_dd);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__divmod_float);
  __Pyx_GIVEREF(__pyx_v_4cupy_4core_4core__divmod_float);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_4cupy_4core_4core__divmod_float);

  /* "cupy/core/core.pyx":1871
 * divmod = create_ufunc(
 *     'cupy_divmod',
 *     ('bb->bb', 'BB->BB', 'hh->hh', 'HH->HH', 'ii->ii', 'II->II', 'll->ll',             # <<<<<<<<<<<<<<
 *      'LL->LL', 'qq->qq', 'QQ->QQ',
 *      ('ee->ee', _divmod_float),
 */
  __pyx_t_1 = PyTuple_New(13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1871, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_kp_s_bb_bb);
  __Pyx_GIVEREF(__pyx_kp_s_bb_bb);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_s_bb_bb);
  __Pyx_INCREF(__pyx_kp_s_BB_BB);
  __Pyx_GIVEREF(__pyx_kp_s_BB_BB);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_s_BB_BB);
  __Pyx_INCREF(__pyx_kp_s_hh_hh);
  __Pyx_GIVEREF(__pyx_kp_s_hh_hh);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_s_hh_hh);
  __Pyx_INCREF(__pyx_kp_s_HH_HH);
  __Pyx_GIVEREF(__pyx_kp_s_HH_HH);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_kp_s_HH_HH);
  __Pyx_INCREF(__pyx_kp_s_ii_ii);
  __Pyx_GIVEREF(__pyx_kp_s_ii_ii);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_s_ii_ii);
  __Pyx_INCREF(__pyx_kp_s_II_II);
  __Pyx_GIVEREF(__pyx_kp_s_II_II);
  PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_kp_s_II_II);
  __Pyx_INCREF(__pyx_kp_s_ll_ll);
  __Pyx_GIVEREF(__pyx_kp_s_ll_ll);
  PyTuple_SET_ITEM(__pyx_t_1, 6, __pyx_kp_s_ll_ll);
  __Pyx_INCREF(__pyx_kp_s_LL_LL);
  __Pyx_GIVEREF(__pyx_kp_s_LL_LL);
  PyTuple_SET_ITEM(__pyx_t_1, 7, __pyx_kp_s_LL_LL);
  __Pyx_INCREF(__pyx_kp_s_qq_qq);
  __Pyx_GIVEREF(__pyx_kp_s_qq_qq);
  PyTuple_SET_ITEM(__pyx_t_1, 8, __pyx_kp_s_qq_qq);
  __Pyx_INCREF(__pyx_kp_s_QQ_QQ);
  __Pyx_GIVEREF(__pyx_kp_s_QQ_QQ);
  PyTuple_SET_ITEM(__pyx_t_1, 9, __pyx_kp_s_QQ_QQ);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 10, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_1, 11, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_1, 12, __pyx_t_7);
  __pyx_t_2 = 0;
  __pyx_t_8 = 0;
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":1869
 * 
 * 
 * divmod = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divmod',
 *     ('bb->bb', 'BB->BB', 'hh->hh', 'HH->HH', 'ii->ii', 'II->II', 'll->ll',
 */
  __pyx_t_16.__pyx_n = 1;
  __pyx_t_16.routine = __pyx_kp_s_if_in1_0_out0_0_out1_0_else_out;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_divmod, __pyx_t_1, 0, &__pyx_t_16); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1869, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_divmod, __pyx_t_7) < 0) __PYX_ERR(0, 1869, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":1887
 * 
 * 
 * cdef _min_max_preamble = '''             # <<<<<<<<<<<<<<
 * template <typename T>
 * struct min_max_st{
 */
  __Pyx_INCREF(__pyx_kp_s_template_typename_T_struct_min);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__min_max_preamble);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__min_max_preamble, __pyx_kp_s_template_typename_T_struct_min);
  __Pyx_GIVEREF(__pyx_kp_s_template_typename_T_struct_min);

  /* "cupy/core/core.pyx":1989
 *     ('min_max_st<type_in0_raw>(in0)', 'my_min(a, b)', 'out0 = a.value',
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_7 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_7);

  /* "cupy/core/core.pyx":1980
 * 
 * 
 * _amin = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_min',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__259;
  __pyx_t_17.identity = Py_None;
  __pyx_t_17.preamble = __pyx_t_7;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_min, __pyx_tuple__258, 0, &__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1980, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_amin, __pyx_t_1) < 0) __PYX_ERR(0, 1980, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2001
 *     ('min_max_st<type_in0_raw>(in0)', 'my_max(a, b)', 'out0 = a.value',
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_1);

  /* "cupy/core/core.pyx":1992
 * 
 * 
 * _amax = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_max',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__267;
  __pyx_t_17.identity = Py_None;
  __pyx_t_17.preamble = __pyx_t_1;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_max, __pyx_tuple__266, 0, &__pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_amax, __pyx_t_7) < 0) __PYX_ERR(0, 1992, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2010
 *     ('min_max_st<type_in0_raw>(in0)', 'my_min(a, b)', 'out0 = a.value',
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_7 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_7);

  /* "cupy/core/core.pyx":2004
 * 
 * 
 * nanmin = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_nanmin',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__269;
  __pyx_t_17.identity = Py_None;
  __pyx_t_17.preamble = __pyx_t_7;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_nanmin, __pyx_tuple__268, 0, &__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2004, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_nanmin, __pyx_t_1) < 0) __PYX_ERR(0, 2004, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2019
 *     ('min_max_st<type_in0_raw>(in0)', 'my_max(a, b)', 'out0 = a.value',
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_1);

  /* "cupy/core/core.pyx":2013
 * 
 * 
 * nanmax = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_nanmax',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__271;
  __pyx_t_17.identity = Py_None;
  __pyx_t_17.preamble = __pyx_t_1;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_nanmax, __pyx_tuple__270, 0, &__pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2013, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_nanmax, __pyx_t_7) < 0) __PYX_ERR(0, 2013, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2031
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmin(a, b)', 'out0 = a.index',
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_7 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_7);

  /* "cupy/core/core.pyx":2022
 * 
 * 
 * cdef _argmin = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_argmin',
 *     ('?->q', 'B->q', 'h->q', 'H->q', 'i->q', 'I->q', 'l->q', 'L->q',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__279;
  __pyx_t_17.identity = Py_None;
  __pyx_t_17.preamble = __pyx_t_7;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_argmin, __pyx_tuple__278, 0, &__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2022, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__argmin);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__argmin, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2043
 *     ('min_max_st<type_in0_raw>(in0, _J)', 'my_argmax(a, b)', 'out0 = a.index',
 *      'min_max_st<type_in0_raw>'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_1);

  /* "cupy/core/core.pyx":2034
 * 
 * 
 * cdef _argmax = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_argmax',
 *     ('?->q', 'B->q', 'h->q', 'H->q', 'i->q', 'I->q', 'l->q', 'L->q',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__287;
  __pyx_t_17.identity = Py_None;
  __pyx_t_17.preamble = __pyx_t_1;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_argmax, __pyx_tuple__286, 0, &__pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2034, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__argmax);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__argmax, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2153
 * # -----------------------------------------------------------------------------
 * 
 * def _has_element(vector.vector[Py_ssize_t] source, Py_ssize_t n):             # <<<<<<<<<<<<<<
 *     for elem in source:
 *         if elem == n:
 */
  __pyx_t_7 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_55_has_element, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_has_element, __pyx_t_7) < 0) __PYX_ERR(0, 2153, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2228
 * 
 * 
 * def array_split(ndarray ary, indices_or_sections, Py_ssize_t axis):             # <<<<<<<<<<<<<<
 * 
 *     cdef Py_ssize_t i, ndim, size, each_size, index, prev, offset, stride
 */
  __pyx_t_7 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_63array_split, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_array_split, __pyx_t_7) < 0) __PYX_ERR(0, 2228, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2274
 * 
 * 
 * cdef Py_ssize_t PY_SSIZE_T_MAX = sys.maxsize             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_maxsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2274, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_4cupy_4core_4core_PY_SSIZE_T_MAX = __pyx_t_12;

  /* "cupy/core/core.pyx":2591
 * 
 * 
 * cdef _concatenate_kernel_same_size = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw P x, int64 base',
 *     'T y',
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__292, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__concatenate_kernel_same_size);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__concatenate_kernel_same_size, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2639
 *     ''',
 *     'cupy_concatenate',
 *     reduce_dims=False             # <<<<<<<<<<<<<<
 * )
 * 
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2639, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reduce_dims, Py_False) < 0) __PYX_ERR(0, 2639, __pyx_L1_error)

  /* "cupy/core/core.pyx":2605
 * 
 * 
 * cdef _concatenate_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     '''raw P x, int32 axis, raw int64 cum_sizes, raw int64 x_strides''',
 *     'T y',
 */
  __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__293, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2605, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__concatenate_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__concatenate_kernel, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2681
 * 
 * 
 * bitwise_and = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_and', '&', False,
 *     '''Computes the bitwise AND of two arrays elementwise.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Computes_the_bitwise_AND_of_two;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_bitwise_and, __pyx_kp_s__294, Py_False, 0, &__pyx_t_18); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_and, __pyx_t_7) < 0) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2692
 * 
 * 
 * bitwise_or = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_or', '|', False,
 *     '''Computes the bitwise OR of two arrays elementwise.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Computes_the_bitwise_OR_of_two_a;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_bitwise_or, __pyx_kp_s__295, Py_False, 0, &__pyx_t_18); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2692, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_or, __pyx_t_7) < 0) __PYX_ERR(0, 2692, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2703
 * 
 * 
 * bitwise_xor = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_xor', '^', False,
 *     '''Computes the bitwise XOR of two arrays elementwise.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Computes_the_bitwise_XOR_of_two;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_bitwise_xor, __pyx_kp_s__296, Py_False, 0, &__pyx_t_18); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2703, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_xor, __pyx_t_7) < 0) __PYX_ERR(0, 2703, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2714
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2714, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/core.pyx":2719
 *      'l->l', 'L->L', 'q->q', 'Q->Q'),
 *     'out0 = ~in0',
 *     doc='''Computes the bitwise NOT of an array elementwise.             # <<<<<<<<<<<<<<
 * 
 *     Only integer and boolean arrays are handled.
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2719, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_doc, __pyx_kp_s_Computes_the_bitwise_NOT_of_an_a) < 0) __PYX_ERR(0, 2719, __pyx_L1_error)

  /* "cupy/core/core.pyx":2714
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__299, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2714, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_invert, __pyx_t_8) < 0) __PYX_ERR(0, 2714, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2728
 * 
 * 
 * left_shift = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'left_shift', '<<', True,
 *     '''Shifts the bits of each integer element to the left.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Shifts_the_bits_of_each_integer;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_left_shift, __pyx_kp_s__300, Py_True, 0, &__pyx_t_18); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_left_shift, __pyx_t_8) < 0) __PYX_ERR(0, 2728, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2739
 * 
 * 
 * right_shift = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'right_shift', '>>', True,
 *     '''Shifts the bits of each integer element to the right.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Shifts_the_bits_of_each_integer_2;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_right_shift, __pyx_kp_s__301, Py_True, 0, &__pyx_t_18); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2739, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_right_shift, __pyx_t_8) < 0) __PYX_ERR(0, 2739, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2921
 * 
 * 
 * cdef _take_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 cdim, int32 rdim, int32 adim, S index_range',
 *     'T out',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__302, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2921, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__take_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__take_kernel, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2935
 * 
 * 
 * cdef _take_kernel_0axis = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 rdim, S index_range',
 *     'T out',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__303, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2935, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__take_kernel_0axis);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__take_kernel_0axis, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2947
 * 
 * 
 * cdef _choose_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'S a, raw T choices, int32 n_channel',
 *     'T y',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__304, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2947, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__choose_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__choose_kernel, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2954
 * 
 * 
 * cdef _choose_clip_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'S a, raw T choices, int32 n_channel, int32 n',
 *     'T y',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__305, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2954, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__choose_clip_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__choose_clip_kernel, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2969
 * 
 * 
 * cdef _scatter_update_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'T v, S indices, int32 cdim, int32 rdim, int32 adim',
 *     'raw T a',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__306, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2969, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__scatter_update_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__scatter_update_kernel, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2982
 * 
 * 
 * cdef _scatter_add_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T v, S indices, int32 cdim, int32 rdim, int32 adim',
 *     'raw T a',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__307, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2982, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__scatter_add_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__scatter_add_kernel, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2995
 * 
 * 
 * cdef _scatter_update_mask_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T v, bool mask, S mask_scanned',
 *     'T a',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__308, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2995, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__scatter_update_mask_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__scatter_update_mask_kernel, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3002
 * 
 * 
 * cdef _scatter_add_mask_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T v, bool mask, S mask_scanned',
 *     'T a',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__309, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3002, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__scatter_add_mask_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__scatter_add_mask_kernel, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3009
 * 
 * 
 * cdef _getitem_mask_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'T a, bool mask, S mask_scanned',
 *     'raw T out',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__310, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3009, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__getitem_mask_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__getitem_mask_kernel, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":3769
 * 
 * 
 * cdef _cuda_runtime_version = None             # <<<<<<<<<<<<<<
 * cdef _tensordot_core_mul_sum = ReductionKernel(
 *     'S x, T y', 'U out',
 */
  __Pyx_INCREF(Py_None);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cuda_runtime_version);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cuda_runtime_version, Py_None);
  __Pyx_GIVEREF(Py_None);

  /* "cupy/core/core.pyx":3770
 * 
 * cdef _cuda_runtime_version = None
 * cdef _tensordot_core_mul_sum = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T y', 'U out',
 *     'static_cast<U>(x) * static_cast<U>(y)',
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_ReductionKernel); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__311, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__tensordot_core_mul_sum);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__tensordot_core_mul_sum, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3940
 * 
 * 
 * greater = create_comparison(             # <<<<<<<<<<<<<<
 *     'greater', '>',
 *     '''Tests elementwise if ``x1 > x2``.
 */
  __pyx_t_19.__pyx_n = 1;
  __pyx_t_19.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_greater, __pyx_kp_s__312, 0, &__pyx_t_19); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3940, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_greater, __pyx_t_1) < 0) __PYX_ERR(0, 3940, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3949
 * 
 * 
 * greater_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'greater_equal', '>=',
 *     '''Tests elementwise if ``x1 >= x2``.
 */
  __pyx_t_19.__pyx_n = 1;
  __pyx_t_19.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_2;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_greater_equal, __pyx_kp_s__313, 0, &__pyx_t_19); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3949, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_greater_equal, __pyx_t_1) < 0) __PYX_ERR(0, 3949, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3958
 * 
 * 
 * less = create_comparison(             # <<<<<<<<<<<<<<
 *     'less', '<',
 *     '''Tests elementwise if ``x1 < x2``.
 */
  __pyx_t_19.__pyx_n = 1;
  __pyx_t_19.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_3;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_less, __pyx_kp_s__314, 0, &__pyx_t_19); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3958, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_less, __pyx_t_1) < 0) __PYX_ERR(0, 3958, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3967
 * 
 * 
 * less_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'less_equal', '<=',
 *     '''Tests elementwise if ``x1 <= x2``.
 */
  __pyx_t_19.__pyx_n = 1;
  __pyx_t_19.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_4;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_less_equal, __pyx_kp_s__315, 0, &__pyx_t_19); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3967, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_less_equal, __pyx_t_1) < 0) __PYX_ERR(0, 3967, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3976
 * 
 * 
 * equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'equal', '==',
 *     '''Tests elementwise if ``x1 == x2``.
 */
  __pyx_t_19.__pyx_n = 2;
  __pyx_t_19.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_5;
  __pyx_t_19.require_sortable_dtype = Py_False;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_equal, __pyx_kp_s__316, 0, &__pyx_t_19); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3976, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_equal, __pyx_t_1) < 0) __PYX_ERR(0, 3976, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3985
 * 
 * 
 * not_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'not_equal', '!=',
 *     '''Tests elementwise if ``x1 != x2``.
 */
  __pyx_t_19.__pyx_n = 2;
  __pyx_t_19.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_6;
  __pyx_t_19.require_sortable_dtype = Py_False;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_not_equal, __pyx_kp_s__317, 0, &__pyx_t_19); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3985, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_not_equal, __pyx_t_1) < 0) __PYX_ERR(0, 3985, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":3994
 * 
 * 
 * _all = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_all',
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__319;
  __pyx_t_17.identity = __pyx_n_s_true;
  __pyx_t_17.preamble = __pyx_kp_s__6;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_all, __pyx_tuple__318, 0, &__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_all_2, __pyx_t_1) < 0) __PYX_ERR(0, 3994, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4002
 * 
 * 
 * _any = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_any',
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 */
  __pyx_t_17.__pyx_n = 3;
  __pyx_t_17.routine = __pyx_tuple__321;
  __pyx_t_17.identity = __pyx_n_s_false;
  __pyx_t_17.preamble = __pyx_kp_s__6;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_any, __pyx_tuple__320, 0, &__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4002, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_any_2, __pyx_t_1) < 0) __PYX_ERR(0, 4002, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4014
 * # -----------------------------------------------------------------------------
 * 
 * _sum_auto_dtype = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_sum',
 *     ('?->l', 'b->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',
 */
  __pyx_t_17.__pyx_n = 2;
  __pyx_t_17.routine = __pyx_tuple__325;
  __pyx_t_17.identity = __pyx_int_0;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_sum, __pyx_tuple__324, 0, &__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4014, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sum_auto_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 4014, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4023
 * 
 * 
 * _sum_keep_dtype = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_sum_with_dtype',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_17.__pyx_n = 2;
  __pyx_t_17.routine = __pyx_tuple__329;
  __pyx_t_17.identity = __pyx_int_0;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_sum_with_dtype, __pyx_tuple__328, 0, &__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4023, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sum_keep_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 4023, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4032
 * 
 * 
 * _prod_auto_dtype = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_prod',
 *     ('?->l', 'b->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',
 */
  __pyx_t_17.__pyx_n = 2;
  __pyx_t_17.routine = __pyx_tuple__333;
  __pyx_t_17.identity = __pyx_int_1;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_prod, __pyx_tuple__332, 0, &__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4032, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_prod_auto_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 4032, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4041
 * 
 * 
 * _prod_keep_dtype = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_prod_with_dtype',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_17.__pyx_n = 2;
  __pyx_t_17.routine = __pyx_tuple__337;
  __pyx_t_17.identity = __pyx_int_1;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_prod_with_dtype, __pyx_tuple__336, 0, &__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4041, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_prod_keep_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 4041, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4061
 * 
 * 
 * add = create_arithmetic(             # <<<<<<<<<<<<<<
 *     'add', '+', '|',
 *     '''Adds two arrays elementwise.
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_create_arithmetic(__pyx_n_s_add, __pyx_kp_s__338, __pyx_kp_s__295, __pyx_kp_s_Adds_two_arrays_elementwise_seea); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4061, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_add, __pyx_t_1) < 0) __PYX_ERR(0, 4061, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4070
 * 
 * 
 * conj = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_conj',
 *     ('b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L', 'q->q',
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4070, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":4077
 *      ('D->D', 'out0 = conj(in0)')),
 *     'out0 = in0',
 *     doc='''Returns the complex conjugate, element-wise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.conj`
 */
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4077, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Returns_the_complex_conjugate_el) < 0) __PYX_ERR(0, 4077, __pyx_L1_error)

  /* "cupy/core/core.pyx":4070
 * 
 * 
 * conj = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_conj',
 *     ('b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L', 'q->q',
 */
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__342, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4070, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_conj, __pyx_t_7) < 0) __PYX_ERR(0, 4070, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4084
 * 
 * 
 * angle = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_angle',
 *     ('?->d', 'e->e', 'f->f', 'd->d',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4084, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/core.pyx":4090
 *      ('D->d', 'out0 = arg(in0)')),
 *     'out0 = in0 >= 0 ? 0 : M_PI',
 *     doc='''Returns the angle of the complex argument.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.angle`
 */
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Returns_the_angle_of_the_complex) < 0) __PYX_ERR(0, 4090, __pyx_L1_error)

  /* "cupy/core/core.pyx":4084
 * 
 * 
 * angle = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_angle',
 *     ('?->d', 'e->e', 'f->f', 'd->d',
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__346, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4084, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_angle, __pyx_t_1) < 0) __PYX_ERR(0, 4084, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4097
 * 
 * 
 * real = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_real',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4097, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":4104
 *      ('D->d', 'out0 = in0.real()')),
 *     'out0 = in0',
 *     doc='''Returns the real part of the elements of the array.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.real`
 */
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Returns_the_real_part_of_the_ele) < 0) __PYX_ERR(0, 4104, __pyx_L1_error)

  /* "cupy/core/core.pyx":4097
 * 
 * 
 * real = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_real',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__350, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4097, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_real, __pyx_t_7) < 0) __PYX_ERR(0, 4097, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4110
 *     ''')
 * 
 * _real_setter = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_real_setter',
 *     ('f->F', 'd->D'),
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/core.pyx":4114
 *     ('f->F', 'd->D'),
 *     'out0.real(in0)',
 *     doc='''Sets the real part of the elements of the array.             # <<<<<<<<<<<<<<
 *     ''')
 * 
 */
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Sets_the_real_part_of_the_elemen) < 0) __PYX_ERR(0, 4114, __pyx_L1_error)

  /* "cupy/core/core.pyx":4110
 *     ''')
 * 
 * _real_setter = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_real_setter',
 *     ('f->F', 'd->D'),
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__352, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_real_setter, __pyx_t_1) < 0) __PYX_ERR(0, 4110, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4118
 * 
 * 
 * imag = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_imag',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":4125
 *      ('D->d', 'out0 = in0.imag()')),
 *     'out0 = 0',
 *     doc='''Returns the imaginary part of the elements of the array.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.imag`
 */
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Returns_the_imaginary_part_of_th) < 0) __PYX_ERR(0, 4125, __pyx_L1_error)

  /* "cupy/core/core.pyx":4118
 * 
 * 
 * imag = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_imag',
 *     ('?->?', 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I', 'l->l', 'L->L',
 */
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__356, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_imag, __pyx_t_7) < 0) __PYX_ERR(0, 4118, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4132
 * 
 * 
 * _imag_setter = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_imag_setter',
 *     ('f->F', 'd->D'),
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/core.pyx":4136
 *     ('f->F', 'd->D'),
 *     'out0.imag(in0)',
 *     doc='''Sets the imaginary part of the elements of the array.             # <<<<<<<<<<<<<<
 *     ''')
 * 
 */
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Sets_the_imaginary_part_of_the_e) < 0) __PYX_ERR(0, 4136, __pyx_L1_error)

  /* "cupy/core/core.pyx":4132
 * 
 * 
 * _imag_setter = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_imag_setter',
 *     ('f->F', 'd->D'),
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__358, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_imag_setter, __pyx_t_1) < 0) __PYX_ERR(0, 4132, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4140
 * 
 * 
 * negative = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_negative',
 *     (('?->?', 'out0 = !in0'),
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":4146
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d', 'F->F', 'D->D'),
 *     'out0 = -in0',
 *     doc='''Takes numerical negative elementwise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.negative`
 */
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Takes_numerical_negative_element) < 0) __PYX_ERR(0, 4146, __pyx_L1_error)

  /* "cupy/core/core.pyx":4140
 * 
 * 
 * negative = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_negative',
 *     (('?->?', 'out0 = !in0'),
 */
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__361, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_negative, __pyx_t_7) < 0) __PYX_ERR(0, 4140, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4153
 * 
 * 
 * multiply = create_arithmetic(             # <<<<<<<<<<<<<<
 *     'multiply', '*', '&',
 *     '''Multiplies two arrays elementwise.
 */
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_arithmetic(__pyx_n_s_multiply, __pyx_kp_s__362, __pyx_kp_s__294, __pyx_kp_s_Multiplies_two_arrays_elementwis); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_multiply, __pyx_t_7) < 0) __PYX_ERR(0, 4153, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4162
 * 
 * 
 * divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/core.pyx":4172
 *      ('DD->D', 'out0 = in0 / in1')),
 *     'out0 = in1 == 0 ? 0 : floor((double)in0 / (double)in1)',
 *     doc='''Divides arguments elementwise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.divide`
 */
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Divides_arguments_elementwise_se) < 0) __PYX_ERR(0, 4172, __pyx_L1_error)

  /* "cupy/core/core.pyx":4162
 * 
 * 
 * divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__369, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_divide, __pyx_t_1) < 0) __PYX_ERR(0, 4162, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4179
 * 
 * 
 * power = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_power',
 *     ('??->b', 'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":4189
 *      ('DD->D', 'out0 = pow(in0, in1)')),
 *     'out0 = rint(pow((double)in0, (double)in1))',
 *     doc='''Computes ``x1 ** x2`` elementwise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.power`
 */
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Computes_x1_x2_elementwise_seeal) < 0) __PYX_ERR(0, 4189, __pyx_L1_error)

  /* "cupy/core/core.pyx":4179
 * 
 * 
 * power = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_power',
 *     ('??->b', 'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
 */
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__376, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_power, __pyx_t_7) < 0) __PYX_ERR(0, 4179, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4196
 * 
 * 
 * subtract = create_arithmetic(             # <<<<<<<<<<<<<<
 *     'subtract', '-', '^',
 *     '''Subtracts arguments elementwise.
 */
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_arithmetic(__pyx_n_s_subtract, __pyx_kp_s__377, __pyx_kp_s__296, __pyx_kp_s_Subtracts_arguments_elementwise); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_subtract, __pyx_t_7) < 0) __PYX_ERR(0, 4196, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4205
 * 
 * 
 * true_divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_true_divide',
 *     ('bb->d', 'BB->d', 'hh->d', 'HH->d', 'ii->d', 'II->d', 'll->d', 'LL->d',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/core.pyx":4210
 *      'qq->d', 'QQ->d', 'ee->e', 'ff->f', 'dd->d', 'FF->F', 'DD->D'),
 *     'out0 = (out0_type)in0 / (out0_type)in1',
 *     doc='''Elementwise true division (i.e. division as floating values).             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.true_divide`
 */
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4210, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Elementwise_true_division_i_e_di) < 0) __PYX_ERR(0, 4210, __pyx_L1_error)

  /* "cupy/core/core.pyx":4205
 * 
 * 
 * true_divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_true_divide',
 *     ('bb->d', 'BB->d', 'hh->d', 'HH->d', 'ii->d', 'II->d', 'll->d', 'LL->d',
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__379, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_true_divide, __pyx_t_1) < 0) __PYX_ERR(0, 4205, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4217
 * 
 * 
 * if six.PY3:             # <<<<<<<<<<<<<<
 *     divide = true_divide
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_PY3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 4217, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__pyx_t_11) {

    /* "cupy/core/core.pyx":4218
 * 
 * if six.PY3:
 *     divide = true_divide             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_true_divide); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4218, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_divide, __pyx_t_8) < 0) __PYX_ERR(0, 4218, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":4217
 * 
 * 
 * if six.PY3:             # <<<<<<<<<<<<<<
 *     divide = true_divide
 * 
 */
  }

  /* "cupy/core/core.pyx":4221
 * 
 * 
 * floor_divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_floor_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/core.pyx":4226
 *      'qq->q', 'QQ->Q', 'ee->e', 'ff->f', 'dd->d'),
 *     'out0 = _floor_divide(in0, in1)',
 *     doc='''Elementwise floor division (i.e. integer quotient).             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.floor_divide`
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4226, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_doc, __pyx_kp_s_Elementwise_floor_division_i_e_i) < 0) __PYX_ERR(0, 4226, __pyx_L1_error)

  /* "cupy/core/core.pyx":4221
 * 
 * 
 * floor_divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_floor_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__381, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_floor_divide, __pyx_t_7) < 0) __PYX_ERR(0, 4221, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4233
 * 
 * 
 * remainder = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_remainder',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/core.pyx":4241
 *      ('dd->d', 'out0 = in0 - _floor_divide(in0, in1) * in1')),
 *     'out0 = (in0 - _floor_divide(in0, in1) * in1) * (in1 != 0)',
 *     doc='''Computes the remainder of Python division elementwise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.remainder`
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_doc, __pyx_kp_s_Computes_the_remainder_of_Python) < 0) __PYX_ERR(0, 4241, __pyx_L1_error)

  /* "cupy/core/core.pyx":4233
 * 
 * 
 * remainder = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_remainder',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__386, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_remainder, __pyx_t_8) < 0) __PYX_ERR(0, 4233, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":4248
 * 
 * 
 * absolute = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/core.pyx":4260
 *      ('D->d', 'out0 = abs(in0)')),
 *     'out0 = in0 > 0 ? in0 : -in0',
 *     doc='''Elementwise absolute value function.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.absolute`
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_doc, __pyx_kp_s_Elementwise_absolute_value_funct) < 0) __PYX_ERR(0, 4260, __pyx_L1_error)

  /* "cupy/core/core.pyx":4248
 * 
 * 
 * absolute = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),
 */
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__399, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_absolute, __pyx_t_7) < 0) __PYX_ERR(0, 4248, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4267
 * 
 * 
 * sqrt = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_sqrt',
 *     ('e->e', 'f->f', 'd->d', 'F->F', 'D->D'),
 */
  __pyx_t_16.__pyx_n = 1;
  __pyx_t_16.routine = __pyx_kp_s_out0_sqrt_in0;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_sqrt, __pyx_tuple__400, 0, &__pyx_t_16); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sqrt, __pyx_t_7) < 0) __PYX_ERR(0, 4267, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4273
 * 
 * 
 * _clip = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_clip',
 *     ('???->?', 'bbb->b', 'BBB->B', 'hhh->h', 'HHH->H', 'iii->i', 'III->I',
 */
  __pyx_t_16.__pyx_n = 1;
  __pyx_t_16.routine = __pyx_kp_s_out0_in0_in1_in1_in0_in2_in2_in0;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_clip, __pyx_tuple__402, 0, &__pyx_t_16); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_clip_2, __pyx_t_7) < 0) __PYX_ERR(0, 4273, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4315
 * 
 * 
 * cdef _var_core = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T mean, T alpha', 'T out',
 *     '(x - mean) * (x - mean)',
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_ReductionKernel); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__403, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__var_core);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__var_core, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4320
 *     'a + b', 'out = alpha * a', '0', '_var_core')
 * 
 * cdef _var_core_out = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T mean, T alpha', 'U out',
 *     '(x - mean) * (x - mean)',
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ReductionKernel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__404, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__var_core_out);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__var_core_out, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4326
 * 
 * # TODO(okuta) needs cast
 * cdef _mean = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_mean',
 *     ('?->d', 'B->d', 'h->d', 'H->d', 'i->d', 'I->d', 'l->d', 'L->d',
 */
  __pyx_t_17.__pyx_n = 1;
  __pyx_t_17.routine = __pyx_tuple__408;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_mean, __pyx_tuple__407, 0, &__pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__mean);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__mean, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4340
 * # -----------------------------------------------------------------------------
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _inclusive_scan_kernel(dtype, block_size):
 *     """return Prefix Sum(Scan) cuda kernel
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_memoize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(0, 4340, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4341
 * 
 * @util.memoize(for_each_device=True)
 * def _inclusive_scan_kernel(dtype, block_size):             # <<<<<<<<<<<<<<
 *     """return Prefix Sum(Scan) cuda kernel
 * 
 */
  __pyx_t_7 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_119_inclusive_scan_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/core.pyx":4340
 * # -----------------------------------------------------------------------------
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _inclusive_scan_kernel(dtype, block_size):
 *     """return Prefix Sum(Scan) cuda kernel
 */
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_inclusive_scan_kernel_2, __pyx_t_1) < 0) __PYX_ERR(0, 4341, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4407
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _add_scan_blocked_sum_kernel(dtype):
 *     name = "add_scan_blocked_sum_kernel"
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_memoize); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(0, 4407, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4408
 * 
 * @util.memoize(for_each_device=True)
 * def _add_scan_blocked_sum_kernel(dtype):             # <<<<<<<<<<<<<<
 *     name = "add_scan_blocked_sum_kernel"
 *     dtype = _get_typename(dtype)
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_121_add_scan_blocked_sum_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":4407
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _add_scan_blocked_sum_kernel(dtype):
 *     name = "add_scan_blocked_sum_kernel"
 */
  __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_add_scan_blocked_sum_kernel_2, __pyx_t_7) < 0) __PYX_ERR(0, 4408, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4427
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _nonzero_1d_kernel(src_dtype, index_dtype):
 *     name = "nonzero_1d_kernel"
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_memoize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(0, 4427, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4428
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_1d_kernel(src_dtype, index_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_1d_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */
  __pyx_t_7 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_123_nonzero_1d_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/core.pyx":4427
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _nonzero_1d_kernel(src_dtype, index_dtype):
 *     name = "nonzero_1d_kernel"
 */
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_nonzero_1d_kernel, __pyx_t_1) < 0) __PYX_ERR(0, 4428, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4450
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):
 *     name = "nonzero_kernel"
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4450, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_memoize); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4450, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4450, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(0, 4450, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4450, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4451
 * 
 * @util.memoize(for_each_device=True)
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):             # <<<<<<<<<<<<<<
 *     name = "nonzero_kernel"
 *     src_dtype = _get_typename(src_dtype)
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_125_nonzero_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":4450
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _nonzero_kernel(src_dtype, src_ndim, index_dtype, dst_dtype):
 *     name = "nonzero_kernel"
 */
  __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4450, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_nonzero_kernel, __pyx_t_7) < 0) __PYX_ERR(0, 4451, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4528
 * # -----------------------------------------------------------------------------
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _partition_kernel(dtype):
 *     name = 'partition_kernel'
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_memoize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_for_each_device, Py_True) < 0) __PYX_ERR(0, 4528, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":4529
 * 
 * @util.memoize(for_each_device=True)
 * def _partition_kernel(dtype):             # <<<<<<<<<<<<<<
 *     name = 'partition_kernel'
 *     merge_kernel = 'partition_merge_kernel'
 */
  __pyx_t_7 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_129_partition_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4529, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/core.pyx":4528
 * # -----------------------------------------------------------------------------
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _partition_kernel(dtype):
 *     name = 'partition_kernel'
 */
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_partition_kernel, __pyx_t_1) < 0) __PYX_ERR(0, 4529, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Indexer(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x6d47339:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_131__pyx_unpickle_Indexer, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Indexer, __pyx_t_1) < 0) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":9
 *         __pyx_unpickle_Indexer__set_state(<Indexer> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Indexer__set_state(Indexer __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.shape = __pyx_state[0]; __pyx_result.size = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_133__pyx_unpickle_ParameterInfo, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_ParameterInfo, __pyx_t_1) < 0) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ElementwiseKernel(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0x7d8b293:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_135__pyx_unpickle_ElementwiseKernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_ElementwiseKernel, __pyx_t_1) < 0) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":9
 *         __pyx_unpickle_ElementwiseKernel__set_state(<ElementwiseKernel> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ElementwiseKernel__set_state(ElementwiseKernel __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.in_params = __pyx_state[0]; __pyx_result.kwargs = __pyx_state[1]; __pyx_result.name = __pyx_state[2]; __pyx_result.nargs = __pyx_state[3]; __pyx_result.nin = __pyx_state[4]; __pyx_result.nout = __pyx_state[5]; __pyx_result.operation = __pyx_state[6]; __pyx_result.out_params = __pyx_state[7]; __pyx_result.params = __pyx_state[8]; __pyx_result.preamble = __pyx_state[9]; __pyx_result.reduce_dims = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_137__pyx_unpickle_broadcast, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_broadcast, __pyx_t_1) < 0) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1
 * # distutils: language = c++             # <<<<<<<<<<<<<<
 * 
 * from __future__ import division
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_ndarray___getitem___line_1507, __pyx_kp_u_x___getitem___y_x_y_Supports_bot) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_ndarray___setitem___line_1553, __pyx_kp_u_x___setitem___slices_y_x_slices) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "View.MemoryView":208
 *         info.obj = self
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(array self):
 */
  __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 208, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(4, 208, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_array_type);

  /* "View.MemoryView":285
 *         return self.name
 * 
 * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__427, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(generic);
  __Pyx_DECREF_SET(generic, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":286
 * 
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
 * cdef indirect = Enum("<strided and indirect>")
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__428, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(strided);
  __Pyx_DECREF_SET(strided, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":287
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__429, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(indirect);
  __Pyx_DECREF_SET(indirect, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":290
 * 
 * 
 * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__430, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(contiguous);
  __Pyx_DECREF_SET(contiguous, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":291
 * 
 * cdef contiguous = Enum("<contiguous and direct>")
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__431, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(indirect_contiguous);
  __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":315
 * 
 * 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":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(),
 *     PyThread_allocate_lock(),
 */
  __pyx_t_20[0] = PyThread_allocate_lock();
  __pyx_t_20[1] = PyThread_allocate_lock();
  __pyx_t_20[2] = PyThread_allocate_lock();
  __pyx_t_20[3] = PyThread_allocate_lock();
  __pyx_t_20[4] = PyThread_allocate_lock();
  __pyx_t_20[5] = PyThread_allocate_lock();
  __pyx_t_20[6] = PyThread_allocate_lock();
  __pyx_t_20[7] = PyThread_allocate_lock();
  memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_20, sizeof(__pyx_memoryview_thread_locks[0]) * (8));

  /* "View.MemoryView":544
 *         info.obj = self
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(4, 544, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_memoryview_type);

  /* "View.MemoryView":990
 *         return self.from_object
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 990, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(4, 990, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_memoryviewslice_type);

  /* "(tree fragment)":1
 * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     if __pyx_checksum != 0xb068931:
 *         from pickle import PickleError as __pyx_PickleError
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum, NULL, __pyx_n_s_View_MemoryView); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Enum, __pyx_t_1) < 0) __PYX_ERR(4, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":9
 *         __pyx_unpickle_Enum__set_state(<Enum> __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);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_14);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init cupy.core.core", 0, __pyx_lineno, __pyx_filename);
    }
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init cupy.core.core");
  }
  __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((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* 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

/* 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;
}

/* 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; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_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

/* 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

/* 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);
}

/* 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);
}

/* 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_CheckExact(key)) || 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
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(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
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(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;
}

/* 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);
}

/* GetModuleGlobalName */
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    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);
    if (likely(result)) {
        Py_INCREF(result);
    } else if (unlikely(PyErr_Occurred())) {
        result = NULL;
    } else {
#else
    result = PyDict_GetItem(__pyx_d, name);
    if (likely(result)) {
        Py_INCREF(result);
    } else {
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

/* PyObjectCall */
    #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->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

/* 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

/* UnicodeAsUCS4 */
    static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject* x) {
   Py_ssize_t length;
   #if CYTHON_PEP393_ENABLED
   length = PyUnicode_GET_LENGTH(x);
   if (likely(length == 1)) {
       return PyUnicode_READ_CHAR(x, 0);
   }
   #else
   length = PyUnicode_GET_SIZE(x);
   if (likely(length == 1)) {
       return PyUnicode_AS_UNICODE(x)[0];
   }
   #if Py_UNICODE_SIZE == 2
   else if (PyUnicode_GET_SIZE(x) == 2) {
       Py_UCS4 high_val = PyUnicode_AS_UNICODE(x)[0];
       if (high_val >= 0xD800 && high_val <= 0xDBFF) {
           Py_UCS4 low_val = PyUnicode_AS_UNICODE(x)[1];
           if (low_val >= 0xDC00 && low_val <= 0xDFFF) {
               return 0x10000 + (((high_val & ((1<<10)-1)) << 10) | (low_val & ((1<<10)-1)));
           }
       }
   }
   #endif
   #endif
   PyErr_Format(PyExc_ValueError,
                "only single character unicode strings can be converted to Py_UCS4, "
                "got length %" CYTHON_FORMAT_SSIZE_T "d", length);
   return (Py_UCS4)-1;
}

/* object_ord */
    static long __Pyx__PyObject_Ord(PyObject* c) {
    Py_ssize_t size;
    if (PyBytes_Check(c)) {
        size = PyBytes_GET_SIZE(c);
        if (likely(size == 1)) {
            return (unsigned char) PyBytes_AS_STRING(c)[0];
        }
#if PY_MAJOR_VERSION < 3
    } else if (PyUnicode_Check(c)) {
        return (long)__Pyx_PyUnicode_AsPy_UCS4(c);
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    } else if (PyByteArray_Check(c)) {
        size = PyByteArray_GET_SIZE(c);
        if (likely(size == 1)) {
            return (unsigned char) PyByteArray_AS_STRING(c)[0];
        }
#endif
    } else {
        PyErr_Format(PyExc_TypeError,
            "ord() expected string of length 1, but %.200s found", c->ob_type->tp_name);
        return (long)(Py_UCS4)-1;
    }
    PyErr_Format(PyExc_TypeError,
        "ord() expected a character, but string of length %zd found", size);
    return (long)(Py_UCS4)-1;
}

/* 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;
}

/* 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)));
    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)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
    }
}
#endif

/* PyFunctionFastCall */
    #if CYTHON_FAST_PYCALL
#include "frameobject.h"
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 = f->f_localsplus;
    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, int 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, nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* 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 (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
            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

/* PyObjectCallNoArg */
    #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* PyIntBinop */
      #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 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

/* py_abs */
      #if CYTHON_USE_PYLONG_INTERNALS
static PyObject *__Pyx_PyLong_AbsNeg(PyObject *n) {
    if (likely(Py_SIZE(n) == -1)) {
        return PyLong_FromLong(((PyLongObject*)n)->ob_digit[0]);
    }
#if CYTHON_COMPILING_IN_CPYTHON
    {
        PyObject *copy = _PyLong_Copy((PyLongObject*)n);
        if (likely(copy)) {
            Py_SIZE(copy) = -(Py_SIZE(copy));
        }
        return copy;
    }
#else
    return PyNumber_Negative(n);
#endif
}
#endif

/* 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");
}

/* IterFinish */
      static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

/* UnpackItemEndCheck */
      static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

/* 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_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_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
}

/* SaveResetException */
      #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if PY_VERSION_HEX >= 0x030700A2
    *type = tstate->exc_state.exc_type;
    *value = tstate->exc_state.exc_value;
    *tb = tstate->exc_state.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 PY_VERSION_HEX >= 0x030700A2
    tmp_type = tstate->exc_state.exc_type;
    tmp_value = tstate->exc_state.exc_value;
    tmp_tb = tstate->exc_state.exc_traceback;
    tstate->exc_state.exc_type = type;
    tstate->exc_state.exc_value = value;
    tstate->exc_state.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 PY_VERSION_HEX >= 0x030700A2
    tmp_type = tstate->exc_state.exc_type;
    tmp_value = tstate->exc_state.exc_value;
    tmp_tb = tstate->exc_state.exc_traceback;
    tstate->exc_state.exc_type = local_type;
    tstate->exc_state.exc_value = local_value;
    tstate->exc_state.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;
}

/* None */
        static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

/* PyIntBinop */
        #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    if (op1 == op2) {
        Py_RETURN_TRUE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a == b) {
            Py_RETURN_TRUE;
        } else {
            Py_RETURN_FALSE;
        }
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a;
        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;
                    }
                    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;
                    }
                    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;
                    }
                    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;
                    }
                    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;
                    }
                    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;
                    }
                    CYTHON_FALLTHROUGH;
                #if PyLong_SHIFT < 30 && PyLong_SHIFT != 15
                default: return PyLong_Type.tp_richcompare(op1, op2, Py_EQ);
                #else
                default: Py_RETURN_FALSE;
                #endif
            }
        }
            if (a == b) {
                Py_RETURN_TRUE;
            } else {
                Py_RETURN_FALSE;
            }
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            if ((double)a == (double)b) {
                Py_RETURN_TRUE;
            } else {
                Py_RETURN_FALSE;
            }
    }
    return PyObject_RichCompare(op1, op2, Py_EQ);
}
#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((0 <= wrapped_i) & (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((0 <= wrapped_i) & (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((n >= 0) & (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((n >= 0) & (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));
}

/* SetItemInt */
        static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, 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) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_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 -1;
                    PyErr_Clear();
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) {
#else
    if (is_list || PySequence_Check(o)) {
#endif
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

/* KeywordStringCheck */
          static int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
#if CYTHON_COMPILING_IN_PYPY
    if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
        goto invalid_keyword;
    return 1;
#else
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_Check(key)))
        #endif
            if (unlikely(!PyUnicode_Check(key)))
                goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    return 0;
#endif
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
    return 0;
}

/* None */
          static CYTHON_INLINE Py_ssize_t __Pyx_mod_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
    Py_ssize_t r = a % b;
    r += ((r != 0) & ((r ^ b) < 0)) * b;
    return r;
}

/* PyIntBinop */
          #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a - b);
            if (likely((x^a) >= 0 || (x^~b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_subtract(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_subtract(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("subtract", return NULL)
            result = ((double)a) - (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
}
#endif

/* 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

/* RaiseNoneIterError */
          static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

/* SliceObject */
          static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_USE_TYPE_SLOTS
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                    goto bad;
                PyErr_Clear();
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_USE_TYPE_SLOTS
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

/* PyIntBinop */
          #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_FloorDivideObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            if (unlikely(b == -1 && ((unsigned long)a) == 0-(unsigned long)a))
                return PyInt_Type.tp_as_number->nb_floor_divide(op1, op2);
            else {
                long q, r;
                q = a / b;
                r = a - q*b;
                q -= ((r != 0) & ((r ^ b) < 0));
                x = q;
            }
            return PyInt_FromLong(x);
    }
    #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_floor_divide(op1, op2);
            }
        }
                {
                    long q, r;
                    q = a / b;
                    r = a - q*b;
                    q -= ((r != 0) & ((r ^ b) < 0));
                    x = q;
                }
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                {
                    PY_LONG_LONG q, r;
                    q = lla / llb;
                    r = lla - q*llb;
                    q -= ((r != 0) & ((r ^ llb) < 0));
                    llx = q;
                }
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    return (inplace ? PyNumber_InPlaceFloorDivide : PyNumber_FloorDivide)(op1, op2);
}
#endif

/* UnpackUnboundCMethod */
          static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
    }
#endif
    return 0;
}

/* CallUnboundCMethod1 */
          #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
    if (likely(cfunc->func)) {
        int flag = cfunc->flag;
        if (flag == METH_O) {
            return (*(cfunc->func))(self, arg);
        } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
            if (PY_VERSION_HEX >= 0x030700A0) {
                return (*(__Pyx_PyCFunctionFast)cfunc->func)(self, &arg, 1);
            } else {
                return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, &arg, 1, NULL);
            }
        } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
            return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, &arg, 1, NULL);
        }
    }
    return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 0, arg);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 1, arg);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(2, self, arg);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* 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;
}

/* None */
          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;
}

/* StringJoin */
          #if !CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
    return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
}
#endif

/* DictGetItem */
          #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            PyObject* args = PyTuple_Pack(1, key);
            if (likely(args))
                PyErr_SetObject(PyExc_KeyError, args);
            Py_XDECREF(args);
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#endif

/* pyfrozenset_new */
          static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) {
    if (it) {
        PyObject* result;
#if CYTHON_COMPILING_IN_PYPY
        PyObject* args;
        args = PyTuple_Pack(1, it);
        if (unlikely(!args))
            return NULL;
        result = PyObject_Call((PyObject*)&PyFrozenSet_Type, args, NULL);
        Py_DECREF(args);
        return result;
#else
        if (PyFrozenSet_CheckExact(it)) {
            Py_INCREF(it);
            return it;
        }
        result = PyFrozenSet_New(it);
        if (unlikely(!result))
            return NULL;
        if (likely(PySet_GET_SIZE(result)))
            return result;
        Py_DECREF(result);
#endif
    }
#if CYTHON_USE_TYPE_SLOTS
    return PyFrozenSet_Type.tp_new(&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
#else
    return PyObject_Call((PyObject*)&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
#endif
}

/* PySetContains */
          static int __Pyx_PySet_ContainsUnhashable(PyObject *set, PyObject *key) {
    int result = -1;
    if (PySet_Check(key) && PyErr_ExceptionMatches(PyExc_TypeError)) {
        PyObject *tmpkey;
        PyErr_Clear();
        tmpkey = __Pyx_PyFrozenSet_New(key);
        if (tmpkey != NULL) {
            result = PySet_Contains(set, tmpkey);
            Py_DECREF(tmpkey);
        }
    }
    return result;
}
static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq) {
    int result = PySet_Contains(set, key);
    if (unlikely(result < 0)) {
        result = __Pyx_PySet_ContainsUnhashable(set, key);
    }
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* CallUnboundCMethod0 */
          static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_ASSUME_SAFE_MACROS
    args = PyTuple_New(1);
    if (unlikely(!args)) goto bad;
    Py_INCREF(self);
    PyTuple_SET_ITEM(args, 0, self);
#else
    args = PyTuple_Pack(1, self);
    if (unlikely(!args)) goto bad;
#endif
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    Py_DECREF(args);
bad:
    return result;
}

/* SliceTupleAndList */
          #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) {
    Py_ssize_t start = *_start, stop = *_stop, length = *_length;
    if (start < 0) {
        start += length;
        if (start < 0)
            start = 0;
    }
    if (stop < 0)
        stop += length;
    else if (stop > length)
        stop = length;
    *_length = stop - start;
    *_start = start;
    *_stop = stop;
}
static CYTHON_INLINE void __Pyx_copy_object_array(PyObject** CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
    PyObject *v;
    Py_ssize_t i;
    for (i = 0; i < length; i++) {
        v = dest[i] = src[i];
        Py_INCREF(v);
    }
}
static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(
            PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
    PyObject* dest;
    Py_ssize_t length = PyList_GET_SIZE(src);
    __Pyx_crop_slice(&start, &stop, &length);
    if (unlikely(length <= 0))
        return PyList_New(0);
    dest = PyList_New(length);
    if (unlikely(!dest))
        return NULL;
    __Pyx_copy_object_array(
        ((PyListObject*)src)->ob_item + start,
        ((PyListObject*)dest)->ob_item,
        length);
    return dest;
}
static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(
            PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
    PyObject* dest;
    Py_ssize_t length = PyTuple_GET_SIZE(src);
    __Pyx_crop_slice(&start, &stop, &length);
    if (unlikely(length <= 0))
        return PyTuple_New(0);
    dest = PyTuple_New(length);
    if (unlikely(!dest))
        return NULL;
    __Pyx_copy_object_array(
        ((PyTupleObject*)src)->ob_item + start,
        ((PyTupleObject*)dest)->ob_item,
        length);
    return dest;
}
#endif

/* py_dict_items */
          static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
    if (PY_MAJOR_VERSION >= 3)
        return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_items, d);
    else
        return PyDict_Items(d);
}

/* None */
          static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

/* CallUnboundCMethod2 */
          #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
    if (likely(cfunc->func)) {
        PyObject *args[2] = {arg1, arg2};
        if (cfunc->flag == METH_FASTCALL) {
            #if PY_VERSION_HEX >= 0x030700A0
            return (*(__Pyx_PyCFunctionFast)cfunc->func)(self, args, 2);
            #else
            return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, args, 2, NULL);
            #endif
        }
        #if PY_VERSION_HEX >= 0x030700A0
        if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
            return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, args, 2, NULL);
        #endif
    }
    return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 0, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 1, arg2);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(3);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 1, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 2, arg2);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(3, self, arg1, arg2);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* py_dict_pop */
          static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B3
    if ((1)) {
        return _PyDict_Pop(d, key, default_value);
    } else
#endif
    if (default_value) {
        return __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_pop, d, key, default_value);
    } else {
        return __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_pop, d, key);
    }
}

/* PyObjectCallMethod1 */
          static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
    PyObject *result = NULL;
#if CYTHON_UNPACK_METHODS
    if (likely(PyMethod_Check(method))) {
        PyObject *self = PyMethod_GET_SELF(method);
        if (likely(self)) {
            PyObject *args;
            PyObject *function = PyMethod_GET_FUNCTION(method);
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(function)) {
                PyObject *args[2] = {self, arg};
                result = __Pyx_PyFunction_FastCall(function, args, 2);
                goto done;
            }
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(function)) {
                PyObject *args[2] = {self, arg};
                result = __Pyx_PyCFunction_FastCall(function, args, 2);
                goto done;
            }
            #endif
            args = PyTuple_New(2);
            if (unlikely(!args)) goto done;
            Py_INCREF(self);
            PyTuple_SET_ITEM(args, 0, self);
            Py_INCREF(arg);
            PyTuple_SET_ITEM(args, 1, arg);
            Py_INCREF(function);
            result = __Pyx_PyObject_Call(function, args, NULL);
            Py_DECREF(args);
            Py_DECREF(function);
            return result;
        }
    }
#endif
    result = __Pyx_PyObject_CallOneArg(method, arg);
    goto done;
done:
    return result;
}
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method, *result;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) return NULL;
    result = __Pyx__PyObject_CallMethod1(method, arg);
    Py_DECREF(method);
    return result;
}

/* append */
          static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
    } else {
        PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
        if (unlikely(!retval))
            return -1;
        Py_DECREF(retval);
    }
    return 0;
}

/* dict_getitem_default */
          static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
    PyObject* value;
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (unlikely(PyErr_Occurred()))
            return NULL;
        value = default_value;
    }
    Py_INCREF(value);
    if ((1));
#else
    if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            value = default_value;
        }
        Py_INCREF(value);
    }
#endif
    else {
        if (default_value == Py_None)
            value = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_get, d, key);
        else
            value = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_get, d, key, default_value);
    }
    return value;
}

/* PyObjectSetAttrStr */
          #if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_setattr))
        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
#endif
    return PyObject_SetAttr(obj, attr_name, value);
}
#endif

/* BufferIndexError */
          static void __Pyx_RaiseBufferIndexError(int axis) {
  PyErr_Format(PyExc_IndexError,
     "Out of bounds on buffer access (axis %d)", axis);
}

/* 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 (!buf) {
        PyErr_SetString(PyExc_ValueError,
            "buf is NULL.");
        goto fail;
    } else if (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 (!memview || (PyObject *) memview == Py_None)
        return;
    if (__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 (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 (!memview ) {
        return;
    } else if ((PyObject *) memview == Py_None) {
        memslice->memview = NULL;
        return;
    }
    if (__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 (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;
    }
}

/* DelItemInt */
          static int __Pyx_DelItem_Generic(PyObject *o, PyObject *j) {
    int r;
    if (!j) return -1;
    r = PyObject_DelItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i,
                                               CYTHON_UNUSED int is_list, CYTHON_NCP_UNUSED int wraparound) {
#if !CYTHON_USE_TYPE_SLOTS
    if (is_list || PySequence_Check(o)) {
        return PySequence_DelItem(o, i);
    }
#else
    PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
    if (likely(m && m->sq_ass_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 -1;
                PyErr_Clear();
            }
        }
        return m->sq_ass_item(o, i, (PyObject *)NULL);
    }
#endif
    return __Pyx_DelItem_Generic(o, PyInt_FromSsize_t(i));
}

/* WriteUnraisableException */
          static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#ifdef _MSC_VER
    else state = (PyGILState_STATE)-1;
#endif
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

/* PyFloatBinop */
          #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyFloat_TrueDivideCObj(PyObject *op1, PyObject *op2, double floatval, CYTHON_UNUSED int inplace) {
    const double a = floatval;
    double b, result;
    if (likely(PyFloat_CheckExact(op2))) {
        b = PyFloat_AS_DOUBLE(op2);
    } else
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op2))) {
        b = (double) PyInt_AS_LONG(op2);
    } else
    #endif
    if (likely(PyLong_CheckExact(op2))) {
        #if CYTHON_USE_PYLONG_INTERNALS
        const digit* digits = ((PyLongObject*)op2)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op2);
        switch (size) {
            case  0: b = 0.0; break;
            case -1: b = -(double) digits[0]; break;
            case  1: b = (double) digits[0]; break;
            case -2:
            case 2:
                if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) {
                    b = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -2)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            case -3:
            case 3:
                if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -3)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            case -4:
            case 4:
                if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -4)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            default:
        #else
        {
        #endif
            b = PyLong_AsDouble(op2);
            if (unlikely(b == -1.0 && PyErr_Occurred())) return NULL;
        }
    } else {
        return (inplace ? PyNumber_InPlaceTrueDivide : PyNumber_TrueDivide)(op1, op2);
    }
        PyFPE_START_PROTECT("divide", return NULL)
        result = a / b;
        PyFPE_END_PROTECT(result)
        return PyFloat_FromDouble(result);
}
#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 (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, 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;
}

/* 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;
    }
}

/* 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;
    }
    length = stop - start;
    if (unlikely(length <= 0))
        return PyUnicode_FromUnicode(NULL, 0);
    cstring += start;
    if (decode_func) {
        return decode_func(cstring, length, errors);
    } else {
        return PyUnicode_Decode(cstring, length, encoding, errors);
    }
}

/* 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 PY_VERSION_HEX >= 0x030700A2
    tmp_type = tstate->exc_state.exc_type;
    tmp_value = tstate->exc_state.exc_value;
    tmp_tb = tstate->exc_state.exc_traceback;
    tstate->exc_state.exc_type = *type;
    tstate->exc_state.exc_value = *value;
    tstate->exc_state.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

/* 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 CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* None */
            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;
}

/* CallNextTpDealloc */
            static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_dealloc != current_tp_dealloc)
        type = type->tp_base;
    while (type && type->tp_dealloc == current_tp_dealloc)
        type = type->tp_base;
    if (type)
        type->tp_dealloc(obj);
}

/* 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;
}

/* 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_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD;
#else
    if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD;
#endif
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto 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 BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD;
            ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD;
            ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto 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_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD;
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD;
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto GOOD;
BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* 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;
}

/* CalculateMetaclass */
            static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
    Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
    for (i=0; i < nbases; i++) {
        PyTypeObject *tmptype;
        PyObject *tmp = PyTuple_GET_ITEM(bases, i);
        tmptype = Py_TYPE(tmp);
#if PY_MAJOR_VERSION < 3
        if (tmptype == &PyClass_Type)
            continue;
#endif
        if (!metaclass) {
            metaclass = tmptype;
            continue;
        }
        if (PyType_IsSubtype(metaclass, tmptype))
            continue;
        if (PyType_IsSubtype(tmptype, metaclass)) {
            metaclass = tmptype;
            continue;
        }
        PyErr_SetString(PyExc_TypeError,
                        "metaclass conflict: "
                        "the metaclass of a derived class "
                        "must be a (non-strict) subclass "
                        "of the metaclasses of all its bases");
        return NULL;
    }
    if (!metaclass) {
#if PY_MAJOR_VERSION < 3
        metaclass = &PyClass_Type;
#else
        metaclass = &PyType_Type;
#endif
    }
    Py_INCREF((PyObject*) metaclass);
    return (PyObject*) metaclass;
}

/* FetchCommonType */
            static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

/* CythonFunction */
            #include <structmember.h>
static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (unlikely(op->func_doc == NULL)) {
        if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
            if (unlikely(op->func_doc == NULL))
                return NULL;
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL) {
        value = Py_None;
    }
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
        if (unlikely(op->func_name == NULL))
            return NULL;
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = op->func_qualname;
    Py_INCREF(value);
    op->func_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_dict == NULL)) {
        op->func_dict = PyDict_New();
        if (unlikely(op->func_dict == NULL))
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
    if (unlikely(value == NULL)) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (unlikely(!PyDict_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    int result = 0;
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
    Py_INCREF(op->defaults_tuple);
    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
    Py_INCREF(op->defaults_kwdict);
    #else
    op->defaults_tuple = PySequence_ITEM(res, 0);
    if (unlikely(!op->defaults_tuple)) result = -1;
    else {
        op->defaults_kwdict = PySequence_ITEM(res, 1);
        if (unlikely(!op->defaults_kwdict)) result = -1;
    }
    #endif
    Py_DECREF(res);
    return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyTuple_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__defaults__ must be set to a tuple object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_tuple;
    op->defaults_tuple = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_tuple;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_tuple;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__kwdefaults__ must be set to a dict object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_kwdict;
    op->defaults_kwdict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_kwdict;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_kwdict;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value || value == Py_None) {
        value = NULL;
    } else if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__annotations__ must be set to a dict object");
        return -1;
    }
    Py_XINCREF(value);
    tmp = op->func_annotations;
    op->func_annotations = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
    PyObject* result = op->func_annotations;
    if (unlikely(!result)) {
        result = PyDict_New();
        if (unlikely(!result)) return NULL;
        op->func_annotations = result;
    }
    Py_INCREF(result);
    return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
    {0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
    if (op == NULL)
        return NULL;
    op->flags = flags;
    __Pyx_CyFunction_weakreflist(op) = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    Py_INCREF(qualname);
    op->func_qualname = qualname;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    op->func_globals = globals;
    Py_INCREF(op->func_globals);
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    PyObject_GC_Track(op);
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_qualname);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_globals);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    Py_CLEAR(m->defaults_kwdict);
    Py_CLEAR(m->func_annotations);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyObject_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    if (__Pyx_CyFunction_weakreflist(m) != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    __Pyx__CyFunction_dealloc(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_qualname);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_globals);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    Py_VISIT(m->defaults_kwdict);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
    return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                op->func_qualname, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(op->func_qualname), (void *)op);
#endif
}
static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = f->m_ml->ml_meth;
    Py_ssize_t size;
    switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
    case METH_VARARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0))
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 0))
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 1)) {
                PyObject *result, *arg0;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                arg0 = PyTuple_GET_ITEM(arg, 0);
                #else
                arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
                #endif
                result = (*meth)(self, arg0);
                #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
                Py_DECREF(arg0);
                #endif
                return result;
            }
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
}
static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
    PyObject *result;
    __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
    if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
        Py_ssize_t argc;
        PyObject *new_args;
        PyObject *self;
        argc = PyTuple_GET_SIZE(args);
        new_args = PyTuple_GetSlice(args, 1, argc);
        if (unlikely(!new_args))
            return NULL;
        self = PyTuple_GetItem(args, 0);
        if (unlikely(!self)) {
            Py_DECREF(new_args);
            return NULL;
        }
        result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
        Py_DECREF(new_args);
    } else {
        result = __Pyx_CyFunction_Call(func, args, kw);
    }
    return result;
}
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "cython_function_or_method",
    sizeof(__pyx_CyFunctionObject),
    0,
    (destructor) __Pyx_CyFunction_dealloc,
    0,
    0,
    0,
#if PY_MAJOR_VERSION < 3
    0,
#else
    0,
#endif
    (reprfunc) __Pyx_CyFunction_repr,
    0,
    0,
    0,
    0,
    __Pyx_CyFunction_CallAsMethod,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
    0,
    (traverseproc) __Pyx_CyFunction_traverse,
    (inquiry) __Pyx_CyFunction_clear,
    0,
#if PY_VERSION_HEX < 0x030500A0
    offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
    offsetof(PyCFunctionObject, m_weakreflist),
#endif
    0,
    0,
    __pyx_CyFunction_methods,
    __pyx_CyFunction_members,
    __pyx_CyFunction_getsets,
    0,
    0,
    __Pyx_CyFunction_descr_get,
    0,
    offsetof(__pyx_CyFunctionObject, func_dict),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
};
static int __pyx_CyFunction_init(void) {
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (unlikely(__pyx_CyFunctionType == NULL)) {
        return -1;
    }
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyObject_Malloc(size);
    if (unlikely(!m->defaults))
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_kwdict = dict;
    Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->func_annotations = dict;
    Py_INCREF(dict);
}

/* Py3ClassCreate */
                static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
                                           PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
    PyObject *ns;
    if (metaclass) {
        PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
        if (prep) {
            PyObject *pargs = PyTuple_Pack(2, name, bases);
            if (unlikely(!pargs)) {
                Py_DECREF(prep);
                return NULL;
            }
            ns = PyObject_Call(prep, pargs, mkw);
            Py_DECREF(prep);
            Py_DECREF(pargs);
        } else {
            if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
                return NULL;
            PyErr_Clear();
            ns = PyDict_New();
        }
    } else {
        ns = PyDict_New();
    }
    if (unlikely(!ns))
        return NULL;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
    if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc_2, doc) < 0)) goto bad;
    return ns;
bad:
    Py_DECREF(ns);
    return NULL;
}
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
                                      PyObject *dict, PyObject *mkw,
                                      int calculate_metaclass, int allow_py2_metaclass) {
    PyObject *result, *margs;
    PyObject *owned_metaclass = NULL;
    if (allow_py2_metaclass) {
        owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
        if (owned_metaclass) {
            metaclass = owned_metaclass;
        } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
            PyErr_Clear();
        } else {
            return NULL;
        }
    }
    if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
        metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
        Py_XDECREF(owned_metaclass);
        if (unlikely(!metaclass))
            return NULL;
        owned_metaclass = metaclass;
    }
    margs = PyTuple_Pack(3, name, bases, dict);
    if (unlikely(!margs)) {
        result = NULL;
    } else {
        result = PyObject_Call(metaclass, margs, mkw);
        Py_DECREF(margs);
    }
    Py_XDECREF(owned_metaclass);
    return result;
}

/* CLineInTraceback */
                #ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
      use_cline = __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;
        PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (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"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    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);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    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;
    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) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __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);
}

#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;
}

/* 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;\
    }

/* CIntToPy */
                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    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);
    }
}

/* Declarations */
                #if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return ::std::complex< double >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return x + y*(__pyx_t_double_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      __pyx_t_double_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

/* Arithmetic */
                #if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    #if 1
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        if (b.imag == 0) {
            return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else if (fabs(b.real) >= fabs(b.imag)) {
            if (b.real == 0 && b.imag == 0) {
                return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
            } else {
                double r = b.imag / b.real;
                double s = 1.0 / (b.real + b.imag * r);
                return __pyx_t_double_complex_from_parts(
                    (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
            }
        } else {
            double r = b.real / b.imag;
            double s = 1.0 / (b.imag + b.real * r);
            return __pyx_t_double_complex_from_parts(
                (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
        }
    }
    #else
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        if (b.imag == 0) {
            return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else {
            double denom = b.real * b.real + b.imag * b.imag;
            return __pyx_t_double_complex_from_parts(
                (a.real * b.real + a.imag * b.imag) / denom,
                (a.imag * b.real - a.real * b.imag) / denom);
        }
    }
    #endif
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrt(z.real*z.real + z.imag*z.imag);
          #else
            return hypot(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
            __pyx_t_double_complex z;
            double r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    double denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prod_double(a, a);
                        return __Pyx_c_prod_double(a, a);
                    case 3:
                        z = __Pyx_c_prod_double(a, a);
                        return __Pyx_c_prod_double(z, a);
                    case 4:
                        z = __Pyx_c_prod_double(a, a);
                        return __Pyx_c_prod_double(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                } else if (b.imag == 0) {
                    z.real = pow(a.real, b.real);
                    z.imag = 0;
                    return z;
                } else if (a.real > 0) {
                    r = a.real;
                    theta = 0;
                } else {
                    r = -a.real;
                    theta = atan2(0, -1);
                }
            } else {
                r = __Pyx_c_abs_double(a);
                theta = atan2(a.imag, a.real);
            }
            lnr = log(r);
            z_r = exp(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cos(z_theta);
            z.imag = z_r * sin(z_theta);
            return z;
        }
    #endif
#endif

/* CIntToPy */
                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    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);
    }
}

/* CIntToPy */
                static CYTHON_INLINE PyObject* __Pyx_PyInt_From_PY_LONG_LONG(PY_LONG_LONG value) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG) -1, const_zero = (PY_LONG_LONG) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(PY_LONG_LONG) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(PY_LONG_LONG) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(PY_LONG_LONG) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(PY_LONG_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(PY_LONG_LONG),
                                     little, !is_unsigned);
    }
}

/* MemviewDtypeToObject */
                static CYTHON_INLINE PyObject *__pyx_memview_get_Py_ssize_t(const char *itemp) {
    return (PyObject *) PyInt_FromSsize_t(*(Py_ssize_t *) itemp);
}
static CYTHON_INLINE int __pyx_memview_set_Py_ssize_t(const char *itemp, PyObject *obj) {
    Py_ssize_t value = __Pyx_PyIndex_AsSsize_t(obj);
    if ((value == (Py_ssize_t)-1) && PyErr_Occurred())
        return 0;
    *(Py_ssize_t *) itemp = value;
    return 1;
}

/* Declarations */
                #if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return ::std::complex< float >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return x + y*(__pyx_t_float_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      __pyx_t_float_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

/* Arithmetic */
                #if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    #if 1
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        if (b.imag == 0) {
            return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else if (fabsf(b.real) >= fabsf(b.imag)) {
            if (b.real == 0 && b.imag == 0) {
                return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
            } else {
                float r = b.imag / b.real;
                float s = 1.0 / (b.real + b.imag * r);
                return __pyx_t_float_complex_from_parts(
                    (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
            }
        } else {
            float r = b.real / b.imag;
            float s = 1.0 / (b.imag + b.real * r);
            return __pyx_t_float_complex_from_parts(
                (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
        }
    }
    #else
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        if (b.imag == 0) {
            return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else {
            float denom = b.real * b.real + b.imag * b.imag;
            return __pyx_t_float_complex_from_parts(
                (a.real * b.real + a.imag * b.imag) / denom,
                (a.imag * b.real - a.real * b.imag) / denom);
        }
    }
    #endif
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrtf(z.real*z.real + z.imag*z.imag);
          #else
            return hypotf(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
            __pyx_t_float_complex z;
            float r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    float denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prod_float(a, a);
                        return __Pyx_c_prod_float(a, a);
                    case 3:
                        z = __Pyx_c_prod_float(a, a);
                        return __Pyx_c_prod_float(z, a);
                    case 4:
                        z = __Pyx_c_prod_float(a, a);
                        return __Pyx_c_prod_float(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                } else if (b.imag == 0) {
                    z.real = powf(a.real, b.real);
                    z.imag = 0;
                    return z;
                } else if (a.real > 0) {
                    r = a.real;
                    theta = 0;
                } else {
                    r = -a.real;
                    theta = atan2f(0, -1);
                }
            } else {
                r = __Pyx_c_abs_float(a);
                theta = atan2f(a.imag, a.real);
            }
            lnr = logf(r);
            z_r = expf(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cosf(z_theta);
            z.imag = z_r * sinf(z_theta);
            return z;
        }
    #endif
#endif

/* 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 (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;
}

/* CIntFromPy */
                static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    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 PY_LONG_LONG __Pyx_PyInt_As_PY_LONG_LONG(PyObject *x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG) -1, const_zero = (PY_LONG_LONG) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(PY_LONG_LONG) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (PY_LONG_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 (PY_LONG_LONG) 0;
                case  1: __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, digit, digits[0])
                case 2:
                    if (8 * sizeof(PY_LONG_LONG) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PY_LONG_LONG) >= 2 * PyLong_SHIFT) {
                            return (PY_LONG_LONG) (((((PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(PY_LONG_LONG) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PY_LONG_LONG) >= 3 * PyLong_SHIFT) {
                            return (PY_LONG_LONG) (((((((PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(PY_LONG_LONG) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PY_LONG_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(PY_LONG_LONG) >= 4 * PyLong_SHIFT) {
                            return (PY_LONG_LONG) (((((((((PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_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 (PY_LONG_LONG) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(PY_LONG_LONG) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(PY_LONG_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 (PY_LONG_LONG) 0;
                case -1: __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(PY_LONG_LONG,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                            return (PY_LONG_LONG) (((PY_LONG_LONG)-1)*(((((PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(PY_LONG_LONG) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                            return (PY_LONG_LONG) ((((((PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                            return (PY_LONG_LONG) (((PY_LONG_LONG)-1)*(((((((PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(PY_LONG_LONG) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                            return (PY_LONG_LONG) ((((((((PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PY_LONG_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(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                            return (PY_LONG_LONG) (((PY_LONG_LONG)-1)*(((((((((PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(PY_LONG_LONG) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PY_LONG_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(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                            return (PY_LONG_LONG) ((((((((((PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(PY_LONG_LONG) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(PY_LONG_LONG, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(PY_LONG_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
            PY_LONG_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 (PY_LONG_LONG) -1;
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (PY_LONG_LONG) -1;
        val = __Pyx_PyInt_As_PY_LONG_LONG(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to PY_LONG_LONG");
    return (PY_LONG_LONG) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to PY_LONG_LONG");
    return (PY_LONG_LONG) -1;
}

/* CIntFromPy */
                static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
    const size_t neg_one = (size_t) -1, const_zero = (size_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(size_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (size_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 (size_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
                            return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
                            return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_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(size_t) >= 4 * PyLong_SHIFT) {
                            return (size_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
#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 (size_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(size_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_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 (size_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_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(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((((((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(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_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(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_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
            if (sizeof(size_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_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
            size_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 (size_t) -1;
        }
    } else {
        size_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (size_t) -1;
        val = __Pyx_PyInt_As_size_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to size_t");
    return (size_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to size_t");
    return (size_t) -1;
}

/* CIntFromPy */
                static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    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;
}

/* CIntFromPy */
                static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
    const char neg_one = (char) -1, const_zero = (char) 0;
    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;
}

/* CoroutineBase */
                #include <structmember.h>
#include <frameobject.h>
#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
    PyObject *et, *ev, *tb;
    PyObject *value = NULL;
    __Pyx_ErrFetch(&et, &ev, &tb);
    if (!et) {
        Py_XDECREF(tb);
        Py_XDECREF(ev);
        Py_INCREF(Py_None);
        *pvalue = Py_None;
        return 0;
    }
    if (likely(et == PyExc_StopIteration)) {
        if (!ev) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#if PY_VERSION_HEX >= 0x030300A0
        else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
            value = ((PyStopIterationObject *)ev)->value;
            Py_INCREF(value);
            Py_DECREF(ev);
        }
#endif
        else if (unlikely(PyTuple_Check(ev))) {
            if (PyTuple_GET_SIZE(ev) >= 1) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                value = PyTuple_GET_ITEM(ev, 0);
                Py_INCREF(value);
#else
                value = PySequence_ITEM(ev, 0);
#endif
            } else {
                Py_INCREF(Py_None);
                value = Py_None;
            }
            Py_DECREF(ev);
        }
        else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            value = ev;
        }
        if (likely(value)) {
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            return 0;
        }
    } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    PyErr_NormalizeException(&et, &ev, &tb);
    if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    Py_XDECREF(tb);
    Py_DECREF(et);
#if PY_VERSION_HEX >= 0x030300A0
    value = ((PyStopIterationObject *)ev)->value;
    Py_INCREF(value);
    Py_DECREF(ev);
#else
    {
        PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
        Py_DECREF(ev);
        if (likely(args)) {
            value = PySequence_GetItem(args, 0);
            Py_DECREF(args);
        }
        if (unlikely(!value)) {
            __Pyx_ErrRestore(NULL, NULL, NULL);
            Py_INCREF(Py_None);
            value = Py_None;
        }
    }
#endif
    *pvalue = value;
    return 0;
}
static CYTHON_INLINE
void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) {
    PyObject *exc_type = self->exc_type;
    PyObject *exc_value = self->exc_value;
    PyObject *exc_traceback = self->exc_traceback;
    self->exc_type = NULL;
    self->exc_value = NULL;
    self->exc_traceback = NULL;
    Py_XDECREF(exc_type);
    Py_XDECREF(exc_value);
    Py_XDECREF(exc_traceback);
}
#define __Pyx_Coroutine_AlreadyRunningError(gen)  (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
    const char *msg;
    if (0) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
        msg = "coroutine already executing";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
        msg = "async generator already executing";
    #endif
    } else {
        msg = "generator already executing";
    }
    PyErr_SetString(PyExc_ValueError, msg);
}
#define __Pyx_Coroutine_NotStartedError(gen)  (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
    const char *msg;
    if (0) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check(gen)) {
        msg = "can't send non-None value to a just-started coroutine";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact(gen)) {
        msg = "can't send non-None value to a just-started async generator";
    #endif
    } else {
        msg = "can't send non-None value to a just-started generator";
    }
    PyErr_SetString(PyExc_TypeError, msg);
}
#define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing)  (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
    #ifdef __Pyx_Coroutine_USED
    if (!closing && __Pyx_Coroutine_Check(gen)) {
        PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
    } else
    #endif
    if (value) {
        #ifdef __Pyx_AsyncGen_USED
        if (__Pyx_AsyncGen_CheckExact(gen))
            PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
        else
        #endif
        PyErr_SetNone(PyExc_StopIteration);
    }
}
static
PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
    __Pyx_PyThreadState_declare
    PyThreadState *tstate;
    PyObject *retval;
    assert(!self->is_running);
    if (unlikely(self->resume_label == 0)) {
        if (unlikely(value && value != Py_None)) {
            return __Pyx_Coroutine_NotStartedError((PyObject*)self);
        }
    }
    if (unlikely(self->resume_label == -1)) {
        return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
    }
#if CYTHON_FAST_THREAD_STATE
    __Pyx_PyThreadState_assign
    tstate = __pyx_tstate;
#else
    tstate = __Pyx_PyThreadState_Current;
#endif
    if (self->exc_type) {
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
#else
        if (self->exc_traceback) {
            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_XINCREF(tstate->frame);
            assert(f->f_back == NULL);
            f->f_back = tstate->frame;
        }
#endif
        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
                            &self->exc_traceback);
    } else {
        __Pyx_Coroutine_ExceptionClear(self);
        __Pyx_ExceptionSave(&self->exc_type, &self->exc_value, &self->exc_traceback);
    }
    self->is_running = 1;
    retval = self->body((PyObject *) self, tstate, value);
    self->is_running = 0;
    return retval;
}
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self) {
    if (likely(self->exc_traceback)) {
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
#else
        PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
        PyFrameObject *f = tb->tb_frame;
        Py_CLEAR(f->f_back);
#endif
    }
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
    if (unlikely(!retval)) {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        if (!__Pyx_PyErr_Occurred()) {
            PyObject *exc = PyExc_StopIteration;
            #ifdef __Pyx_AsyncGen_USED
            if (__Pyx_AsyncGen_CheckExact(gen))
                exc = __Pyx_PyExc_StopAsyncIteration;
            #endif
            __Pyx_PyErr_SetNone(exc);
        }
    }
    return retval;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
    PyObject *ret;
    PyObject *val = NULL;
    __Pyx_Coroutine_Undelegate(gen);
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
    ret = __Pyx_Coroutine_SendEx(gen, val, 0);
    Py_XDECREF(val);
    return ret;
}
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
    PyObject *retval;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_AsyncGen_USED
        if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
            ret = __Pyx_async_gen_asend_send(yf, value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyCoro_CheckExact(yf)) {
            ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
        {
            if (value == Py_None)
                ret = Py_TYPE(yf)->tp_iternext(yf);
            else
                ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
        }
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        retval = __Pyx_Coroutine_FinishDelegation(gen);
    } else {
        retval = __Pyx_Coroutine_SendEx(gen, value, 0);
    }
    return __Pyx_Coroutine_MethodReturn(self, retval);
}
static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
    PyObject *retval = NULL;
    int err = 0;
    #ifdef __Pyx_Generator_USED
    if (__Pyx_Generator_CheckExact(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_Coroutine_USED
    if (__Pyx_Coroutine_Check(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    if (__Pyx_CoroutineAwait_CheckExact(yf)) {
        retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_AsyncGen_USED
    if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
        retval = __Pyx_async_gen_asend_close(yf, NULL);
    } else
    if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
        retval = __Pyx_async_gen_athrow_close(yf, NULL);
    } else
    #endif
    {
        PyObject *meth;
        gen->is_running = 1;
        meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
        if (unlikely(!meth)) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                PyErr_WriteUnraisable(yf);
            }
            PyErr_Clear();
        } else {
            retval = PyObject_CallFunction(meth, NULL);
            Py_DECREF(meth);
            if (!retval)
                err = -1;
        }
        gen->is_running = 0;
    }
    Py_XDECREF(retval);
    return err;
}
static PyObject *__Pyx_Generator_Next(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Next(yf);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = _PyGen_Send((PyGenObject*)yf, NULL);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, Py_None);
        } else
        #endif
            ret = Py_TYPE(yf)->tp_iternext(yf);
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        return __Pyx_Coroutine_FinishDelegation(gen);
    }
    return __Pyx_Coroutine_SendEx(gen, Py_None, 0);
}
static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *retval, *raised_exception;
    PyObject *yf = gen->yieldfrom;
    int err = 0;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        Py_INCREF(yf);
        err = __Pyx_Coroutine_CloseIter(gen, yf);
        __Pyx_Coroutine_Undelegate(gen);
        Py_DECREF(yf);
    }
    if (err == 0)
        PyErr_SetNone(PyExc_GeneratorExit);
    retval = __Pyx_Coroutine_SendEx(gen, NULL, 1);
    if (unlikely(retval)) {
        const char *msg;
        Py_DECREF(retval);
        if ((0)) {
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_Coroutine_Check(self)) {
            msg = "coroutine ignored GeneratorExit";
        #endif
        #ifdef __Pyx_AsyncGen_USED
        } else if (__Pyx_AsyncGen_CheckExact(self)) {
#if PY_VERSION_HEX < 0x03060000
            msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
#else
            msg = "async generator ignored GeneratorExit";
#endif
        #endif
        } else {
            msg = "generator ignored GeneratorExit";
        }
        PyErr_SetString(PyExc_RuntimeError, msg);
        return NULL;
    }
    raised_exception = PyErr_Occurred();
    if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
        if (raised_exception) PyErr_Clear();
        Py_INCREF(Py_None);
        return Py_None;
    }
    return NULL;
}
static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
                                        PyObject *args, int close_on_genexit) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
        if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
            int err = __Pyx_Coroutine_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Coroutine_Undelegate(gen);
            if (err < 0)
                return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
            goto throw_here;
        }
        gen->is_running = 1;
        if (0
        #ifdef __Pyx_Generator_USED
            || __Pyx_Generator_CheckExact(yf)
        #endif
        #ifdef __Pyx_Coroutine_USED
            || __Pyx_Coroutine_Check(yf)
        #endif
            ) {
            ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
            ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
        #endif
        } else {
            PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
            if (unlikely(!meth)) {
                Py_DECREF(yf);
                if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                    gen->is_running = 0;
                    return NULL;
                }
                PyErr_Clear();
                __Pyx_Coroutine_Undelegate(gen);
                gen->is_running = 0;
                goto throw_here;
            }
            if (likely(args)) {
                ret = PyObject_CallObject(meth, args);
            } else {
                ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
            }
            Py_DECREF(meth);
        }
        gen->is_running = 0;
        Py_DECREF(yf);
        if (!ret) {
            ret = __Pyx_Coroutine_FinishDelegation(gen);
        }
        return __Pyx_Coroutine_MethodReturn(self, ret);
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
}
static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
    PyObject *typ;
    PyObject *val = NULL;
    PyObject *tb = NULL;
    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
        return NULL;
    return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
}
static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
    Py_VISIT(gen->closure);
    Py_VISIT(gen->classobj);
    Py_VISIT(gen->yieldfrom);
    Py_VISIT(gen->exc_type);
    Py_VISIT(gen->exc_value);
    Py_VISIT(gen->exc_traceback);
    return 0;
}
static int __Pyx_Coroutine_clear(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    Py_CLEAR(gen->closure);
    Py_CLEAR(gen->classobj);
    Py_CLEAR(gen->yieldfrom);
    Py_CLEAR(gen->exc_type);
    Py_CLEAR(gen->exc_value);
    Py_CLEAR(gen->exc_traceback);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
    }
#endif
    Py_CLEAR(gen->gi_code);
    Py_CLEAR(gen->gi_name);
    Py_CLEAR(gen->gi_qualname);
    Py_CLEAR(gen->gi_modulename);
    return 0;
}
static void __Pyx_Coroutine_dealloc(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject_GC_UnTrack(gen);
    if (gen->gi_weakreflist != NULL)
        PyObject_ClearWeakRefs(self);
    if (gen->resume_label >= 0) {
        PyObject_GC_Track(self);
#if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE
        if (PyObject_CallFinalizerFromDealloc(self))
#else
        Py_TYPE(gen)->tp_del(self);
        if (self->ob_refcnt > 0)
#endif
        {
            return;
        }
        PyObject_GC_UnTrack(self);
    }
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        /* We have to handle this case for asynchronous generators
           right here, because this code has to be between UNTRACK
           and GC_Del. */
        Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
    }
#endif
    __Pyx_Coroutine_clear(self);
    PyObject_GC_Del(gen);
}
static void __Pyx_Coroutine_del(PyObject *self) {
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    __Pyx_PyThreadState_declare
    if (gen->resume_label < 0) {
        return;
    }
#if !CYTHON_USE_TP_FINALIZE
    assert(self->ob_refcnt == 0);
    self->ob_refcnt = 1;
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
        PyObject *finalizer = agen->ag_finalizer;
        if (finalizer && !agen->ag_closed) {
            PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
            if (unlikely(!res)) {
                PyErr_WriteUnraisable(self);
            } else {
                Py_DECREF(res);
            }
            __Pyx_ErrRestore(error_type, error_value, error_traceback);
            return;
        }
    }
#endif
    if (unlikely(gen->resume_label == 0 && !error_value)) {
#ifdef __Pyx_Coroutine_USED
#ifdef __Pyx_Generator_USED
    if (!__Pyx_Generator_CheckExact(self))
#endif
        {
        PyObject_GC_UnTrack(self);
#if PY_MAJOR_VERSION >= 3  || defined(PyErr_WarnFormat)
        if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
            PyErr_WriteUnraisable(self);
#else
        {PyObject *msg;
        char *cmsg;
        #if CYTHON_COMPILING_IN_PYPY
        msg = NULL;
        cmsg = (char*) "coroutine was never awaited";
        #else
        char *cname;
        PyObject *qualname;
        qualname = gen->gi_qualname;
        cname = PyString_AS_STRING(qualname);
        msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
        if (unlikely(!msg)) {
            PyErr_Clear();
            cmsg = (char*) "coroutine was never awaited";
        } else {
            cmsg = PyString_AS_STRING(msg);
        }
        #endif
        if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
            PyErr_WriteUnraisable(self);
        Py_XDECREF(msg);}
#endif
        PyObject_GC_Track(self);
        }
#endif
    } else {
        PyObject *res = __Pyx_Coroutine_Close(self);
        if (unlikely(!res)) {
            if (PyErr_Occurred())
                PyErr_WriteUnraisable(self);
        } else {
            Py_DECREF(res);
        }
    }
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
#if !CYTHON_USE_TP_FINALIZE
    assert(self->ob_refcnt > 0);
    if (--self->ob_refcnt == 0) {
        return;
    }
    {
        Py_ssize_t refcnt = self->ob_refcnt;
        _Py_NewReference(self);
        self->ob_refcnt = refcnt;
    }
#if CYTHON_COMPILING_IN_CPYTHON
    assert(PyType_IS_GC(self->ob_type) &&
           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
    _Py_DEC_REFTOTAL;
#endif
#ifdef COUNT_ALLOCS
    --Py_TYPE(self)->tp_frees;
    --Py_TYPE(self)->tp_allocs;
#endif
#endif
}
static PyObject *
__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self)
{
    PyObject *name = self->gi_name;
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
static int
__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_name;
    Py_INCREF(value);
    self->gi_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self)
{
    PyObject *name = self->gi_qualname;
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
static int
__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_qualname;
    Py_INCREF(value);
    self->gi_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
            PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
    if (unlikely(!gen))
        return NULL;
    return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
}
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    gen->body = body;
    gen->closure = closure;
    Py_XINCREF(closure);
    gen->is_running = 0;
    gen->resume_label = 0;
    gen->classobj = NULL;
    gen->yieldfrom = NULL;
    gen->exc_type = NULL;
    gen->exc_value = NULL;
    gen->exc_traceback = NULL;
    gen->gi_weakreflist = NULL;
    Py_XINCREF(qualname);
    gen->gi_qualname = qualname;
    Py_XINCREF(name);
    gen->gi_name = name;
    Py_XINCREF(module_name);
    gen->gi_modulename = module_name;
    Py_XINCREF(code);
    gen->gi_code = code;
    PyObject_GC_Track(gen);
    return gen;
}

/* PatchModuleWithCoroutine */
                    static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    int result;
    PyObject *globals, *result_obj;
    globals = PyDict_New();  if (unlikely(!globals)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_coroutine_type",
    #ifdef __Pyx_Coroutine_USED
        (PyObject*)__pyx_CoroutineType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_generator_type",
    #ifdef __Pyx_Generator_USED
        (PyObject*)__pyx_GeneratorType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
    result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
    if (unlikely(!result_obj)) goto ignore;
    Py_DECREF(result_obj);
    Py_DECREF(globals);
    return module;
ignore:
    Py_XDECREF(globals);
    PyErr_WriteUnraisable(module);
    if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
        Py_DECREF(module);
        module = NULL;
    }
#else
    py_code++;
#endif
    return module;
}

/* PatchGeneratorABC */
                    #ifndef CYTHON_REGISTER_ABCS
#define CYTHON_REGISTER_ABCS 1
#endif
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
static PyObject* __Pyx_patch_abc_module(PyObject *module);
static PyObject* __Pyx_patch_abc_module(PyObject *module) {
    module = __Pyx_Coroutine_patch_module(
        module, ""
"if _cython_generator_type is not None:\n"
"    try: Generator = _module.Generator\n"
"    except AttributeError: pass\n"
"    else: Generator.register(_cython_generator_type)\n"
"if _cython_coroutine_type is not None:\n"
"    try: Coroutine = _module.Coroutine\n"
"    except AttributeError: pass\n"
"    else: Coroutine.register(_cython_coroutine_type)\n"
    );
    return module;
}
#endif
static int __Pyx_patch_abc(void) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    static int abc_patched = 0;
    if (CYTHON_REGISTER_ABCS && !abc_patched) {
        PyObject *module;
        module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
        if (!module) {
            PyErr_WriteUnraisable(NULL);
            if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
                    ((PY_MAJOR_VERSION >= 3) ?
                        "Cython module failed to register with collections.abc module" :
                        "Cython module failed to register with collections module"), 1) < 0)) {
                return -1;
            }
        } else {
            module = __Pyx_patch_abc_module(module);
            abc_patched = 1;
            if (unlikely(!module))
                return -1;
            Py_DECREF(module);
        }
        module = PyImport_ImportModule("backports_abc");
        if (module) {
            module = __Pyx_patch_abc_module(module);
            Py_XDECREF(module);
        }
        if (!module) {
            PyErr_Clear();
        }
    }
#else
    if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL);
#endif
    return 0;
}

/* Generator */
                    static PyMethodDef __pyx_Generator_methods[] = {
    {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
     (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
    {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
     (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
    {"close", (PyCFunction) __Pyx_Coroutine_Close, METH_NOARGS,
     (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
    {0, 0, 0, 0}
};
static PyMemberDef __pyx_Generator_memberlist[] = {
    {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
    {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
     (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
    {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
    {0, 0, 0, 0, 0}
};
static PyGetSetDef __pyx_Generator_getsets[] = {
    {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
     (char*) PyDoc_STR("name of the generator"), 0},
    {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
     (char*) PyDoc_STR("qualified name of the generator"), 0},
    {0, 0, 0, 0, 0}
};
static PyTypeObject __pyx_GeneratorType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "generator",
    sizeof(__pyx_CoroutineObject),
    0,
    (destructor) __Pyx_Coroutine_dealloc,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
    0,
    (traverseproc) __Pyx_Coroutine_traverse,
    0,
    0,
    offsetof(__pyx_CoroutineObject, gi_weakreflist),
    0,
    (iternextfunc) __Pyx_Generator_Next,
    __pyx_Generator_methods,
    __pyx_Generator_memberlist,
    __pyx_Generator_getsets,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if CYTHON_USE_TP_FINALIZE
    0,
#else
    __Pyx_Coroutine_del,
#endif
    0,
#if CYTHON_USE_TP_FINALIZE
    __Pyx_Coroutine_del,
#elif PY_VERSION_HEX >= 0x030400a1
    0,
#endif
};
static int __pyx_Generator_init(void) {
    __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
    __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
    __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
    if (unlikely(!__pyx_GeneratorType)) {
        return -1;
    }
    return 0;
}

/* IsLittleEndian */
                    static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
{
  union {
    uint32_t u32;
    uint8_t u8[4];
  } S;
  S.u32 = 0x01020304;
  return S.u8[0] == 4;
}

/* BufferFormatCheck */
                    static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
                              __Pyx_BufFmt_StackElem* stack,
                              __Pyx_TypeInfo* type) {
  stack[0].field = &ctx->root;
  stack[0].parent_offset = 0;
  ctx->root.type = type;
  ctx->root.name = "buffer dtype";
  ctx->root.offset = 0;
  ctx->head = stack;
  ctx->head->field = &ctx->root;
  ctx->fmt_offset = 0;
  ctx->head->parent_offset = 0;
  ctx->new_packmode = '@';
  ctx->enc_packmode = '@';
  ctx->new_count = 1;
  ctx->enc_count = 0;
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  ctx->is_valid_array = 0;
  ctx->struct_alignment = 0;
  while (type->typegroup == 'S') {
    ++ctx->head;
    ctx->head->field = type->fields;
    ctx->head->parent_offset = 0;
    type = type->fields->type;
  }
}
static int __Pyx_BufFmt_ParseNumber(const char** ts) {
    int count;
    const char* t = *ts;
    if (*t < '0' || *t > '9') {
      return -1;
    } else {
        count = *t++ - '0';
        while (*t >= '0' && *t < '9') {
            count *= 10;
            count += *t++ - '0';
        }
    }
    *ts = t;
    return count;
}
static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
    int number = __Pyx_BufFmt_ParseNumber(ts);
    if (number == -1)
        PyErr_Format(PyExc_ValueError,\
                     "Does not understand character buffer dtype format string ('%c')", **ts);
    return number;
}
static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
  PyErr_Format(PyExc_ValueError,
               "Unexpected format string character: '%c'", ch);
}
static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
  switch (ch) {
    case 'c': return "'char'";
    case 'b': return "'signed char'";
    case 'B': return "'unsigned char'";
    case 'h': return "'short'";
    case 'H': return "'unsigned short'";
    case 'i': return "'int'";
    case 'I': return "'unsigned int'";
    case 'l': return "'long'";
    case 'L': return "'unsigned long'";
    case 'q': return "'long long'";
    case 'Q': return "'unsigned long long'";
    case 'f': return (is_complex ? "'complex float'" : "'float'");
    case 'd': return (is_complex ? "'complex double'" : "'double'");
    case 'g': return (is_complex ? "'complex long double'" : "'long double'");
    case 'T': return "a struct";
    case 'O': return "Python object";
    case 'P': return "a pointer";
    case 's': case 'p': return "a string";
    case 0: return "end";
    default: return "unparseable format string";
  }
}
static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return 2;
    case 'i': case 'I': case 'l': case 'L': return 4;
    case 'q': case 'Q': return 8;
    case 'f': return (is_complex ? 8 : 4);
    case 'd': return (is_complex ? 16 : 8);
    case 'g': {
      PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
      return 0;
    }
    case 'O': case 'P': return sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
  switch (ch) {
    case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(short);
    case 'i': case 'I': return sizeof(int);
    case 'l': case 'L': return sizeof(long);
    #ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(PY_LONG_LONG);
    #endif
    case 'f': return sizeof(float) * (is_complex ? 2 : 1);
    case 'd': return sizeof(double) * (is_complex ? 2 : 1);
    case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
    case 'O': case 'P': return sizeof(void*);
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
typedef struct { char c; short x; } __Pyx_st_short;
typedef struct { char c; int x; } __Pyx_st_int;
typedef struct { char c; long x; } __Pyx_st_long;
typedef struct { char c; float x; } __Pyx_st_float;
typedef struct { char c; double x; } __Pyx_st_double;
typedef struct { char c; long double x; } __Pyx_st_longdouble;
typedef struct { char c; void *x; } __Pyx_st_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
/* These are for computing the padding at the end of the struct to align
   on the first member of the struct. This will probably the same as above,
   but we don't have any guarantees.
 */
typedef struct { short x; char c; } __Pyx_pad_short;
typedef struct { int x; char c; } __Pyx_pad_int;
typedef struct { long x; char c; } __Pyx_pad_long;
typedef struct { float x; char c; } __Pyx_pad_float;
typedef struct { double x; char c; } __Pyx_pad_double;
typedef struct { long double x; char c; } __Pyx_pad_longdouble;
typedef struct { void *x; char c; } __Pyx_pad_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
  switch (ch) {
    case 'c':
        return 'H';
    case 'b': case 'h': case 'i':
    case 'l': case 'q': case 's': case 'p':
        return 'I';
    case 'B': case 'H': case 'I': case 'L': case 'Q':
        return 'U';
    case 'f': case 'd': case 'g':
        return (is_complex ? 'C' : 'R');
    case 'O':
        return 'O';
    case 'P':
        return 'P';
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
  if (ctx->head == NULL || ctx->head->field == &ctx->root) {
    const char* expected;
    const char* quote;
    if (ctx->head == NULL) {
      expected = "end";
      quote = "";
    } else {
      expected = ctx->head->field->type->name;
      quote = "'";
    }
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected %s%s%s but got %s",
                 quote, expected, quote,
                 __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
  } else {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_StructField* parent = (ctx->head - 1)->field;
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
                 field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
                 parent->type->name, field->name);
  }
}
static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
  char group;
  size_t size, offset, arraysize = 1;
  if (ctx->enc_type == 0) return 0;
  if (ctx->head->field->type->arraysize[0]) {
    int i, ndim = 0;
    if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
        ctx->is_valid_array = ctx->head->field->type->ndim == 1;
        ndim = 1;
        if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
            PyErr_Format(PyExc_ValueError,
                         "Expected a dimension of size %zu, got %zu",
                         ctx->head->field->type->arraysize[0], ctx->enc_count);
            return -1;
        }
    }
    if (!ctx->is_valid_array) {
      PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
                   ctx->head->field->type->ndim, ndim);
      return -1;
    }
    for (i = 0; i < ctx->head->field->type->ndim; i++) {
      arraysize *= ctx->head->field->type->arraysize[i];
    }
    ctx->is_valid_array = 0;
    ctx->enc_count = 1;
  }
  group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
  do {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_TypeInfo* type = field->type;
    if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
      size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
    } else {
      size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
    }
    if (ctx->enc_packmode == '@') {
      size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
      size_t align_mod_offset;
      if (align_at == 0) return -1;
      align_mod_offset = ctx->fmt_offset % align_at;
      if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
      if (ctx->struct_alignment == 0)
          ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
                                                                 ctx->is_complex);
    }
    if (type->size != size || type->typegroup != group) {
      if (type->typegroup == 'C' && type->fields != NULL) {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        ++ctx->head;
        ctx->head->field = type->fields;
        ctx->head->parent_offset = parent_offset;
        continue;
      }
      if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
      } else {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
      }
    }
    offset = ctx->head->parent_offset + field->offset;
    if (ctx->fmt_offset != offset) {
      PyErr_Format(PyExc_ValueError,
                   "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
                   (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
      return -1;
    }
    ctx->fmt_offset += size;
    if (arraysize)
      ctx->fmt_offset += (arraysize - 1) * size;
    --ctx->enc_count;
    while (1) {
      if (field == &ctx->root) {
        ctx->head = NULL;
        if (ctx->enc_count != 0) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
        }
        break;
      }
      ctx->head->field = ++field;
      if (field->type == NULL) {
        --ctx->head;
        field = ctx->head->field;
        continue;
      } else if (field->type->typegroup == 'S') {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        if (field->type->fields->type == NULL) continue;
        field = field->type->fields;
        ++ctx->head;
        ctx->head->field = field;
        ctx->head->parent_offset = parent_offset;
        break;
      } else {
        break;
      }
    }
  } while (ctx->enc_count);
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  return 0;
}
static PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
{
    const char *ts = *tsp;
    int i = 0, number;
    int ndim = ctx->head->field->type->ndim;
;
    ++ts;
    if (ctx->new_count != 1) {
        PyErr_SetString(PyExc_ValueError,
                        "Cannot handle repeated arrays in format string");
        return NULL;
    }
    if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
    while (*ts && *ts != ')') {
        switch (*ts) {
            case ' ': case '\f': case '\r': case '\n': case '\t': case '\v':  continue;
            default:  break;
        }
        number = __Pyx_BufFmt_ExpectNumber(&ts);
        if (number == -1) return NULL;
        if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
            return PyErr_Format(PyExc_ValueError,
                        "Expected a dimension of size %zu, got %d",
                        ctx->head->field->type->arraysize[i], number);
        if (*ts != ',' && *ts != ')')
            return PyErr_Format(PyExc_ValueError,
                                "Expected a comma in format string, got '%c'", *ts);
        if (*ts == ',') ts++;
        i++;
    }
    if (i != ndim)
        return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
                            ctx->head->field->type->ndim, i);
    if (!*ts) {
        PyErr_SetString(PyExc_ValueError,
                        "Unexpected end of format string, expected ')'");
        return NULL;
    }
    ctx->is_valid_array = 1;
    ctx->new_count = 1;
    *tsp = ++ts;
    return Py_None;
}
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
  int got_Z = 0;
  while (1) {
    switch(*ts) {
      case 0:
        if (ctx->enc_type != 0 && ctx->head == NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        if (ctx->head != NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        return ts;
      case ' ':
      case '\r':
      case '\n':
        ++ts;
        break;
      case '<':
        if (!__Pyx_Is_Little_Endian()) {
          PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '>':
      case '!':
        if (__Pyx_Is_Little_Endian()) {
          PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '=':
      case '@':
      case '^':
        ctx->new_packmode = *ts++;
        break;
      case 'T':
        {
          const char* ts_after_sub;
          size_t i, struct_count = ctx->new_count;
          size_t struct_alignment = ctx->struct_alignment;
          ctx->new_count = 1;
          ++ts;
          if (*ts != '{') {
            PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
            return NULL;
          }
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0;
          ctx->enc_count = 0;
          ctx->struct_alignment = 0;
          ++ts;
          ts_after_sub = ts;
          for (i = 0; i != struct_count; ++i) {
            ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
            if (!ts_after_sub) return NULL;
          }
          ts = ts_after_sub;
          if (struct_alignment) ctx->struct_alignment = struct_alignment;
        }
        break;
      case '}':
        {
          size_t alignment = ctx->struct_alignment;
          ++ts;
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0;
          if (alignment && ctx->fmt_offset % alignment) {
            ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
          }
        }
        return ts;
      case 'x':
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        ctx->fmt_offset += ctx->new_count;
        ctx->new_count = 1;
        ctx->enc_count = 0;
        ctx->enc_type = 0;
        ctx->enc_packmode = ctx->new_packmode;
        ++ts;
        break;
      case 'Z':
        got_Z = 1;
        ++ts;
        if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
          __Pyx_BufFmt_RaiseUnexpectedChar('Z');
          return NULL;
        }
        CYTHON_FALLTHROUGH;
      case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
      case 'l': case 'L': case 'q': case 'Q':
      case 'f': case 'd': case 'g':
      case 'O': case 'p':
        if (ctx->enc_type == *ts && got_Z == ctx->is_complex &&
            ctx->enc_packmode == ctx->new_packmode) {
          ctx->enc_count += ctx->new_count;
          ctx->new_count = 1;
          got_Z = 0;
          ++ts;
          break;
        }
        CYTHON_FALLTHROUGH;
      case 's':
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        ctx->enc_count = ctx->new_count;
        ctx->enc_packmode = ctx->new_packmode;
        ctx->enc_type = *ts;
        ctx->is_complex = got_Z;
        ++ts;
        ctx->new_count = 1;
        got_Z = 0;
        break;
      case ':':
        ++ts;
        while(*ts != ':') ++ts;
        ++ts;
        break;
      case '(':
        if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
        break;
      default:
        {
          int number = __Pyx_BufFmt_ExpectNumber(&ts);
          if (number == -1) return NULL;
          ctx->new_count = (size_t)number;
        }
    }
  }
}

/* TypeInfoCompare */
                      static int
__pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b)
{
    int i;
    if (!a || !b)
        return 0;
    if (a == b)
        return 1;
    if (a->size != b->size || a->typegroup != b->typegroup ||
            a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) {
        if (a->typegroup == 'H' || b->typegroup == 'H') {
            return a->size == b->size;
        } else {
            return 0;
        }
    }
    if (a->ndim) {
        for (i = 0; i < a->ndim; i++)
            if (a->arraysize[i] != b->arraysize[i])
                return 0;
    }
    if (a->typegroup == 'S') {
        if (a->flags != b->flags)
            return 0;
        if (a->fields || b->fields) {
            if (!(a->fields && b->fields))
                return 0;
            for (i = 0; a->fields[i].type && b->fields[i].type; i++) {
                __Pyx_StructField *field_a = a->fields + i;
                __Pyx_StructField *field_b = b->fields + i;
                if (field_a->offset != field_b->offset ||
                    !__pyx_typeinfo_cmp(field_a->type, field_b->type))
                    return 0;
            }
            return !a->fields[i].type && !b->fields[i].type;
        }
    }
    return 1;
}

/* MemviewSliceValidateAndInit */
                      static int
__pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec)
{
    if (buf->shape[dim] <= 1)
        return 1;
    if (buf->strides) {
        if (spec & __Pyx_MEMVIEW_CONTIG) {
            if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) {
                if (buf->strides[dim] != sizeof(void *)) {
                    PyErr_Format(PyExc_ValueError,
                                 "Buffer is not indirectly contiguous "
                                 "in dimension %d.", dim);
                    goto fail;
                }
            } else if (buf->strides[dim] != buf->itemsize) {
                PyErr_SetString(PyExc_ValueError,
                                "Buffer and memoryview are not contiguous "
                                "in the same dimension.");
                goto fail;
            }
        }
        if (spec & __Pyx_MEMVIEW_FOLLOW) {
            Py_ssize_t stride = buf->strides[dim];
            if (stride < 0)
                stride = -stride;
            if (stride < buf->itemsize) {
                PyErr_SetString(PyExc_ValueError,
                                "Buffer and memoryview are not contiguous "
                                "in the same dimension.");
                goto fail;
            }
        }
    } else {
        if (spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1) {
            PyErr_Format(PyExc_ValueError,
                         "C-contiguous buffer is not contiguous in "
                         "dimension %d", dim);
            goto fail;
        } else if (spec & (__Pyx_MEMVIEW_PTR)) {
            PyErr_Format(PyExc_ValueError,
                         "C-contiguous buffer is not indirect in "
                         "dimension %d", dim);
            goto fail;
        } else if (buf->suboffsets) {
            PyErr_SetString(PyExc_ValueError,
                            "Buffer exposes suboffsets but no strides");
            goto fail;
        }
    }
    return 1;
fail:
    return 0;
}
static int
__pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec)
{
    if (spec & __Pyx_MEMVIEW_DIRECT) {
        if (buf->suboffsets && buf->suboffsets[dim] >= 0) {
            PyErr_Format(PyExc_ValueError,
                         "Buffer not compatible with direct access "
                         "in dimension %d.", dim);
            goto fail;
        }
    }
    if (spec & __Pyx_MEMVIEW_PTR) {
        if (!buf->suboffsets || (buf->suboffsets && buf->suboffsets[dim] < 0)) {
            PyErr_Format(PyExc_ValueError,
                         "Buffer is not indirectly accessible "
                         "in dimension %d.", dim);
            goto fail;
        }
    }
    return 1;
fail:
    return 0;
}
static int
__pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag)
{
    int i;
    if (c_or_f_flag & __Pyx_IS_F_CONTIG) {
        Py_ssize_t stride = 1;
        for (i = 0; i < ndim; i++) {
            if (stride * buf->itemsize != buf->strides[i] &&
                    buf->shape[i] > 1)
            {
                PyErr_SetString(PyExc_ValueError,
                    "Buffer not fortran contiguous.");
                goto fail;
            }
            stride = stride * buf->shape[i];
        }
    } else if (c_or_f_flag & __Pyx_IS_C_CONTIG) {
        Py_ssize_t stride = 1;
        for (i = ndim - 1; i >- 1; i--) {
            if (stride * buf->itemsize != buf->strides[i] &&
                    buf->shape[i] > 1) {
                PyErr_SetString(PyExc_ValueError,
                    "Buffer not C contiguous.");
                goto fail;
            }
            stride = stride * buf->shape[i];
        }
    }
    return 1;
fail:
    return 0;
}
static int __Pyx_ValidateAndInit_memviewslice(
                int *axes_specs,
                int c_or_f_flag,
                int buf_flags,
                int ndim,
                __Pyx_TypeInfo *dtype,
                __Pyx_BufFmt_StackElem stack[],
                __Pyx_memviewslice *memviewslice,
                PyObject *original_obj)
{
    struct __pyx_memoryview_obj *memview, *new_memview;
    __Pyx_RefNannyDeclarations
    Py_buffer *buf;
    int i, spec = 0, retval = -1;
    __Pyx_BufFmt_Context ctx;
    int from_memoryview = __pyx_memoryview_check(original_obj);
    __Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0);
    if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *)
                                                            original_obj)->typeinfo)) {
        memview = (struct __pyx_memoryview_obj *) original_obj;
        new_memview = NULL;
    } else {
        memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
                                            original_obj, buf_flags, 0, dtype);
        new_memview = memview;
        if (unlikely(!memview))
            goto fail;
    }
    buf = &memview->view;
    if (buf->ndim != ndim) {
        PyErr_Format(PyExc_ValueError,
                "Buffer has wrong number of dimensions (expected %d, got %d)",
                ndim, buf->ndim);
        goto fail;
    }
    if (new_memview) {
        __Pyx_BufFmt_Init(&ctx, stack, dtype);
        if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
    }
    if ((unsigned) buf->itemsize != dtype->size) {
        PyErr_Format(PyExc_ValueError,
                     "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) "
                     "does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)",
                     buf->itemsize,
                     (buf->itemsize > 1) ? "s" : "",
                     dtype->name,
                     dtype->size,
                     (dtype->size > 1) ? "s" : "");
        goto fail;
    }
    for (i = 0; i < ndim; i++) {
        spec = axes_specs[i];
        if (!__pyx_check_strides(buf, i, ndim, spec))
            goto fail;
        if (!__pyx_check_suboffsets(buf, i, ndim, spec))
            goto fail;
    }
    if (buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag))
        goto fail;
    if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice,
                                         new_memview != NULL) == -1)) {
        goto fail;
    }
    retval = 0;
    goto no_fail;
fail:
    Py_XDECREF(new_memview);
    retval = -1;
no_fail:
    __Pyx_RefNannyFinishContext();
    return retval;
}

/* ObjectToMemviewSlice */
                      static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_Py_ssize_t(PyObject *obj, int writable_flag) {
    __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
    __Pyx_BufFmt_StackElem stack[1];
    int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
    int retcode;
    if (obj == Py_None) {
        result.memview = (struct __pyx_memoryview_obj *) Py_None;
        return result;
    }
    retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
                                                 PyBUF_RECORDS_RO | writable_flag, 1,
                                                 &__Pyx_TypeInfo_Py_ssize_t, stack,
                                                 &result, obj);
    if (unlikely(retcode == -1))
        goto __pyx_fail;
    return result;
__pyx_fail:
    result.memview = NULL;
    result.data = NULL;
    return result;
}

/* ObjectToMemviewSlice */
                      static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_Py_ssize_t(PyObject *obj, int writable_flag) {
    __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
    __Pyx_BufFmt_StackElem stack[1];
    int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
    int retcode;
    if (obj == Py_None) {
        result.memview = (struct __pyx_memoryview_obj *) Py_None;
        return result;
    }
    retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
                                                 PyBUF_RECORDS_RO | writable_flag, 2,
                                                 &__Pyx_TypeInfo_Py_ssize_t, stack,
                                                 &result, obj);
    if (unlikely(retcode == -1))
        goto __pyx_fail;
    return result;
__pyx_fail:
    result.memview = NULL;
    result.data = NULL;
    return result;
}

/* CheckBinaryVersion */
                      static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        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;
}

/* FunctionExport */
                      static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
    if (!d) {
        PyErr_Clear();
        d = PyDict_New();
        if (!d)
            goto bad;
        Py_INCREF(d);
        if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
            goto bad;
    }
    tmp.fp = f;
#if PY_VERSION_HEX >= 0x02070000
    cobj = PyCapsule_New(tmp.p, sig, 0);
#else
    cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
#endif
    if (!cobj)
        goto bad;
    if (PyDict_SetItemString(d, name, cobj) < 0)
        goto bad;
    Py_DECREF(cobj);
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(cobj);
    Py_XDECREF(d);
    return -1;
}

/* ModuleImport */
                      #ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

/* TypeImport */
                      #ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    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 (!strict && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
            module_name, class_name, basicsize, size);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    else if ((size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
            module_name, class_name, basicsize, size);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

/* FunctionImport */
                      #ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

/* 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 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(x);
  }
#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 PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
