/* Generated by Cython 0.28.3 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "define_macros": [
            [
                "_FORCE_INLINES",
                "1"
            ]
        ],
        "depends": [],
        "extra_link_args": [
            "-Wl,--disable-new-dtags,-rpath,/usr/local/cuda/lib64"
        ],
        "include_dirs": [
            "/usr/local/cuda/include"
        ],
        "language": "c++",
        "libraries": [
            "cublas",
            "cuda",
            "cudart",
            "cufft",
            "curand",
            "cusparse",
            "nvrtc"
        ],
        "library_dirs": [
            "/usr/local/cuda/lib64"
        ],
        "name": "cupy.core.core",
        "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_3"
#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
  #define PyObject_Unicode             PyObject_Str
#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 <stdint.h>
#include <utility>
#include <map>
#include <string.h>
#include <stdio.h>
#include "pythread.h"
#include "../cuda/cupy_cuda.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)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
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 = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;

/* 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/core.pxd",
  "stringsource",
  "cupy/cuda/device.pxd",
  "cupy/cuda/memory.pxd",
  "cupy/cuda/function.pxd",
  "type.pxd",
  "bool.pxd",
  "complex.pxd",
  "cupy/core/_carray.pxd",
  "cupy/core/_scalar.pxd",
  "cupy/core/_kernel.pxd",
  "cupy/core/_routines_manipulation.pxd",
  "cupy/cuda/pinned_memory.pxd",
  "cupy/cuda/runtime.pxd",
};

/* "internal.pxd":39
 * cpdef size_t clp2(size_t x)
 * 
 * ctypedef unsigned short _float16             # <<<<<<<<<<<<<<
 * 
 * cpdef uint16_t to_float16(float f)
 */
typedef unsigned short __pyx_t_4cupy_4core_8internal__float16;
/* 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_Handle;
struct __pyx_obj_4cupy_4cuda_6device_Device;
struct __pyx_obj_4cupy_4cuda_6memory_BaseMemory;
struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer;
struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool;
struct __pyx_obj_4cupy_4cuda_6memory_CFunctionAllocatorMemory;
struct __pyx_obj_4cupy_4cuda_6memory_CFunctionAllocator;
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_4core_7_carray_CArray;
struct __pyx_obj_4cupy_4core_7_carray_CIndexer;
struct __pyx_obj_4cupy_4core_7_carray_Indexer;
struct __pyx_obj_4cupy_4core_7_scalar_CScalar;
struct __pyx_obj_4cupy_4core_7_kernel_ParameterInfo;
struct __pyx_obj_4cupy_4core_7_kernel__ArgInfo;
struct __pyx_obj_4cupy_4core_7_kernel__TypeMap;
struct __pyx_obj_4cupy_4core_7_kernel__Op;
struct __pyx_obj_4cupy_4core_7_kernel__Ops;
struct __pyx_obj_4cupy_4core_22_routines_manipulation_broadcast;
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___pyx_scope_struct____iter__;
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr;
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_10MemoryPool_free_all_blocks;
struct __pyx_opt_args_4cupy_4cuda_6memory_10MemoryPool_set_limit;

/* "memory.pxd":30
 * 
 *     cpdef copy_from_device(self, MemoryPointer src, size_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":33
 *                                  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":35
 *     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":37
 *     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":39
 *     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=?)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_memset_async {
  int __pyx_n;
  PyObject *stream;
};

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

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

/* "memory.pxd":64
 *     cpdef size_t free_bytes(self)
 *     cpdef size_t total_bytes(self)
 *     cpdef set_limit(self, size=?, fraction=?)             # <<<<<<<<<<<<<<
 *     cpdef size_t get_limit(self)
 * 
 */
struct __pyx_opt_args_4cupy_4cuda_6memory_10MemoryPool_set_limit {
  int __pyx_n;
  PyObject *size;
  PyObject *fraction;
};
struct __pyx_opt_args_4cupy_4cuda_8function_8Function_linear_launch;

/* "cupy/cuda/function.pxd":14
 *         public intptr_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_t_4cupy_4core_7_carray__CArray;
struct __pyx_t_4cupy_4core_7_carray__CIndexer;

/* "_carray.pxd":10
 * 
 * 
 * cdef struct _CArray:             # <<<<<<<<<<<<<<
 *     void* data
 *     Py_ssize_t size
 */
struct __pyx_t_4cupy_4core_7_carray__CArray {
  void *data;
  Py_ssize_t size;
  Py_ssize_t shape_and_strides[(25 * 2)];
};

/* "_carray.pxd":28
 * 
 * 
 * cdef struct _CIndexer:             # <<<<<<<<<<<<<<
 *     Py_ssize_t size
 *     Py_ssize_t shape_and_index[MAX_NDIM * 2]
 */
struct __pyx_t_4cupy_4core_7_carray__CIndexer {
  Py_ssize_t size;
  Py_ssize_t shape_and_index[(25 * 2)];
};
struct __pyx_opt_args_4cupy_4core_7_kernel_create_ufunc;

/* "cupy/core/_kernel.pxd":17
 * 
 * 
 * cdef enum _ArgKind:             # <<<<<<<<<<<<<<
 *     ARG_KIND_NDARRAY = 1
 *     ARG_KIND_INDEXER
 */
enum __pyx_t_4cupy_4core_7_kernel__ArgKind {
  __pyx_e_4cupy_4core_7_kernel_ARG_KIND_NDARRAY = 1,
  __pyx_e_4cupy_4core_7_kernel_ARG_KIND_INDEXER,
  __pyx_e_4cupy_4core_7_kernel_ARG_KIND_SCALAR
};

/* "cupy/core/_kernel.pxd":122
 * 
 * 
 * cpdef create_ufunc(name, ops, routine=*, preamble=*, doc=*,             # <<<<<<<<<<<<<<
 *                    default_casting=*, loop_prep=*, out_ops=*)
 * 
 */
struct __pyx_opt_args_4cupy_4core_7_kernel_create_ufunc {
  int __pyx_n;
  PyObject *routine;
  PyObject *preamble;
  PyObject *doc;
  PyObject *default_casting;
  PyObject *loop_prep;
  PyObject *out_ops;
};
struct __pyx_opt_args_4cupy_4core_22_routines_manipulation_rollaxis;
struct __pyx_opt_args_4cupy_4core_22_routines_manipulation_concatenate_method;

/* "_routines_manipulation.pxd":26
 * cpdef ndarray _expand_dims(ndarray a, tuple axis)
 * cpdef ndarray moveaxis(ndarray a, source, destination)
 * cpdef ndarray rollaxis(ndarray a, Py_ssize_t axis, Py_ssize_t start=*)             # <<<<<<<<<<<<<<
 * cpdef ndarray broadcast_to(ndarray array, shape)
 * cpdef ndarray _reshape(ndarray self,
 */
struct __pyx_opt_args_4cupy_4core_22_routines_manipulation_rollaxis {
  int __pyx_n;
  Py_ssize_t start;
};

/* "_routines_manipulation.pxd":34
 * cpdef ndarray _concatenate(
 *     list arrays, Py_ssize_t axis, tuple shape, ndarray out)
 * cpdef ndarray concatenate_method(tup, int axis, ndarray out=*)             # <<<<<<<<<<<<<<
 */
struct __pyx_opt_args_4cupy_4core_22_routines_manipulation_concatenate_method {
  int __pyx_n;
  struct __pyx_obj_4cupy_4core_4core_ndarray *out;
};
struct __pyx_opt_args_4cupy_4core_14_routines_math_scan;

/* "_routines_math.pxd":18
 * cpdef ndarray _nanprod(ndarray a, axis, dtype, out, keepdims)
 * 
 * cpdef enum scan_op:             # <<<<<<<<<<<<<<
 *     SCAN_SUM = 0
 *     SCAN_PROD = 1
 */
enum __pyx_t_4cupy_4core_14_routines_math_scan_op {
  __pyx_e_4cupy_4core_14_routines_math_SCAN_SUM = 0,
  __pyx_e_4cupy_4core_14_routines_math_SCAN_PROD = 1
};

/* "_routines_math.pxd":22
 *     SCAN_PROD = 1
 * 
 * cdef ndarray scan(ndarray a, op, dtype=*, ndarray out=*)             # <<<<<<<<<<<<<<
 * cdef object _sum_auto_dtype
 * cdef object _add
 */
struct __pyx_opt_args_4cupy_4core_14_routines_math_scan {
  int __pyx_n;
  PyObject *dtype;
  struct __pyx_obj_4cupy_4core_4core_ndarray *out;
};
struct __pyx_opt_args_4cupy_4core_8internal__normalize_order;

/* "internal.pxd":45
 * cpdef float from_float16(uint16_t v)
 * 
 * cdef int _normalize_order(order, cpp_bool allow_k=*) except? 0             # <<<<<<<<<<<<<<
 * 
 * cdef _broadcast_core(list arrays, vector.vector[Py_ssize_t]& shape)
 */
struct __pyx_opt_args_4cupy_4core_8internal__normalize_order {
  int __pyx_n;
  bool allow_k;
};

/* "cublas.pxd":30
 * ###############################################################################
 * 
 * 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_DEFAULT = -1L,
  __pyx_e_4cupy_4cuda_6cublas_CUBLAS_GEMM_DEFAULT_TENSOR_OP = 99,
  __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":21
 * 
 * 
 * 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_malloc3DArray;
struct __pyx_opt_args_4cupy_4cuda_7runtime_mallocArray;
struct __pyx_opt_args_4cupy_4cuda_7runtime_streamAddCallback;
struct __pyx_opt_args_4cupy_4cuda_7runtime_streamWaitEvent;

/* "runtime.pxd":99
 * ###############################################################################
 * 
 * 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_cudaDevAttrMaxThreadsPerBlock = 1,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxBlockDimX = 2,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxBlockDimY = 3,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxBlockDimZ = 4,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxGridDimX = 5,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxGridDimY = 6,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxGridDimZ = 7,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSharedMemoryPerBlock = 8,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrTotalConstantMemory = 9,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrWarpSize = 10,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxPitch = 11,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxRegistersPerBlock = 12,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrClockRate = 13,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrTextureAlignment = 14,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrGpuOverlap = 15,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMultiProcessorCount = 16,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrKernelExecTimeout = 17,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrIntegrated = 18,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrCanMapHostMemory = 19,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrComputeMode = 20,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture1DWidth = 21,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture2DWidth = 22,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture2DHeight = 23,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture3DWidth = 24,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture3DHeight = 25,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture3DDepth = 26,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture2DLayeredWidth = 27,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture2DLayeredHeight = 28,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture2DLayeredLayers = 29,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrSurfaceAlignment = 30,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrConcurrentKernels = 31,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrEccEnabled = 32,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrPciBusId = 33,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrPciDeviceId = 34,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrTccDriver = 35,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMemoryClockRate = 36,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrGlobalMemoryBusWidth = 37,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrL2CacheSize = 38,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxThreadsPerMultiProcessor = 39,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrAsyncEngineCount = 40,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrUnifiedAddressing = 41,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture1DLayeredWidth = 42,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture1DLayeredLayers = 43,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture2DGatherWidth = 45,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture2DGatherHeight = 46,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture3DWidthAlt = 47,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture3DHeightAlt = 48,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture3DDepthAlt = 49,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrPciDomainId = 50,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrTexturePitchAlignment = 51,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTextureCubemapWidth = 52,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTextureCubemapLayeredWidth = 53,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTextureCubemapLayeredLayers = 54,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSurface1DWidth = 55,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSurface2DWidth = 56,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSurface2DHeight = 57,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSurface3DWidth = 58,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSurface3DHeight = 59,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSurface3DDepth = 60,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSurface1DLayeredWidth = 61,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSurface1DLayeredLayers = 62,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSurface2DLayeredWidth = 63,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSurface2DLayeredHeight = 64,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSurface2DLayeredLayers = 65,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSurfaceCubemapWidth = 66,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSurfaceCubemapLayeredWidth = 67,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSurfaceCubemapLayeredLayers = 68,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture1DLinearWidth = 69,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture2DLinearWidth = 70,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture2DLinearHeight = 71,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture2DLinearPitch = 72,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture2DMipmappedWidth = 73,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture2DMipmappedHeight = 74,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxTexture1DMipmappedWidth = 77,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrStreamPrioritiesSupported = 78,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrGlobalL1CacheSupported = 79,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrLocalL1CacheSupported = 80,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSharedMemoryPerMultiprocessor = 81,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxRegistersPerMultiprocessor = 82,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrManagedMemory = 83,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrIsMultiGpuBoard = 84,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMultiGpuBoardGroupID = 85,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrHostNativeAtomicSupported = 86,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrSingleToDoublePrecisionPerfRatio = 87,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrPageableMemoryAccess = 88,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrConcurrentManagedAccess = 89,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrComputePreemptionSupported = 90,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrCanUseHostPointerForRegisteredMem = 91,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrReserved92 = 92,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrReserved93 = 93,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrReserved94 = 94,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrCooperativeLaunch = 95,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrCooperativeMultiDeviceLaunch = 96,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrMaxSharedMemoryPerBlockOptin = 97,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrCanFlushRemoteWrites = 98,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrHostRegisterSupported = 99,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrPageableMemoryAccessUsesHostPageTables = 0x64,
  __pyx_e_4cupy_4cuda_7runtime_cudaDevAttrDirectManagedMemAccessFromHost = 0x65,
  __pyx_e_4cupy_4cuda_7runtime_cudaChannelFormatKindSigned = 0,
  __pyx_e_4cupy_4cuda_7runtime_cudaChannelFormatKindUnsigned = 1,
  __pyx_e_4cupy_4cuda_7runtime_cudaChannelFormatKindFloat = 2,
  __pyx_e_4cupy_4cuda_7runtime_cudaChannelFormatKindNone = 3,
  __pyx_e_4cupy_4cuda_7runtime_cudaResourceTypeArray = 0,
  __pyx_e_4cupy_4cuda_7runtime_cudaResourceTypeMipmappedArray = 1,
  __pyx_e_4cupy_4cuda_7runtime_cudaResourceTypeLinear = 2,
  __pyx_e_4cupy_4cuda_7runtime_cudaResourceTypePitch2D = 3,
  __pyx_e_4cupy_4cuda_7runtime_cudaAddressModeWrap = 0,
  __pyx_e_4cupy_4cuda_7runtime_cudaAddressModeClamp = 1,
  __pyx_e_4cupy_4cuda_7runtime_cudaAddressModeMirror = 2,
  __pyx_e_4cupy_4cuda_7runtime_cudaAddressModeBorder = 3,
  __pyx_e_4cupy_4cuda_7runtime_cudaFilterModePoint = 0,
  __pyx_e_4cupy_4cuda_7runtime_cudaFilterModeLinear = 1,
  __pyx_e_4cupy_4cuda_7runtime_cudaReadModeElementType = 0,
  __pyx_e_4cupy_4cuda_7runtime_cudaReadModeNormalizedFloat = 1
};

/* "runtime.pxd":326
 * 
 * cpdef intptr_t malloc(size_t size) except? 0
 * cpdef intptr_t mallocManaged(size_t size, unsigned int flags=*) except? 0             # <<<<<<<<<<<<<<
 * cpdef intptr_t malloc3DArray(intptr_t desc, size_t width, size_t height,
 *                              size_t depth, unsigned int flags=*) except? 0
 */
struct __pyx_opt_args_4cupy_4cuda_7runtime_mallocManaged {
  int __pyx_n;
  unsigned int flags;
};

/* "runtime.pxd":327
 * cpdef intptr_t malloc(size_t size) except? 0
 * cpdef intptr_t mallocManaged(size_t size, unsigned int flags=*) except? 0
 * cpdef intptr_t malloc3DArray(intptr_t desc, size_t width, size_t height,             # <<<<<<<<<<<<<<
 *                              size_t depth, unsigned int flags=*) except? 0
 * cpdef intptr_t mallocArray(intptr_t desc, size_t width, size_t height,
 */
struct __pyx_opt_args_4cupy_4cuda_7runtime_malloc3DArray {
  int __pyx_n;
  unsigned int flags;
};

/* "runtime.pxd":329
 * cpdef intptr_t malloc3DArray(intptr_t desc, size_t width, size_t height,
 *                              size_t depth, unsigned int flags=*) except? 0
 * cpdef intptr_t mallocArray(intptr_t desc, size_t width, size_t height,             # <<<<<<<<<<<<<<
 *                            unsigned int flags=*) except? 0
 * cpdef intptr_t hostAlloc(size_t size, unsigned int flags) except? 0
 */
struct __pyx_opt_args_4cupy_4cuda_7runtime_mallocArray {
  int __pyx_n;
  unsigned int flags;
};

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

/* "runtime.pxd":384
 *                         unsigned int flags=*)
 * cpdef streamQuery(intptr_t stream)
 * cpdef streamWaitEvent(intptr_t stream, intptr_t event, unsigned int flags=*)             # <<<<<<<<<<<<<<
 * cpdef intptr_t eventCreate() except? 0
 * cpdef intptr_t eventCreateWithFlags(unsigned int flags) except? 0
 */
struct __pyx_opt_args_4cupy_4cuda_7runtime_streamWaitEvent {
  int __pyx_n;
  unsigned int flags;
};
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tobytes;
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_ravel;
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_put;
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_sort;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argsort;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_partition;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argpartition;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_compress;
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_ptp;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_round;
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_cumsum;
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_cumprod;
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_ascontiguousarray;
struct __pyx_opt_args_4cupy_4core_4core_asfortranarray;
struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache;
struct __pyx_opt_args_4cupy_4core_4core_array;
struct __pyx_opt_args_4cupy_4core_4core__get_strides_for_order_K;
struct __pyx_opt_args_4cupy_4core_4core__create_bit_op;
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;

/* "cupy/core/core.pxd":25
 *     cpdef item(self)
 *     cpdef tolist(self)
 *     cpdef bytes tobytes(self, order=*)             # <<<<<<<<<<<<<<
 *     cpdef tofile(self, fid, sep=*, format=*)
 *     cpdef dump(self, file)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tobytes {
  int __pyx_n;
  PyObject *order;
};

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

/* "cupy/core/core.pxd":29
 *     cpdef dump(self, file)
 *     cpdef bytes 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":30
 *     cpdef bytes 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":31
 *     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 swapaxes(self, Py_ssize_t axis1, Py_ssize_t axis2)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view {
  int __pyx_n;
  PyObject *dtype;
};

/* "cupy/core/core.pxd":35
 *     cpdef ndarray swapaxes(self, Py_ssize_t axis1, Py_ssize_t axis2)
 *     cpdef ndarray flatten(self)
 *     cpdef ndarray ravel(self, order=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray squeeze(self, axis=*)
 *     cpdef ndarray take(self, indices, axis=*, out=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_ravel {
  int __pyx_n;
  PyObject *order;
};

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

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

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

/* "cupy/core/core.pxd":39
 *     cpdef ndarray take(self, indices, axis=*, out=*)
 *     cpdef put(self, indices, values, mode=*)
 *     cpdef repeat(self, repeats, axis=*)             # <<<<<<<<<<<<<<
 *     cpdef choose(self, choices, out=*, mode=*)
 *     cpdef sort(self, int axis=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat {
  int __pyx_n;
  PyObject *axis;
};

/* "cupy/core/core.pxd":40
 *     cpdef put(self, indices, values, mode=*)
 *     cpdef repeat(self, repeats, axis=*)
 *     cpdef choose(self, choices, out=*, mode=*)             # <<<<<<<<<<<<<<
 *     cpdef sort(self, int axis=*)
 *     cpdef ndarray argsort(self, axis=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_choose {
  int __pyx_n;
  PyObject *out;
  PyObject *mode;
};

/* "cupy/core/core.pxd":41
 *     cpdef repeat(self, repeats, axis=*)
 *     cpdef choose(self, choices, out=*, mode=*)
 *     cpdef sort(self, int axis=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray argsort(self, axis=*)
 *     cpdef partition(self, kth, int axis=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sort {
  int __pyx_n;
  int axis;
};

/* "cupy/core/core.pxd":42
 *     cpdef choose(self, choices, out=*, mode=*)
 *     cpdef sort(self, int axis=*)
 *     cpdef ndarray argsort(self, axis=*)             # <<<<<<<<<<<<<<
 *     cpdef partition(self, kth, int axis=*)
 *     cpdef ndarray argpartition(self, kth, axis=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argsort {
  int __pyx_n;
  PyObject *axis;
};

/* "cupy/core/core.pxd":43
 *     cpdef sort(self, int axis=*)
 *     cpdef ndarray argsort(self, axis=*)
 *     cpdef partition(self, kth, int axis=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray argpartition(self, kth, axis=*)
 *     cpdef tuple nonzero(self)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_partition {
  int __pyx_n;
  int axis;
};

/* "cupy/core/core.pxd":44
 *     cpdef ndarray argsort(self, axis=*)
 *     cpdef partition(self, kth, int axis=*)
 *     cpdef ndarray argpartition(self, kth, axis=*)             # <<<<<<<<<<<<<<
 *     cpdef tuple nonzero(self)
 *     cpdef ndarray compress(self, condition, axis=*, out=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argpartition {
  int __pyx_n;
  PyObject *axis;
};

/* "cupy/core/core.pxd":46
 *     cpdef ndarray argpartition(self, kth, axis=*)
 *     cpdef tuple nonzero(self)
 *     cpdef ndarray compress(self, condition, axis=*, out=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray diagonal(self, offset=*, axis1=*, axis2=*)
 *     cpdef ndarray max(self, axis=*, out=*, keepdims=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_compress {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
};

/* "cupy/core/core.pxd":47
 *     cpdef tuple nonzero(self)
 *     cpdef ndarray compress(self, condition, axis=*, out=*)
 *     cpdef ndarray diagonal(self, offset=*, axis1=*, axis2=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray max(self, axis=*, out=*, 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":48
 *     cpdef ndarray compress(self, condition, axis=*, out=*)
 *     cpdef ndarray diagonal(self, offset=*, axis1=*, axis2=*)
 *     cpdef ndarray max(self, axis=*, out=*, 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 *keepdims;
};

/* "cupy/core/core.pxd":49
 *     cpdef ndarray diagonal(self, offset=*, axis1=*, axis2=*)
 *     cpdef ndarray max(self, axis=*, out=*, keepdims=*)
 *     cpdef ndarray argmax(self, axis=*, out=*, dtype=*,             # <<<<<<<<<<<<<<
 *                          keepdims=*)
 *     cpdef ndarray min(self, axis=*, out=*, 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":51
 *     cpdef ndarray argmax(self, axis=*, out=*, dtype=*,
 *                          keepdims=*)
 *     cpdef ndarray min(self, axis=*, out=*, 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 *keepdims;
};

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

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

/* "cupy/core/core.pxd":55
 *                          keepdims=*)
 *     cpdef ndarray ptp(self, axis=*, out=*, keepdims=*)
 *     cpdef ndarray clip(self, a_min=*, a_max=*, out=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray round(self, decimals=*, out=*)
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip {
  int __pyx_n;
  PyObject *a_min;
  PyObject *a_max;
  PyObject *out;
};

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

/* "cupy/core/core.pxd":58
 *     cpdef ndarray round(self, decimals=*, 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":60
 *     cpdef ndarray trace(self, offset=*, axis1=*, axis2=*, dtype=*,
 *                         out=*)
 *     cpdef ndarray sum(self, axis=*, dtype=*, out=*, keepdims=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray cumsum(self, axis=*, dtype=*, out=*)
 *     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":61
 *                         out=*)
 *     cpdef ndarray sum(self, axis=*, dtype=*, out=*, keepdims=*)
 *     cpdef ndarray cumsum(self, axis=*, dtype=*, out=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray mean(self, axis=*, dtype=*, out=*, keepdims=*)
 *     cpdef ndarray var(self, axis=*, dtype=*, out=*, ddof=*,
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_cumsum {
  int __pyx_n;
  PyObject *axis;
  PyObject *dtype;
  PyObject *out;
};

/* "cupy/core/core.pxd":62
 *     cpdef ndarray sum(self, axis=*, dtype=*, out=*, keepdims=*)
 *     cpdef ndarray cumsum(self, axis=*, dtype=*, out=*)
 *     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":63
 *     cpdef ndarray cumsum(self, axis=*, dtype=*, out=*)
 *     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":65
 *     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":67
 *     cpdef ndarray std(self, axis=*, dtype=*, out=*, ddof=*,
 *                       keepdims=*)
 *     cpdef ndarray prod(self, axis=*, dtype=*, out=*, keepdims=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray cumprod(self, axis=*, dtype=*, out=*)
 *     cpdef ndarray all(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":68
 *                       keepdims=*)
 *     cpdef ndarray prod(self, axis=*, dtype=*, out=*, keepdims=*)
 *     cpdef ndarray cumprod(self, axis=*, dtype=*, out=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray all(self, axis=*, out=*, keepdims=*)
 *     cpdef ndarray any(self, axis=*, out=*, keepdims=*)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_cumprod {
  int __pyx_n;
  PyObject *axis;
  PyObject *dtype;
  PyObject *out;
};

/* "cupy/core/core.pxd":69
 *     cpdef ndarray prod(self, axis=*, dtype=*, out=*, keepdims=*)
 *     cpdef ndarray cumprod(self, axis=*, dtype=*, out=*)
 *     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":70
 *     cpdef ndarray cumprod(self, axis=*, dtype=*, out=*)
 *     cpdef ndarray all(self, axis=*, out=*, keepdims=*)
 *     cpdef ndarray any(self, axis=*, out=*, keepdims=*)             # <<<<<<<<<<<<<<
 *     cpdef ndarray conj(self)
 *     cpdef ndarray conjugate(self)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any {
  int __pyx_n;
  PyObject *axis;
  PyObject *out;
  PyObject *keepdims;
};

/* "cupy/core/core.pxd":73
 *     cpdef ndarray conj(self)
 *     cpdef ndarray conjugate(self)
 *     cpdef get(self, stream=*, order=*, out=*)             # <<<<<<<<<<<<<<
 *     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;
  PyObject *order;
  PyObject *out;
};

/* "cupy/core/core.pxd":74
 *     cpdef ndarray conjugate(self)
 *     cpdef get(self, stream=*, order=*, out=*)
 *     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":75
 *     cpdef get(self, stream=*, order=*, out=*)
 *     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":95
 * cpdef ndarray _internal_ascontiguousarray(ndarray a)
 * cpdef ndarray _internal_asfortranarray(ndarray a)
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=*)             # <<<<<<<<<<<<<<
 * cpdef ndarray asfortranarray(ndarray a, dtype=*)
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray {
  int __pyx_n;
  PyObject *dtype;
};

/* "cupy/core/core.pxd":96
 * cpdef ndarray _internal_asfortranarray(ndarray a)
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=*)
 * cpdef ndarray asfortranarray(ndarray a, dtype=*)             # <<<<<<<<<<<<<<
 * 
 * cpdef Module compile_with_cache(str source, tuple options=*, arch=*,
 */
struct __pyx_opt_args_4cupy_4core_4core_asfortranarray {
  int __pyx_n;
  PyObject *dtype;
};

/* "cupy/core/core.pxd":98
 * cpdef ndarray asfortranarray(ndarray a, dtype=*)
 * 
 * cpdef Module compile_with_cache(str source, tuple options=*, arch=*,             # <<<<<<<<<<<<<<
 *                                 cachd_dir=*, prepend_cupy_headers=*,
 *                                 backend=*, translate_cucomplex=*,
 */
struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache {
  int __pyx_n;
  PyObject *options;
  PyObject *arch;
  PyObject *cachd_dir;
  PyObject *prepend_cupy_headers;
  PyObject *backend;
  PyObject *translate_cucomplex;
  PyObject *enable_cooperative_groups;
};

/* "cupy/core/core.pxd":105
 * 
 * # TODO(niboshi): Move to _routines_creation.pyx
 * cpdef ndarray array(obj, dtype=*, bint copy=*, order=*, bint subok=*,             # <<<<<<<<<<<<<<
 *                     Py_ssize_t ndmin=*)
 * cpdef ndarray _convert_object_with_cuda_array_interface(a)
 */
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":1706
 * 
 * 
 * cpdef vector.vector[Py_ssize_t] _get_strides_for_order_K(ndarray x, dtype,             # <<<<<<<<<<<<<<
 *                                                          shape=None):
 *     cdef vector.vector[Py_ssize_t] strides
 */
struct __pyx_opt_args_4cupy_4core_4core__get_strides_for_order_K {
  int __pyx_n;
  PyObject *shape;
};

/* "cupy/core/core.pyx":2292
 * # -----------------------------------------------------------------------------
 * 
 * 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":2378
 * # -----------------------------------------------------------------------------
 * 
 * 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":2480
 * 
 * 
 * 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":2885
 * # -----------------------------------------------------------------------------
 * 
 * cpdef create_comparison(name, op, doc='', no_complex_dtype=True):             # <<<<<<<<<<<<<<
 * 
 *     if no_complex_dtype:
 */
struct __pyx_opt_args_4cupy_4core_4core_create_comparison {
  int __pyx_n;
  PyObject *doc;
  PyObject *no_complex_dtype;
};

/* "device.pxd":7
 * cpdef str get_compute_capability()
 * 
 * cdef class Handle:             # <<<<<<<<<<<<<<
 *     cdef:
 *         public size_t handle
 */
struct __pyx_obj_4cupy_4cuda_6device_Handle {
  PyObject_HEAD
  size_t handle;
  PyObject *_destroy_func;
};


/* "device.pxd":12
 *         object _destroy_func
 * 
 * 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":11
 * 
 * @cython.no_gc
 * cdef class BaseMemory:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_BaseMemory {
  PyObject_HEAD
  intptr_t ptr;
  size_t size;
  int device_id;
};


/* "memory.pxd":20
 * 
 * @cython.final
 * cdef class MemoryPointer:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *__pyx_vtab;
  intptr_t ptr;
  int device_id;
  struct __pyx_obj_4cupy_4cuda_6memory_BaseMemory *mem;
};


/* "memory.pxd":52
 * 
 * 
 * cdef class MemoryPool:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPool *__pyx_vtab;
  PyObject *_pools;
};


/* "memory.pxd":69
 * 
 * @cython.no_gc
 * cdef class CFunctionAllocatorMemory(BaseMemory):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_CFunctionAllocatorMemory {
  struct __pyx_obj_4cupy_4cuda_6memory_BaseMemory __pyx_base;
  intptr_t _param;
  intptr_t _free_func;
};


/* "memory.pxd":76
 * 
 * 
 * cdef class CFunctionAllocator:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_CFunctionAllocator {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_6memory_CFunctionAllocator *__pyx_vtab;
  intptr_t _param;
  intptr_t _malloc_func;
  intptr_t _free_func;
  PyObject *_owner;
};


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


/* "cupy/cuda/function.pxd":8
 * 
 * 
 * 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;
  intptr_t ptr;
};


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


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


/* "_carray.pxd":17
 * 
 * @cython.final
 * cdef class CArray(function.CPointer):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4core_7_carray_CArray {
  struct __pyx_obj_4cupy_4cuda_8function_CPointer __pyx_base;
  struct __pyx_vtabstruct_4cupy_4core_7_carray_CArray *__pyx_vtab;
  struct __pyx_t_4cupy_4core_7_carray__CArray val;
};


/* "_carray.pxd":33
 * 
 * 
 * cdef class CIndexer(function.CPointer):             # <<<<<<<<<<<<<<
 *     cdef:
 *         _CIndexer val
 */
struct __pyx_obj_4cupy_4core_7_carray_CIndexer {
  struct __pyx_obj_4cupy_4cuda_8function_CPointer __pyx_base;
  struct __pyx_t_4cupy_4core_7_carray__CIndexer val;
};


/* "_carray.pxd":38
 * 
 * 
 * cdef class Indexer:             # <<<<<<<<<<<<<<
 *     cdef:
 *         readonly Py_ssize_t size
 */
struct __pyx_obj_4cupy_4core_7_carray_Indexer {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4core_7_carray_Indexer *__pyx_vtab;
  Py_ssize_t size;
  PyObject *shape;
};


/* "_scalar.pxd":10
 * 
 * @cython.final
 * cdef class CScalar(CPointer):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4core_7_scalar_CScalar {
  struct __pyx_obj_4cupy_4cuda_8function_CPointer __pyx_base;
  struct __pyx_vtabstruct_4cupy_4core_7_scalar_CScalar *__pyx_vtab;
  char kind;
  int8_t size;
};


/* "cupy/core/_kernel.pxd":8
 * 
 * 
 * cdef class ParameterInfo:             # <<<<<<<<<<<<<<
 *     cdef:
 *         readonly str name
 */
struct __pyx_obj_4cupy_4core_7_kernel_ParameterInfo {
  PyObject_HEAD
  PyObject *name;
  PyObject *dtype;
  PyObject *ctype;
  int raw;
  int is_const;
};


/* "cupy/core/_kernel.pxd":23
 * 
 * 
 * cdef class _ArgInfo:             # <<<<<<<<<<<<<<
 *     # Holds metadata of an argument.
 *     # This class is immutable and used as a part of hash keys.
 */
struct __pyx_obj_4cupy_4core_7_kernel__ArgInfo {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4core_7_kernel__ArgInfo *__pyx_vtab;
  enum __pyx_t_4cupy_4core_7_kernel__ArgKind arg_kind;
  PyTypeObject *type;
  PyObject *dtype;
  int ndim;
  int c_contiguous;
};


/* "cupy/core/_kernel.pxd":59
 * 
 * 
 * cdef class _TypeMap:             # <<<<<<<<<<<<<<
 *     # Typedef mapping between C types.
 *     # This class is immutable.
 */
struct __pyx_obj_4cupy_4core_7_kernel__TypeMap {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4core_7_kernel__TypeMap *__pyx_vtab;
  PyObject *_pairs;
};


/* "cupy/core/_kernel.pxd":69
 * 
 * 
 * cdef class _Op:             # <<<<<<<<<<<<<<
 *     """Simple data structure that represents a kernel routine with single \
 * concrete dtype mapping.
 */
struct __pyx_obj_4cupy_4core_7_kernel__Op {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4core_7_kernel__Op *__pyx_vtab;
  PyObject *in_types;
  PyObject *out_types;
  int nin;
  int nout;
  PyObject *routine;
  PyObject *error_func;
};


/* "cupy/core/_kernel.pxd":101
 * 
 * 
 * cdef class _Ops:             # <<<<<<<<<<<<<<
 *     """A kernel routine representation with various dtype mappings.
 *     """
 */
struct __pyx_obj_4cupy_4core_7_kernel__Ops {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4core_7_kernel__Ops *__pyx_vtab;
  PyObject *ops;
  int nin;
  int nout;
};


/* "_routines_manipulation.pxd":6
 * 
 * 
 * cdef class broadcast:             # <<<<<<<<<<<<<<
 *     cdef:
 *         readonly tuple values
 */
struct __pyx_obj_4cupy_4core_22_routines_manipulation_broadcast {
  PyObject_HEAD
  PyObject *values;
  PyObject *shape;
  Py_ssize_t size;
  Py_ssize_t nd;
};


/* "pinned_memory.pxd":4
 * 
 * 
 * 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;
  intptr_t ptr;
  Py_ssize_t _shape[1];
  Py_ssize_t _strides[1];
};


/* "pinned_memory.pxd":24
 * 
 * 
 * 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;
  size_t _allocation_unit_size;
};


/* "runtime.pxd":8
 * ###############################################################################
 * 
 * cdef class PointerAttributes:             # <<<<<<<<<<<<<<
 *     cdef:
 *         public int device
 */
struct __pyx_obj_4cupy_4cuda_7runtime_PointerAttributes {
  PyObject_HEAD
  int device;
  intptr_t devicePointer;
  intptr_t hostPointer;
};


/* "cupy/core/core.pxd":7
 * from cupy.cuda.function cimport Module
 * 
 * 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.pyx":1173
 *     # Container customization:
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         if self._shape.size() == 0:
 *             raise TypeError('iteration over a 0-d array')
 */
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__ {
  PyObject_HEAD
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self;
};


/* "cupy/core/core.pyx":1176
 *         if self._shape.size() == 0:
 *             raise TypeError('iteration over a 0-d array')
 *         return (self[i] for i in range(self._shape[0]))             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct_1_genexpr {
  PyObject_HEAD
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__ *__pyx_outer_scope;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_t_0;
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
};



/* "device.pxd":12
 *         object _destroy_func
 * 
 * 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":20
 * 
 * @cython.final
 * cdef class MemoryPointer:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer {
  PyObject *(*_init)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, struct __pyx_obj_4cupy_4cuda_6memory_BaseMemory *, ptrdiff_t);
  PyObject *(*copy_from_device)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *, size_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);
  PyObject *(*_set_peer_access)(int, int);
};
static struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *__pyx_vtabptr_4cupy_4cuda_6memory_MemoryPointer;


/* "memory.pxd":52
 * 
 * 
 * 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 *, size_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);
  size_t (*n_free_blocks)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool *, int __pyx_skip_dispatch);
  size_t (*used_bytes)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool *, int __pyx_skip_dispatch);
  size_t (*free_bytes)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool *, int __pyx_skip_dispatch);
  size_t (*total_bytes)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool *, int __pyx_skip_dispatch);
  PyObject *(*set_limit)(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4cuda_6memory_10MemoryPool_set_limit *__pyx_optional_args);
  size_t (*get_limit)(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;


/* "memory.pxd":76
 * 
 * 
 * cdef class CFunctionAllocator:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_4cupy_4cuda_6memory_CFunctionAllocator {
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *(*malloc)(struct __pyx_obj_4cupy_4cuda_6memory_CFunctionAllocator *, size_t, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4cupy_4cuda_6memory_CFunctionAllocator *__pyx_vtabptr_4cupy_4cuda_6memory_CFunctionAllocator;


/* "cupy/cuda/function.pxd":8
 * 
 * 
 * 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":18
 * 
 * 
 * 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);
  PyObject *(*get_texref)(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":30
 * 
 * 
 * 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 *(*add_ptr_file)(struct __pyx_obj_4cupy_4cuda_8function_LinkState *, 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;


/* "_carray.pxd":17
 * 
 * @cython.final
 * cdef class CArray(function.CPointer):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_4cupy_4core_7_carray_CArray {
  void (*init)(struct __pyx_obj_4cupy_4core_7_carray_CArray *, void *, Py_ssize_t, std::vector<Py_ssize_t>  const &, std::vector<Py_ssize_t>  const &);
};
static struct __pyx_vtabstruct_4cupy_4core_7_carray_CArray *__pyx_vtabptr_4cupy_4core_7_carray_CArray;


/* "_carray.pxd":38
 * 
 * 
 * cdef class Indexer:             # <<<<<<<<<<<<<<
 *     cdef:
 *         readonly Py_ssize_t size
 */

struct __pyx_vtabstruct_4cupy_4core_7_carray_Indexer {
  struct __pyx_obj_4cupy_4cuda_8function_CPointer *(*get_pointer)(struct __pyx_obj_4cupy_4core_7_carray_Indexer *);
};
static struct __pyx_vtabstruct_4cupy_4core_7_carray_Indexer *__pyx_vtabptr_4cupy_4core_7_carray_Indexer;


/* "_scalar.pxd":10
 * 
 * @cython.final
 * cdef class CScalar(CPointer):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_4cupy_4core_7_scalar_CScalar {
  struct __pyx_obj_4cupy_4core_7_scalar_CScalar *(*from_int32)(int32_t);
  struct __pyx_obj_4cupy_4core_7_scalar_CScalar *(*from_numpy_scalar_with_dtype)(PyObject *, PyObject *);
  struct __pyx_obj_4cupy_4core_7_scalar_CScalar *(*_from_python_scalar)(PyObject *);
  struct __pyx_obj_4cupy_4core_7_scalar_CScalar *(*_from_numpy_scalar)(PyObject *);
  PyObject *(*apply_dtype)(struct __pyx_obj_4cupy_4core_7_scalar_CScalar *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*get_numpy_type)(struct __pyx_obj_4cupy_4core_7_scalar_CScalar *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4cupy_4core_7_scalar_CScalar *__pyx_vtabptr_4cupy_4core_7_scalar_CScalar;


/* "cupy/core/_kernel.pxd":23
 * 
 * 
 * cdef class _ArgInfo:             # <<<<<<<<<<<<<<
 *     # Holds metadata of an argument.
 *     # This class is immutable and used as a part of hash keys.
 */

struct __pyx_vtabstruct_4cupy_4core_7_kernel__ArgInfo {
  struct __pyx_obj_4cupy_4core_7_kernel__ArgInfo *(*from_arg)(PyObject *);
  struct __pyx_obj_4cupy_4core_7_kernel__ArgInfo *(*from_ndarray)(struct __pyx_obj_4cupy_4core_4core_ndarray *);
  struct __pyx_obj_4cupy_4core_7_kernel__ArgInfo *(*from_scalar)(struct __pyx_obj_4cupy_4core_7_scalar_CScalar *);
  struct __pyx_obj_4cupy_4core_7_kernel__ArgInfo *(*from_indexer)(struct __pyx_obj_4cupy_4core_7_carray_Indexer *);
  struct __pyx_obj_4cupy_4core_7_kernel__ArgInfo *(*as_ndarray_with_ndim)(struct __pyx_obj_4cupy_4core_7_kernel__ArgInfo *, int);
  int (*is_ndarray)(struct __pyx_obj_4cupy_4core_7_kernel__ArgInfo *);
  int (*is_scalar)(struct __pyx_obj_4cupy_4core_7_kernel__ArgInfo *);
  PyObject *(*get_c_type)(struct __pyx_obj_4cupy_4core_7_kernel__ArgInfo *);
  PyObject *(*get_param_c_type)(struct __pyx_obj_4cupy_4core_7_kernel__ArgInfo *, struct __pyx_obj_4cupy_4core_7_kernel_ParameterInfo *);
  PyObject *(*get_c_var_name)(struct __pyx_obj_4cupy_4core_7_kernel__ArgInfo *, struct __pyx_obj_4cupy_4core_7_kernel_ParameterInfo *);
};
static struct __pyx_vtabstruct_4cupy_4core_7_kernel__ArgInfo *__pyx_vtabptr_4cupy_4core_7_kernel__ArgInfo;


/* "cupy/core/_kernel.pxd":59
 * 
 * 
 * cdef class _TypeMap:             # <<<<<<<<<<<<<<
 *     # Typedef mapping between C types.
 *     # This class is immutable.
 */

struct __pyx_vtabstruct_4cupy_4core_7_kernel__TypeMap {
  PyObject *(*get_typedef_code)(struct __pyx_obj_4cupy_4core_7_kernel__TypeMap *);
};
static struct __pyx_vtabstruct_4cupy_4core_7_kernel__TypeMap *__pyx_vtabptr_4cupy_4core_7_kernel__TypeMap;


/* "cupy/core/_kernel.pxd":69
 * 
 * 
 * cdef class _Op:             # <<<<<<<<<<<<<<
 *     """Simple data structure that represents a kernel routine with single \
 * concrete dtype mapping.
 */

struct __pyx_vtabstruct_4cupy_4core_7_kernel__Op {
  struct __pyx_obj_4cupy_4core_7_kernel__Op *(*_from_type_and_routine_or_error_func)(PyObject *, PyObject *, PyObject *);
  struct __pyx_obj_4cupy_4core_7_kernel__Op *(*from_type_and_routine)(PyObject *, PyObject *);
  struct __pyx_obj_4cupy_4core_7_kernel__Op *(*from_type_and_error_func)(PyObject *, PyObject *);
  PyObject *(*check_valid)(struct __pyx_obj_4cupy_4core_7_kernel__Op *);
};
static struct __pyx_vtabstruct_4cupy_4core_7_kernel__Op *__pyx_vtabptr_4cupy_4core_7_kernel__Op;


/* "cupy/core/_kernel.pxd":101
 * 
 * 
 * cdef class _Ops:             # <<<<<<<<<<<<<<
 *     """A kernel routine representation with various dtype mappings.
 *     """
 */

struct __pyx_vtabstruct_4cupy_4core_7_kernel__Ops {
  struct __pyx_obj_4cupy_4core_7_kernel__Ops *(*from_tuples)(PyObject *, PyObject *);
  struct __pyx_obj_4cupy_4core_7_kernel__Op *(*guess_routine)(struct __pyx_obj_4cupy_4core_7_kernel__Ops *, PyObject *, PyObject *, PyObject *, PyObject *, struct __pyx_obj_4cupy_4core_7_kernel__Ops *);
  struct __pyx_obj_4cupy_4core_7_kernel__Op *(*_guess_routine_from_in_types)(struct __pyx_obj_4cupy_4core_7_kernel__Ops *, PyObject *);
  struct __pyx_obj_4cupy_4core_7_kernel__Op *(*_guess_routine_from_dtype)(struct __pyx_obj_4cupy_4core_7_kernel__Ops *, PyObject *);
};
static struct __pyx_vtabstruct_4cupy_4core_7_kernel__Ops *__pyx_vtabptr_4cupy_4core_7_kernel__Ops;


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

struct __pyx_vtabstruct_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer {
  size_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":24
 * 
 * 
 * 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 *, size_t, int __pyx_skip_dispatch);
  PyObject *(*free)(struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPool *, intptr_t, size_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":64
 * 
 * 
 * cdef class ndarray:             # <<<<<<<<<<<<<<
 * 
 *     """Multi-dimensional array on a CUDA device.
 */

struct __pyx_vtabstruct_4cupy_4core_4core_ndarray {
  PyObject *(*_init_fast)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  const &, PyObject *, int);
  PyObject *(*item)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  PyObject *(*tolist)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  PyObject *(*tobytes)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tobytes *__pyx_optional_args);
  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 *(*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_opt_args_4cupy_4core_4core_7ndarray_ravel *__pyx_optional_args);
  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 *(*put)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_put *__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);
  PyObject *(*sort)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sort *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*argsort)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argsort *__pyx_optional_args);
  PyObject *(*partition)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_partition *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*argpartition)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argpartition *__pyx_optional_args);
  PyObject *(*nonzero)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*compress)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_compress *__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 *(*ptp)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_ptp *__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 *(*round)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_round *__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 *(*cumsum)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_cumsum *__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 *(*cumprod)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_cumprod *__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);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*conjugate)(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>  const &, std::vector<Py_ssize_t>  const &, int, int, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*_view)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  const &, std::vector<Py_ssize_t>  const &, int, int);
  PyObject *(*_set_contiguous_strides)(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, int, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4cuda_8function_CPointer *(*get_pointer)(struct __pyx_obj_4cupy_4core_4core_ndarray *);
  PyObject *(*toDlpack)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *__pyx_vtabptr_4cupy_4core_4core_ndarray;

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

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

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

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

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

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

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

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

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

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

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

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

/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* SwapException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
#endif

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

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

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

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

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

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

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

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

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

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

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

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

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

/* 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 void __Pyx_RaiseUnboundLocalError(const char *varname);

/* tp_new.proto */
#define __Pyx_tp_new(type_obj, args) __Pyx_tp_new_kwargs(type_obj, args, NULL)
static CYTHON_INLINE PyObject* __Pyx_tp_new_kwargs(PyObject* type_obj, PyObject* args, PyObject* kwargs) {
    return (PyObject*) (((PyTypeObject*)type_obj)->tp_new((PyTypeObject*)type_obj, args, kwargs));
}

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

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

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

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

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

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

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

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

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

/* PyUnicodeContains.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_ContainsTF(PyObject* substring, PyObject* text, int eq) {
    int result = PyUnicode_Contains(text, substring);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* SliceObject.proto */
#define __Pyx_PyObject_DelSlice(obj, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)\
    __Pyx_PyObject_SetSlice(obj, (PyObject*)NULL, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)
static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
        PyObject* obj, PyObject* value, 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);

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

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

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

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

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

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

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

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

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

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(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 *);

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

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

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

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

/* VoidPtrImport.proto */
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);

/* 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__init_fast(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  const &__pyx_v_shape, PyObject *__pyx_v_dtype, int __pyx_v_c_order); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_item(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
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_tobytes(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tobytes *__pyx_optional_args); /* 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_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, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_ravel *__pyx_optional_args); /* 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_put(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_indices, PyObject *__pyx_v_values, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_put *__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 PyObject *__pyx_f_4cupy_4core_4core_7ndarray_sort(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sort *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_argsort(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argsort *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_partition(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_kth, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_partition *__pyx_optional_args); /* proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_argpartition(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_kth, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argpartition *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_nonzero(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_compress(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_condition, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_compress *__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_ptp(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_ptp *__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_round(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_round *__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_cumsum(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_cumsum *__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_cumprod(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_cumprod *__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 struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_conjugate(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>  const &__pyx_v_shape, std::vector<Py_ssize_t>  const &__pyx_v_strides, int __pyx_v_update_c_contiguity, int __pyx_v_update_f_contiguity, int __pyx_skip_dispatch); /* 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, std::vector<Py_ssize_t>  const &__pyx_v_shape, std::vector<Py_ssize_t>  const &__pyx_v_strides, int __pyx_v_update_c_contiguity, int __pyx_v_update_f_contiguity); /* proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__set_contiguous_strides(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, Py_ssize_t __pyx_v_itemsize, int __pyx_v_is_c_contiguous, int __pyx_skip_dispatch); /* 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 PyObject *__pyx_f_4cupy_4core_4core_7ndarray_toDlpack(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/

/* Module declarations from 'libcpp' */

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

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

/* Module declarations from 'cython' */

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

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

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

/* Module declarations from 'cupy.cuda.device' */
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6device_Handle = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6device_Device = 0;

/* Module declarations from 'cupy.cuda.memory' */
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_BaseMemory = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_MemoryPointer = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_MemoryPool = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocatorMemory = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocator = 0;
static struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *(*__pyx_f_4cupy_4cuda_6memory_alloc)(PyObject *, 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 'cupy.core' */

/* Module declarations from 'cupy.core._carray' */
static PyTypeObject *__pyx_ptype_4cupy_4core_7_carray_CArray = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_7_carray_CIndexer = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_7_carray_Indexer = 0;

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

/* Module declarations from 'cupy.core._scalar' */
static PyTypeObject *__pyx_ptype_4cupy_4core_7_scalar_CScalar = 0;

/* Module declarations from 'cupy.core._kernel' */
static PyTypeObject *__pyx_ptype_4cupy_4core_7_kernel_ParameterInfo = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_7_kernel__ArgInfo = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_7_kernel__TypeMap = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_7_kernel__Op = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_7_kernel__Ops = 0;
static PyObject *(*__pyx_f_4cupy_4core_7_kernel_create_ufunc)(PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_7_kernel_create_ufunc *__pyx_optional_args); /*proto*/

/* Module declarations from 'cupy.core._routines_indexing' */
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_18_routines_indexing__ndarray_getitem)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_4cupy_4core_18_routines_indexing__ndarray_setitem)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_4cupy_4core_18_routines_indexing__ndarray_nonzero)(struct __pyx_obj_4cupy_4core_4core_ndarray *); /*proto*/
static PyObject *(*__pyx_f_4cupy_4core_18_routines_indexing__ndarray_scatter_add)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_4cupy_4core_18_routines_indexing__ndarray_scatter_max)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_4cupy_4core_18_routines_indexing__ndarray_scatter_min)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_18_routines_indexing__ndarray_take)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_18_routines_indexing__ndarray_put)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_18_routines_indexing__ndarray_choose)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_18_routines_indexing__ndarray_compress)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_18_routines_indexing__ndarray_diagonal)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *); /*proto*/

/* Module declarations from 'cupy.core._routines_logic' */
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_15_routines_logic__ndarray_all)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_15_routines_logic__ndarray_any)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *); /*proto*/

/* Module declarations from 'cupy.core._routines_manipulation' */
static PyTypeObject *__pyx_ptype_4cupy_4core_22_routines_manipulation_broadcast = 0;
static PyObject *(*__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_shape_setter)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_reshape)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_transpose)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_swapaxes)(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, Py_ssize_t); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_flatten)(struct __pyx_obj_4cupy_4core_4core_ndarray *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_ravel)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_squeeze)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_repeat)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_22_routines_manipulation_rollaxis)(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_22_routines_manipulation_rollaxis *__pyx_optional_args); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_22_routines_manipulation__reshape)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  const &, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_22_routines_manipulation__T)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_22_routines_manipulation_concatenate_method)(PyObject *, int, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_22_routines_manipulation_concatenate_method *__pyx_optional_args); /*proto*/

/* Module declarations from 'cupy.core._routines_math' */
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__sum_auto_dtype = 0;
#define __pyx_v_4cupy_4core_14_routines_math__sum_auto_dtype (*__pyx_vp_4cupy_4core_14_routines_math__sum_auto_dtype)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__add = 0;
#define __pyx_v_4cupy_4core_14_routines_math__add (*__pyx_vp_4cupy_4core_14_routines_math__add)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__conj = 0;
#define __pyx_v_4cupy_4core_14_routines_math__conj (*__pyx_vp_4cupy_4core_14_routines_math__conj)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__angle = 0;
#define __pyx_v_4cupy_4core_14_routines_math__angle (*__pyx_vp_4cupy_4core_14_routines_math__angle)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__real = 0;
#define __pyx_v_4cupy_4core_14_routines_math__real (*__pyx_vp_4cupy_4core_14_routines_math__real)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__imag = 0;
#define __pyx_v_4cupy_4core_14_routines_math__imag (*__pyx_vp_4cupy_4core_14_routines_math__imag)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__negative = 0;
#define __pyx_v_4cupy_4core_14_routines_math__negative (*__pyx_vp_4cupy_4core_14_routines_math__negative)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__multiply = 0;
#define __pyx_v_4cupy_4core_14_routines_math__multiply (*__pyx_vp_4cupy_4core_14_routines_math__multiply)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__divide = 0;
#define __pyx_v_4cupy_4core_14_routines_math__divide (*__pyx_vp_4cupy_4core_14_routines_math__divide)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__power = 0;
#define __pyx_v_4cupy_4core_14_routines_math__power (*__pyx_vp_4cupy_4core_14_routines_math__power)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__subtract = 0;
#define __pyx_v_4cupy_4core_14_routines_math__subtract (*__pyx_vp_4cupy_4core_14_routines_math__subtract)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__true_divide = 0;
#define __pyx_v_4cupy_4core_14_routines_math__true_divide (*__pyx_vp_4cupy_4core_14_routines_math__true_divide)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__floor_divide = 0;
#define __pyx_v_4cupy_4core_14_routines_math__floor_divide (*__pyx_vp_4cupy_4core_14_routines_math__floor_divide)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__remainder = 0;
#define __pyx_v_4cupy_4core_14_routines_math__remainder (*__pyx_vp_4cupy_4core_14_routines_math__remainder)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__absolute = 0;
#define __pyx_v_4cupy_4core_14_routines_math__absolute (*__pyx_vp_4cupy_4core_14_routines_math__absolute)
static PyObject **__pyx_vp_4cupy_4core_14_routines_math__sqrt = 0;
#define __pyx_v_4cupy_4core_14_routines_math__sqrt (*__pyx_vp_4cupy_4core_14_routines_math__sqrt)
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_14_routines_math__ndarray_conj)(struct __pyx_obj_4cupy_4core_4core_ndarray *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_14_routines_math__ndarray_real_getter)(struct __pyx_obj_4cupy_4core_4core_ndarray *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_14_routines_math__ndarray_real_setter)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_14_routines_math__ndarray_imag_getter)(struct __pyx_obj_4cupy_4core_4core_ndarray *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_14_routines_math__ndarray_imag_setter)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_14_routines_math__ndarray_prod)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_14_routines_math__ndarray_sum)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_14_routines_math__ndarray_cumsum)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_14_routines_math__ndarray_cumprod)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_14_routines_math__ndarray_clip)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *); /*proto*/

/* Module declarations from 'cupy.core._routines_sorting' */
static PyObject *(*__pyx_f_4cupy_4core_17_routines_sorting__ndarray_sort)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_17_routines_sorting__ndarray_argsort)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_4cupy_4core_17_routines_sorting__ndarray_partition)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_17_routines_sorting__ndarray_argpartition)(PyObject *, PyObject *, PyObject *); /*proto*/

/* Module declarations from 'cupy.core._routines_statistics' */
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_20_routines_statistics__ndarray_max)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_20_routines_statistics__ndarray_min)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_20_routines_statistics__ndarray_ptp)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_20_routines_statistics__ndarray_argmax)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_20_routines_statistics__ndarray_argmin)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_20_routines_statistics__ndarray_mean)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_20_routines_statistics__ndarray_var)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_20_routines_statistics__ndarray_std)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/

/* Module declarations from 'cupy.core.dlpack' */
static PyObject *(*__pyx_f_4cupy_4core_6dlpack_toDlpack)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.core.internal' */
static Py_ssize_t (*__pyx_f_4cupy_4core_8internal_prod)(std::vector<Py_ssize_t>  const &, int __pyx_skip_dispatch); /*proto*/
static Py_ssize_t (*__pyx_f_4cupy_4core_8internal_prod_sequence)(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4core_8internal_get_size)(PyObject *, 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 Py_ssize_t (*__pyx_f_4cupy_4core_8internal_get_contiguous_strides_inplace)(std::vector<Py_ssize_t>  const &, std::vector<Py_ssize_t>  &, Py_ssize_t, int); /*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 int (*__pyx_f_4cupy_4core_8internal__normalize_order)(PyObject *, struct __pyx_opt_args_4cupy_4core_8internal__normalize_order *__pyx_optional_args); /*proto*/

/* Module declarations from 'cupy.cuda.cublas' */
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_setMathMode)(intptr_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_dgemm)(intptr_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)(intptr_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)(intptr_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_sgemmBatched)(intptr_t, int, int, int, int, int, float, size_t, int, size_t, int, float, size_t, int, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_dgemmBatched)(intptr_t, int, int, int, int, int, double, size_t, int, size_t, int, double, size_t, int, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_cgemmBatched)(intptr_t, int, int, int, int, int, __pyx_t_float_complex, size_t, int, size_t, int, __pyx_t_float_complex, size_t, int, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_zgemmBatched)(intptr_t, int, int, int, int, int, __pyx_t_double_complex, size_t, int, size_t, int, __pyx_t_double_complex, size_t, int, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_sgemmStridedBatched)(intptr_t, int, int, int, int, int, float, size_t, int, PY_LONG_LONG, size_t, int, PY_LONG_LONG, float, size_t, int, PY_LONG_LONG, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_dgemmStridedBatched)(intptr_t, int, int, int, int, int, double, size_t, int, PY_LONG_LONG, size_t, int, PY_LONG_LONG, double, size_t, int, PY_LONG_LONG, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_cgemmStridedBatched)(intptr_t, int, int, int, int, int, __pyx_t_float_complex, size_t, int, PY_LONG_LONG, size_t, int, PY_LONG_LONG, __pyx_t_float_complex, size_t, int, PY_LONG_LONG, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_zgemmStridedBatched)(intptr_t, int, int, int, int, int, __pyx_t_double_complex, size_t, int, PY_LONG_LONG, size_t, int, PY_LONG_LONG, __pyx_t_double_complex, size_t, int, PY_LONG_LONG, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_sgeam)(intptr_t, int, int, int, int, float, size_t, int, float, size_t, int, size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_dgeam)(intptr_t, int, int, int, int, double, size_t, int, double, size_t, int, size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_sgemmEx)(intptr_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)(intptr_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)(size_t, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.cuda.runtime' */
static PyTypeObject *__pyx_ptype_4cupy_4cuda_7runtime_PointerAttributes = 0;
static int *__pyx_vp_4cupy_4cuda_7runtime__is_hip_environment = 0;
#define __pyx_v_4cupy_4cuda_7runtime__is_hip_environment (*__pyx_vp_4cupy_4cuda_7runtime__is_hip_environment)
static int *__pyx_vp_4cupy_4cuda_7runtime_deviceAttributeComputeCapabilityMajor = 0;
#define __pyx_v_4cupy_4cuda_7runtime_deviceAttributeComputeCapabilityMajor (*__pyx_vp_4cupy_4cuda_7runtime_deviceAttributeComputeCapabilityMajor)
static int *__pyx_vp_4cupy_4cuda_7runtime_deviceAttributeComputeCapabilityMinor = 0;
#define __pyx_v_4cupy_4cuda_7runtime_deviceAttributeComputeCapabilityMinor (*__pyx_vp_4cupy_4cuda_7runtime_deviceAttributeComputeCapabilityMinor)
static int (*__pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_7runtime_setDevice)(int, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.cuda.stream' */
static intptr_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___pyx_scope_struct____iter__ = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core___pyx_scope_struct_1_genexpr = 0;
static PyObject *__pyx_v_4cupy_4core_4core__HANDLED_TYPES = 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__id = 0;
static PyObject *__pyx_v_4cupy_4core_4core_fill_kernel = 0;
static PyObject *__pyx_v_4cupy_4core_4core__divmod_float = 0;
static PyObject *__pyx_v_4cupy_4core_4core__round_preamble = 0;
static PyObject *__pyx_v_4cupy_4core_4core__round_float = 0;
static PyObject *__pyx_v_4cupy_4core_4core__round_complex = 0;
static int __pyx_v_4cupy_4core_4core__numpy_concatenate_has_out_argument;
static PyObject *__pyx_v_4cupy_4core_4core__mat_ptrs_kernel = 0;
static int __pyx_v_4cupy_4core_4core__cuda_runtime_version;
static PyObject *__pyx_v_4cupy_4core_4core__tensordot_core_mul_sum = 0;
static PyObject *__pyx_8genexpr3__pyx_v_4cupy_4core_4core_i;
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(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__internal_asfortranarray(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_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 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 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 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__convert_object_with_cuda_array_interface(PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__ndarray_init(std::vector<Py_ssize_t>  const &, PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__should_use_rop(PyObject *, PyObject *); /*proto*/
static CYTHON_INLINE struct __pyx_obj_4cupy_4core_7_carray_CArray *__pyx_f_4cupy_4core_4core__CArray_from_ndarray(struct __pyx_obj_4cupy_4core_4core_ndarray *); /*proto*/
static int __pyx_f_4cupy_4core_4core__update_order_char(struct __pyx_obj_4cupy_4core_4core_ndarray *, int, int __pyx_skip_dispatch); /*proto*/
static std::vector<Py_ssize_t>  __pyx_f_4cupy_4core_4core__get_strides_for_order_K(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__get_strides_for_order_K *__pyx_optional_args); /*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 CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__translate_cucomplex_to_thrust(PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_concat_shape(PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__get_concat_shape_impl(PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core__flatten_list(PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__send_object_to_gpu(PyObject *, PyObject *, PyObject *, Py_ssize_t); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__send_numpy_array_list_to_gpu(PyObject *, PyObject *, PyObject *, std::vector<Py_ssize_t>  const &, PyObject *, Py_ssize_t); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__concatenate_numpy_array(PyObject *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__alloc_async_transfer_buffer(Py_ssize_t); /*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 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__mat_ptrs(struct __pyx_obj_4cupy_4core_4core_ndarray *); /*proto*/
static Py_ssize_t __pyx_f_4cupy_4core_4core__get_stride_for_strided_batched_gemm(struct __pyx_obj_4cupy_4core_4core_ndarray *); /*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>  const &, 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 std::vector<Py_ssize_t>  __pyx_convert_vector_from_py_Py_ssize_t(PyObject *); /*proto*/
static PyObject *__pyx_convert_vector_to_py_Py_ssize_t(const std::vector<Py_ssize_t>  &); /*proto*/
#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_TypeError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_chr;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_DeprecationWarning;
static PyObject *__pyx_builtin_NotImplemented;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_oct;
static PyObject *__pyx_builtin_hex;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_open;
static PyObject *__pyx_builtin_zip;
static const char __pyx_k_0[] = "0";
static const char __pyx_k_A[] = "A";
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_I[] = "-I ";
static const char __pyx_k_K[] = "K";
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_k[] = "k";
static const char __pyx_k_m[] = "m";
static const char __pyx_k_n[] = "n";
static const char __pyx_k_s[] = "%s";
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_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_ii[] = "ii->?";
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_re[] = "re";
static const char __pyx_k_B_B[] = "B->B";
static const char __pyx_k_H_H[] = "H->H";
static const char __pyx_k_I_I[] = "I->I";
static const char __pyx_k_I_s[] = "-I%s";
static const char __pyx_k_L_L[] = "L->L";
static const char __pyx_k_Q_Q[] = "Q->Q";
static const char __pyx_k_T_x[] = "T x";
static const char __pyx_k_T_y[] = "T y";
static const char __pyx_k__21[] = ".";
static const char __pyx_k__35[] = "\n";
static const char __pyx_k__44[] = "\077\077->?";
static const char __pyx_k__60[] = ",";
static const char __pyx_k__66[] = "#";
static const char __pyx_k__67[] = "<";
static const char __pyx_k__68[] = ">";
static const char __pyx_k__70[] = "&";
static const char __pyx_k__71[] = "|";
static const char __pyx_k__72[] = "^";
static const char __pyx_k__73[] = "?->?";
static const char __pyx_k__77[] = "<<";
static const char __pyx_k__78[] = ">>";
static const char __pyx_k__81[] = ">=";
static const char __pyx_k__82[] = "<=";
static const char __pyx_k__83[] = "==";
static const char __pyx_k__84[] = "!=";
static const char __pyx_k_a_b[] = "a + b";
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_b_b[] = "b->b";
static const char __pyx_k_chr[] = "chr";
static const char __pyx_k_doc[] = "doc";
static const char __pyx_k_fid[] = "fid";
static const char __pyx_k_get[] = "get";
static const char __pyx_k_h_h[] = "h->h";
static const char __pyx_k_hex[] = "hex";
static const char __pyx_k_i_i[] = "i->i";
static const char __pyx_k_kth[] = "kth";
static const char __pyx_k_l_l[] = "l->l";
static const char __pyx_k_lib[] = "lib";
static const char __pyx_k_max[] = "max";
static const char __pyx_k_min[] = "min";
static const char __pyx_k_obj[] = "obj";
static const char __pyx_k_oct[] = "oct";
static const char __pyx_k_out[] = "out";
static const char __pyx_k_ptp[] = "ptp";
static const char __pyx_k_put[] = "put";
static const char __pyx_k_q_e[] = "?q->e";
static const char __pyx_k_q_q[] = "q->q";
static const char __pyx_k_ror[] = "__ror__";
static const char __pyx_k_s_2[] = "\\s*";
static const char __pyx_k_sep[] = "sep";
static const char __pyx_k_set[] = "set";
static const char __pyx_k_std[] = "std";
static const char __pyx_k_str[] = "str";
static const char __pyx_k_sum[] = "sum";
static const char __pyx_k_sys[] = "sys";
static const char __pyx_k_var[] = "var";
static const char __pyx_k_y_x[] = "y = x";
static const char __pyx_k_zip[] = "zip";
static const char __pyx_k_BB_B[] = "BB->B";
static const char __pyx_k_Bq_B[] = "Bq->B";
static const char __pyx_k_Dq_D[] = "Dq->D";
static const char __pyx_k_Fq_F[] = "Fq->F";
static const char __pyx_k_HH_H[] = "HH->H";
static const char __pyx_k_Hq_H[] = "Hq->H";
static const char __pyx_k_II_I[] = "II->I";
static const char __pyx_k_Iq_I[] = "Iq->I";
static const char __pyx_k_KAka[] = "KAka";
static const char __pyx_k_LL_L[] = "LL->L";
static const char __pyx_k_Lq_L[] = "Lq->L";
static const char __pyx_k_QQ_Q[] = "QQ->Q";
static const char __pyx_k_Qq_Q[] = "Qq->Q";
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_bb_b[] = "bb->b";
static const char __pyx_k_bq_b[] = "bq->b";
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_ddof[] = "ddof";
static const char __pyx_k_dq_d[] = "dq->d";
static const char __pyx_k_dump[] = "dump";
static const char __pyx_k_eq_e[] = "eq->e";
static const char __pyx_k_exit[] = "__exit__";
static const char __pyx_k_fdFD[] = "fdFD";
static const char __pyx_k_file[] = "__file__";
static const char __pyx_k_fill[] = "fill";
static const char __pyx_k_fq_f[] = "fq->f";
static const char __pyx_k_func[] = "func";
static const char __pyx_k_hh_h[] = "hh->h";
static const char __pyx_k_hq_h[] = "hq->h";
static const char __pyx_k_ii_i[] = "ii->i";
static const char __pyx_k_iq_i[] = "iq->i";
static const char __pyx_k_item[] = "item";
static const char __pyx_k_join[] = "join";
static const char __pyx_k_kind[] = "kind";
static const char __pyx_k_less[] = "less";
static const char __pyx_k_ll_l[] = "ll->l";
static const char __pyx_k_lq_l[] = "lq->l";
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_open[] = "open";
static const char __pyx_k_path[] = "path";
static const char __pyx_k_prod[] = "prod";
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_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_send[] = "send";
static const char __pyx_k_size[] = "size";
static const char __pyx_k_sort[] = "sort";
static const char __pyx_k_take[] = "take";
static const char __pyx_k_test[] = "__test__";
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_BB_BB[] = "BB->BB";
static const char __pyx_k_Flags[] = "Flags";
static const char __pyx_k_HH_HH[] = "HH->HH";
static const char __pyx_k_II_II[] = "II->II";
static const char __pyx_k_LL_LL[] = "LL->LL";
static const char __pyx_k_QQ_QQ[] = "QQ->QQ";
static const char __pyx_k_T_out[] = "T out";
static const char __pyx_k_U_out[] = "U out";
static const char __pyx_k_a_max[] = "a_max";
static const char __pyx_k_a_min[] = "a_min";
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_bb_bb[] = "bb->bb";
static const char __pyx_k_close[] = "close";
static const char __pyx_k_dd_dd[] = "dd->dd";
static const char __pyx_k_descr[] = "descr";
static const char __pyx_k_dtype[] = "dtype";
static const char __pyx_k_dumps[] = "dumps";
static const char __pyx_k_ee_ee[] = "ee->ee";
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_ff_ff[] = "ff->ff";
static const char __pyx_k_flags[] = "flags";
static const char __pyx_k_hh_hh[] = "hh->hh";
static const char __pyx_k_ii_ii[] = "ii->ii";
static const char __pyx_k_ll_ll[] = "ll->ll";
static const char __pyx_k_match[] = "match";
static const char __pyx_k_ndmin[] = "ndmin";
static const char __pyx_k_numpy[] = "numpy";
static const char __pyx_k_nvrtc[] = "nvrtc";
static const char __pyx_k_order[] = "order";
static const char __pyx_k_out_a[] = "out = a";
static const char __pyx_k_qq_qq[] = "qq->qq";
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_round[] = "round";
static const char __pyx_k_shape[] = "shape";
static const char __pyx_k_split[] = "split";
static const char __pyx_k_subok[] = "subok";
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_uintp[] = "uintp";
static const char __pyx_k_upper[] = "upper";
static const char __pyx_k_value[] = "value";
static const char __pyx_k_zeros[] = "zeros";
static const char __pyx_k_1_14_0[] = "1.14.0";
static const char __pyx_k_argmax[] = "argmax";
static const char __pyx_k_argmin[] = "argmin";
static const char __pyx_k_astype[] = "astype";
static const char __pyx_k_choose[] = "choose";
static const char __pyx_k_ctypes[] = "ctypes";
static const char __pyx_k_cuda_2[] = "_cuda";
static const char __pyx_k_cumsum[] = "cumsum";
static const char __pyx_k_cupy_2[] = "cupy_";
static const char __pyx_k_device[] = "device";
static const char __pyx_k_divmod[] = "divmod";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_invert[] = "invert";
static const char __pyx_k_kwargs[] = "kwargs";
static const char __pyx_k_memory[] = "memory";
static const char __pyx_k_memptr[] = "memptr";
static const char __pyx_k_method[] = "method";
static const char __pyx_k_module[] = "__module__";
static const char __pyx_k_name_2[] = "name";
static const char __pyx_k_nbytes[] = "nbytes";
static const char __pyx_k_offset[] = "offset";
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_status[] = "status";
static const char __pyx_k_stream[] = "stream";
static const char __pyx_k_tofile[] = "tofile";
static const char __pyx_k_tolist[] = "tolist";
static const char __pyx_k_values[] = "values";
static const char __pyx_k_S_x_T_y[] = "S x, T y";
static const char __pyx_k_abspath[] = "abspath";
static const char __pyx_k_argsort[] = "argsort";
static const char __pyx_k_backend[] = "backend";
static const char __pyx_k_casting[] = "casting";
static const char __pyx_k_choices[] = "choices";
static const char __pyx_k_compile[] = "compile";
static const char __pyx_k_cumprod[] = "cumprod";
static const char __pyx_k_dirname[] = "dirname";
static const char __pyx_k_flatten[] = "flatten";
static const char __pyx_k_float32[] = "float32";
static const char __pyx_k_float64[] = "float64";
static const char __pyx_k_genexpr[] = "genexpr";
static const char __pyx_k_getattr[] = "getattr";
static const char __pyx_k_greater[] = "greater";
static const char __pyx_k_include[] = "include";
static const char __pyx_k_indices[] = "indices";
static const char __pyx_k_ndarray[] = "ndarray";
static const char __pyx_k_no_bool[] = "no_bool";
static const char __pyx_k_nonzero[] = "nonzero";
static const char __pyx_k_options[] = "options";
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_rrshift[] = "__rrshift__";
static const char __pyx_k_squeeze[] = "squeeze";
static const char __pyx_k_strides[] = "strides";
static const char __pyx_k_tobytes[] = "tobytes";
static const char __pyx_k_typestr[] = "typestr";
static const char __pyx_k_version[] = "version";
static const char __pyx_k_c_void_p[] = "c_void_p";
static const char __pyx_k_compress[] = "compress";
static const char __pyx_k_cuda_9_2[] = "cuda-9.2";
static const char __pyx_k_decimals[] = "decimals";
static const char __pyx_k_diagonal[] = "diagonal";
static const char __pyx_k_flatiter[] = "flatiter";
static const char __pyx_k_itemsize[] = "itemsize";
static const char __pyx_k_keepdims[] = "keepdims";
static const char __pyx_k_keepends[] = "keepends";
static const char __pyx_k_mat_ptrs[] = "mat_ptrs";
static const char __pyx_k_out0_in0[] = "out0 = in0";
static const char __pyx_k_rtruediv[] = "__rtruediv__";
static const char __pyx_k_swapaxes[] = "swapaxes";
static const char __pyx_k_toDlpack[] = "toDlpack";
static const char __pyx_k_warnings[] = "warnings";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_cachd_dir[] = "cachd_dir";
static const char __pyx_k_complex64[] = "complex64";
static const char __pyx_k_condition[] = "condition";
static const char __pyx_k_conjugate[] = "conjugate";
static const char __pyx_k_cuda_10_0[] = "cuda-10.0";
static const char __pyx_k_cuda_10_1[] = "cuda-10.1";
static const char __pyx_k_cuda_10_2[] = "cuda-10.2";
static const char __pyx_k_cupy_core[] = "cupy.core";
static const char __pyx_k_cupy_cuda[] = "cupy.cuda";
static const char __pyx_k_enumerate[] = "enumerate";
static const char __pyx_k_functools[] = "functools";
static const char __pyx_k_include_s[] = "#include <%s>\n";
static const char __pyx_k_not_equal[] = "not_equal";
static const char __pyx_k_partition[] = "partition";
static const char __pyx_k_ret_shape[] = "ret_shape";
static const char __pyx_k_rfloordiv[] = "__rfloordiv__";
static const char __pyx_k_signature[] = "signature";
static const char __pyx_k_version_2[] = "__version__";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_bitwise_or[] = "bitwise_or";
static const char __pyx_k_complex128[] = "complex128";
static const char __pyx_k_cupy_round[] = "cupy_round";
static const char __pyx_k_frombuffer[] = "frombuffer";
static const char __pyx_k_left_shift[] = "left_shift";
static const char __pyx_k_less_equal[] = "less_equal";
static const char __pyx_k_order_char[] = "order_char";
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_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_splitlines[] = "splitlines";
static const char __pyx_k_syncdetect[] = "syncdetect";
static const char __pyx_k_bitwise_and[] = "bitwise_and";
static const char __pyx_k_bitwise_xor[] = "bitwise_xor";
static const char __pyx_k_concatenate[] = "concatenate";
static const char __pyx_k_cuComplex_h[] = "cuComplex\\.h";
static const char __pyx_k_cupy_divmod[] = "cupy_divmod";
static const char __pyx_k_cupy_invert[] = "cupy_invert";
static const char __pyx_k_expand_dims[] = "expand_dims";
static const char __pyx_k_reduce_dims[] = "reduce_dims";
static const char __pyx_k_result_type[] = "result_type";
static const char __pyx_k_right_shift[] = "right_shift";
static const char __pyx_k_round_ufunc[] = "_round_ufunc";
static const char __pyx_k_NumpyVersion[] = "NumpyVersion";
static const char __pyx_k_RuntimeError[] = "RuntimeError";
static const char __pyx_k_argpartition[] = "argpartition";
static const char __pyx_k_c_contiguous[] = "c_contiguous";
static const char __pyx_k_create_ufunc[] = "create_ufunc";
static const char __pyx_k_f_contiguous[] = "f_contiguous";
static const char __pyx_k_reduced_view[] = "reduced_view";
static const char __pyx_k_UnownedMemory[] = "UnownedMemory";
static const char __pyx_k_get_cuda_path[] = "get_cuda_path";
static const char __pyx_k_get_device_id[] = "get_device_id";
static const char __pyx_k_greater_equal[] = "greater_equal";
static const char __pyx_k_memory_module[] = "memory_module";
static const char __pyx_k_promote_types[] = "promote_types";
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_array_priority[] = "__array_priority__";
static const char __pyx_k_asfortranarray[] = "asfortranarray";
static const char __pyx_k_cupy_core_core[] = "cupy.core.core";
static const char __pyx_k_out0_in0_s_in1[] = "out0 = in0 %s in1";
static const char __pyx_k_Invalid_dtype_s[] = "Invalid dtype: %s";
static const char __pyx_k_ReductionKernel[] = "ReductionKernel";
static const char __pyx_k_T_base_T_stride[] = "T base, T stride";
static const char __pyx_k_array_interface[] = "__array_interface__";
static const char __pyx_k_bhilqBHILQefdFD[] = "?bhilqBHILQefdFD";
static const char __pyx_k_cupy_carray_cuh[] = "cupy/carray.cuh";
static const char __pyx_k_is_c_contiguous[] = "is_c_contiguous";
static const char __pyx_k_CUDARuntimeError[] = "CUDARuntimeError";
static const char __pyx_k_cupy_atomics_cuh[] = "cupy/atomics.cuh";
static const char __pyx_k_cupy_complex_cuh[] = "cupy/complex.cuh";
static const char __pyx_k_elementwise_copy[] = "elementwise_copy";
static const char __pyx_k_no_complex_dtype[] = "no_complex_dtype";
static const char __pyx_k_ENABLE_SLICE_COPY[] = "ENABLE_SLICE_COPY";
static const char __pyx_k_ElementwiseKernel[] = "ElementwiseKernel";
static const char __pyx_k_ascontiguousarray[] = "ascontiguousarray";
static const char __pyx_k_cupy_core__kernel[] = "cupy.core._kernel";
static const char __pyx_k_cupy_core__ufuncs[] = "cupy.core._ufuncs";
static const char __pyx_k_cupy_cuda_runtime[] = "cupy.cuda.runtime";
static const char __pyx_k_get_cublas_handle[] = "get_cublas_handle";
static const char __pyx_k_unsupported_order[] = "unsupported order: {}";
static const char __pyx_k_update_contiguity[] = "_update_contiguity";
static const char __pyx_k_DeprecationWarning[] = "DeprecationWarning";
static const char __pyx_k_PerformanceWarning[] = "PerformanceWarning";
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_NotImplementedError[] = "NotImplementedError";
static const char __pyx_k_Unsupported_dtype_s[] = "Unsupported dtype %s";
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_declare_synchronize[] = "_declare_synchronize";
static const char __pyx_k_translate_cucomplex[] = "translate_cucomplex";
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_cuda_array_interface[] = "__cuda_array_interface__";
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_core__reduction[] = "cupy.core._reduction";
static const char __pyx_k_prepend_cupy_headers[] = "prepend_cupy_headers";
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_iter___locals_genexpr[] = "__iter__.<locals>.genexpr";
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_update_f_contiguity_2[] = "update_f_contiguity";
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_compute_capability[] = "get_compute_capability";
static const char __pyx_k_set_contiguous_strides[] = "_set_contiguous_strides";
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_cupy_cuComplex_bridge_h[] = "cupy/cuComplex_bridge.h";
static const char __pyx_k_cucomplex_include_tokens[] = "_cucomplex_include_tokens";
static const char __pyx_k_cucomplex_include_pattern[] = "_cucomplex_include_pattern";
static const char __pyx_k_cupy_complex_arithmetic_h[] = "cupy/complex/arithmetic.h";
static const char __pyx_k_enable_cooperative_groups[] = "enable_cooperative_groups";
static const char __pyx_k_cupy_complex_complex_inl_h[] = "cupy/complex/complex_inl.h";
static const char __pyx_k_iteration_over_a_0_d_array[] = "iteration over a 0-d array";
static const char __pyx_k_ndarray_toDlpack_line_1648[] = "ndarray.toDlpack (line 1648)";
static const char __pyx_k_subok_is_not_supported_yet[] = "subok is not supported yet";
static const char __pyx_k_cupy_complex_math_private_h[] = "cupy/complex/math_private.h";
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_order_not_understood_order_s[] = "order not understood. order=%s";
static const char __pyx_k_template_typename_T___device[] = "\ntemplate<typename T> __device__ T pow10(long long n){\n  T x = 1, a = 10;\n  while (n) {\n    if (n & 1) x *= a;\n    a *= a;\n    n >>= 1;\n  }\n  return x;\n};\n";
static const char __pyx_k_ndarray___getitem___line_1183[] = "ndarray.__getitem__ (line 1183)";
static const char __pyx_k_ndarray___setitem___line_1207[] = "ndarray.__setitem__ (line 1207)";
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_CuPy_cannot_copy_non_contiguous[] = "CuPy cannot copy non-contiguous array between devices.";
static const char __pyx_k_CuPy_currently_does_not_support[] = "CuPy currently does not support masked arrays.";
static const char __pyx_k_Failed_to_auto_detect_CUDA_root[] = "Failed to auto-detect CUDA root directory. Please specify `CUDA_PATH` environment variable if you are using CUDA v9.0, v9.1 or versions not yet supported by CuPy.";
static const char __pyx_k_Not_supported_dtype_combination[] = "Not supported dtype combination.";
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_array_cannot_be_obtained_from_a[] = "{} array cannot be obtained from {} array";
static const char __pyx_k_calling_nonzero_on_0d_arrays_is[] = "calling nonzero on 0d arrays is deprecated";
static const char __pyx_k_calling_reduced_view_with_dtype[] = "calling reduced_view with dtype is deprecated";
static const char __pyx_k_double_x_inv_x_if_in1_0_x_inv_x[] = "\ndouble x, inv_x;\nif (in1 == 0) {\n    x = inv_x = 1;\n} else {\n    x = pow10<double>(abs(in1));  // TODO(okuta): Move before loop\n    inv_x = 1.0 / x;\n    if (in1 < 0) {\n        double y = x;\n        x = inv_x;\n        inv_x = y;\n    }\n}\nout0 = in0_type(round(in0.real() * x) * inv_x,\n                round(in0.imag() * x) * inv_x);";
static const char __pyx_k_if_in1_0_TODO_okuta_Move_before[] = "\n    if (in1 < 0) {\n        // TODO(okuta): Move before loop\n        long long x = pow10<long long>(-in1 - 1);\n        // TODO(okuta): Check Numpy\n        out0 = ((in0 / x + (in0 > 0 ? 5 : -5)) / 10) * x * 10;\n    } else {\n        out0 = in0;\n    }";
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_if_in1_0_out0_round_in0_else_do[] = "\nif (in1 == 0) {\n    out0 = round(in0);\n} else {\n    double x;\n    x = pow10<double>(abs(in1));  // TODO(okuta): Move before loop\n    out0 = in1 < 0 ? round(in0 / x) * x : round(in0 * x) / x;\n}";
static const char __pyx_k_include_cupy_cuComplex_bridge_h[] = "#include <cupy/cuComplex_bridge.h>  // translate_cucomplex\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_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_out_cannot_be_specified_when_co[] = "`out` cannot be specified when copying to non-contiguous ndarray";
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_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_Cannot_set_to_non_contiguous_arr[] = "Cannot set to non-contiguous array";
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    .. note::\n        :func:`cupy.bitwise_not` is an alias for :func:`cupy.invert`.\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_Negative_dimensions_are_not_allo[] = "Negative dimensions are not allowed";
static const char __pyx_k_Only_numpy_ndarray_can_be_obtain[] = "Only numpy.ndarray can be obtained fromcupy.ndarray";
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_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_Shape_mismatch_Expected_shape_ac[] = "Shape mismatch. Expected shape: {}, actual shape: {}";
static const char __pyx_k_Shape_mismatch_Old_shape_new_sha[] = "Shape mismatch. Old shape: {}, new shape: {}";
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_out_parameter_must_have_exac[] = "The 'out' parameter must have exactly one array value";
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_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_Using_synchronous_transfer_as_pi[] = "Using synchronous transfer as pinned memory ({} bytes) could not be allocated. This generally occurs because of insufficient host memory. The original error was: {}";
static const char __pyx_k_Zero_copy_conversion_to_a_DLPack[] = "Zero-copy conversion to a DLPack tensor.\n\n        DLPack is a open in memory tensor structure proposed in this\n        repository: `dmlc/dlpack <https://github.com/dmlc/dlpack>`_.\n\n        This function returns a :class:`PyCapsule` object which contains a\n        pointer to a DLPack tensor converted from the own ndarray. This\n        function does not copy the own data to the output DLpack tensor\n        but it shares the pointer which is pointing to the same memory region\n        for the data.\n\n        Returns:\n            dltensor (:class:`PyCapsule`): Output DLPack tensor which is\n                encapsulated in a :class:`PyCapsule` object.\n\n        .. seealso::\n\n            :meth:`~cupy.fromDlpack` is a method for zero-copy conversion from\n            a DLPack tensor (which is encapsulated in a :class:`PyCapsule`\n            object) to a :class:`ndarray`\n\n        .. admonition:: Example\n\n            >>> import cupy\n            >>> array1 = cupy.array([0, 1, 2], dtype=cupy.float32)\n            >>> dltensor = array1.toDlpack()\n            >>> array2 = cupy.fromDlpack(dltensor)\n            >>> cupy.testing.assert_array_equal(array1, array2)\n\n        ";
static const char __pyx_k_can_only_convert_an_array_of_siz[] = "can only convert an array of size 1 to a Python scalar";
static const char __pyx_k_copying_a_numpy_ndarray_to_a_cup[] = "copying a numpy.ndarray to a cupy.ndarray by empty slice assignment must ensure arrays have same shape and dtype";
static const char __pyx_k_memptr_is_required_if_strides_is[] = "memptr is required if strides is given.";
static const char __pyx_k_out_base__ind_get__ind_ndim_1_st[] = "out = base + _ind.get()[_ind.ndim - 1] * stride";
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_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_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 PyObject *__pyx_kp_u_0;
static PyObject *__pyx_kp_u_1_14_0;
static PyObject *__pyx_n_u_A;
static PyObject *__pyx_n_s_AttributeError;
static PyObject *__pyx_kp_u_Axis_dimension_mismatch;
static PyObject *__pyx_kp_u_BB;
static PyObject *__pyx_kp_u_BB_B;
static PyObject *__pyx_kp_u_BB_BB;
static PyObject *__pyx_kp_u_B_B;
static PyObject *__pyx_kp_u_Bq_B;
static PyObject *__pyx_n_u_C;
static PyObject *__pyx_n_s_CUDARuntimeError;
static PyObject *__pyx_kp_u_Cannot_set_to_non_contiguous_arr;
static PyObject *__pyx_kp_u_Casting_complex_values_to_real_d;
static PyObject *__pyx_kp_u_Changing_the_dtype_of_a_0d_array;
static PyObject *__pyx_n_s_ComplexWarning;
static PyObject *__pyx_kp_u_Computes_the_bitwise_AND_of_two;
static PyObject *__pyx_kp_u_Computes_the_bitwise_NOT_of_an_a;
static PyObject *__pyx_kp_u_Computes_the_bitwise_OR_of_two_a;
static PyObject *__pyx_kp_u_Computes_the_bitwise_XOR_of_two;
static PyObject *__pyx_kp_u_CuPy_cannot_copy_non_contiguous;
static PyObject *__pyx_kp_u_CuPy_currently_does_not_support;
static PyObject *__pyx_n_u_D;
static PyObject *__pyx_kp_u_DD;
static PyObject *__pyx_n_s_DeprecationWarning;
static PyObject *__pyx_kp_u_Dq_D;
static PyObject *__pyx_n_s_ENABLE_SLICE_COPY;
static PyObject *__pyx_n_s_ElementwiseKernel;
static PyObject *__pyx_n_u_F;
static PyObject *__pyx_kp_u_FF;
static PyObject *__pyx_kp_u_Failed_to_auto_detect_CUDA_root;
static PyObject *__pyx_n_u_Ff;
static PyObject *__pyx_n_s_Flags;
static PyObject *__pyx_kp_u_Fq_F;
static PyObject *__pyx_kp_u_HH;
static PyObject *__pyx_kp_u_HH_H;
static PyObject *__pyx_kp_u_HH_HH;
static PyObject *__pyx_kp_u_H_H;
static PyObject *__pyx_kp_u_Hq_H;
static PyObject *__pyx_kp_u_I;
static PyObject *__pyx_kp_u_II;
static PyObject *__pyx_kp_u_II_I;
static PyObject *__pyx_kp_u_II_II;
static PyObject *__pyx_kp_u_I_I;
static PyObject *__pyx_kp_u_I_s;
static PyObject *__pyx_kp_u_Invalid_dtype_s;
static PyObject *__pyx_kp_u_Iq_I;
static PyObject *__pyx_n_u_K;
static PyObject *__pyx_n_u_KAka;
static PyObject *__pyx_kp_u_LL;
static PyObject *__pyx_kp_u_LL_L;
static PyObject *__pyx_kp_u_LL_LL;
static PyObject *__pyx_kp_u_L_L;
static PyObject *__pyx_kp_u_Lq_L;
static PyObject *__pyx_kp_u_Negative_dimensions_are_not_allo;
static PyObject *__pyx_n_s_NotImplemented;
static PyObject *__pyx_n_s_NotImplementedError;
static PyObject *__pyx_kp_u_Not_supported_dtype_combination;
static PyObject *__pyx_n_s_NumpyVersion;
static PyObject *__pyx_kp_u_Only_numpy_ndarray_can_be_obtain;
static PyObject *__pyx_kp_u_Only_numpy_ndarray_can_be_set_to;
static PyObject *__pyx_kp_u_Output_array_has_an_invalid_size;
static PyObject *__pyx_kp_u_Output_array_must_be_C_contiguou;
static PyObject *__pyx_n_s_PerformanceWarning;
static PyObject *__pyx_kp_u_QQ;
static PyObject *__pyx_kp_u_QQ_Q;
static PyObject *__pyx_kp_u_QQ_QQ;
static PyObject *__pyx_kp_u_Q_Q;
static PyObject *__pyx_kp_u_Qq_Q;
static PyObject *__pyx_n_s_ReductionKernel;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_kp_u_S_x_T_y;
static PyObject *__pyx_kp_u_Scalar_operands_are_not_allowed;
static PyObject *__pyx_kp_u_Shape_mismatch_Expected_shape_ac;
static PyObject *__pyx_kp_u_Shape_mismatch_Old_shape_new_sha;
static PyObject *__pyx_kp_u_Shifts_the_bits_of_each_integer;
static PyObject *__pyx_kp_u_Shifts_the_bits_of_each_integer_2;
static PyObject *__pyx_kp_u_T_base_T_stride;
static PyObject *__pyx_kp_u_T_out;
static PyObject *__pyx_kp_u_T_x;
static PyObject *__pyx_kp_u_T_y;
static PyObject *__pyx_kp_u_Tests_elementwise_if_x1_x2_seeal;
static PyObject *__pyx_kp_u_Tests_elementwise_if_x1_x2_seeal_2;
static PyObject *__pyx_kp_u_Tests_elementwise_if_x1_x2_seeal_3;
static PyObject *__pyx_kp_u_Tests_elementwise_if_x1_x2_seeal_4;
static PyObject *__pyx_kp_u_Tests_elementwise_if_x1_x2_seeal_5;
static PyObject *__pyx_kp_u_Tests_elementwise_if_x1_x2_seeal_6;
static PyObject *__pyx_kp_u_The_out_array_as_input_is_curren;
static PyObject *__pyx_kp_u_The_out_parameter_must_have_exac;
static PyObject *__pyx_kp_u_The_truth_value_of_an_array_with;
static PyObject *__pyx_kp_u_To_change_to_a_dtype_of_a_differ;
static PyObject *__pyx_n_s_TypeError;
static PyObject *__pyx_kp_u_U_out;
static PyObject *__pyx_n_s_UnownedMemory;
static PyObject *__pyx_kp_u_Unsupported_dtype_s;
static PyObject *__pyx_kp_u_Using_synchronous_transfer_as_pi;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_kp_u_Zero_copy_conversion_to_a_DLPack;
static PyObject *__pyx_kp_u__21;
static PyObject *__pyx_kp_u__35;
static PyObject *__pyx_kp_u__44;
static PyObject *__pyx_kp_u__6;
static PyObject *__pyx_kp_u__60;
static PyObject *__pyx_kp_u__66;
static PyObject *__pyx_kp_u__67;
static PyObject *__pyx_kp_u__68;
static PyObject *__pyx_kp_u__70;
static PyObject *__pyx_kp_u__71;
static PyObject *__pyx_kp_u__72;
static PyObject *__pyx_kp_u__73;
static PyObject *__pyx_kp_u__77;
static PyObject *__pyx_kp_u__78;
static PyObject *__pyx_kp_u__81;
static PyObject *__pyx_kp_u__82;
static PyObject *__pyx_kp_u__83;
static PyObject *__pyx_kp_u__84;
static PyObject *__pyx_n_s_a;
static PyObject *__pyx_kp_u_a_b;
static PyObject *__pyx_n_s_a_max;
static PyObject *__pyx_n_s_a_min;
static PyObject *__pyx_n_s_abspath;
static PyObject *__pyx_n_s_all;
static PyObject *__pyx_n_s_any;
static PyObject *__pyx_n_s_arch;
static PyObject *__pyx_n_s_argmax;
static PyObject *__pyx_n_s_argmin;
static PyObject *__pyx_n_s_argpartition;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_argsort;
static PyObject *__pyx_n_s_arr;
static PyObject *__pyx_n_s_array;
static PyObject *__pyx_kp_u_array_cannot_be_obtained_from_a;
static PyObject *__pyx_kp_u_array_cannot_be_set_to_array;
static PyObject *__pyx_n_s_array_interface;
static PyObject *__pyx_n_s_array_priority;
static PyObject *__pyx_n_u_array_priority;
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_n_s_axis2;
static PyObject *__pyx_n_s_b;
static PyObject *__pyx_n_u_b;
static PyObject *__pyx_kp_u_b_b;
static PyObject *__pyx_n_s_backend;
static PyObject *__pyx_kp_u_bb;
static PyObject *__pyx_kp_u_bb_b;
static PyObject *__pyx_kp_u_bb_bb;
static PyObject *__pyx_kp_u_bhilqBHILQefdFD;
static PyObject *__pyx_n_s_bitwise_and;
static PyObject *__pyx_n_u_bitwise_and;
static PyObject *__pyx_n_s_bitwise_or;
static PyObject *__pyx_n_u_bitwise_or;
static PyObject *__pyx_n_s_bitwise_xor;
static PyObject *__pyx_n_u_bitwise_xor;
static PyObject *__pyx_kp_u_bq_b;
static PyObject *__pyx_n_u_c;
static PyObject *__pyx_n_s_c_contiguous;
static PyObject *__pyx_n_s_c_void_p;
static PyObject *__pyx_n_s_cachd_dir;
static PyObject *__pyx_n_u_call;
static PyObject *__pyx_kp_u_calling_nonzero_on_0d_arrays_is;
static PyObject *__pyx_kp_u_calling_reduced_view_with_dtype;
static PyObject *__pyx_kp_u_can_only_convert_an_array_of_siz;
static PyObject *__pyx_n_s_casting;
static PyObject *__pyx_kp_u_casting_is_not_supported_yet;
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_cline_in_traceback;
static PyObject *__pyx_n_s_clip;
static PyObject *__pyx_n_s_close;
static PyObject *__pyx_n_s_compile;
static PyObject *__pyx_n_s_compile_with_cache;
static PyObject *__pyx_n_s_complex128;
static PyObject *__pyx_n_s_complex64;
static PyObject *__pyx_n_s_compress;
static PyObject *__pyx_n_s_concatenate;
static PyObject *__pyx_n_s_condition;
static PyObject *__pyx_n_s_conj;
static PyObject *__pyx_n_s_conjugate;
static PyObject *__pyx_n_s_copy;
static PyObject *__pyx_kp_u_copying_a_numpy_ndarray_to_a_cup;
static PyObject *__pyx_n_s_create_ufunc;
static PyObject *__pyx_n_s_ctypes;
static PyObject *__pyx_kp_u_cuComplex_h;
static PyObject *__pyx_n_s_cucomplex_include_pattern;
static PyObject *__pyx_n_s_cucomplex_include_tokens;
static PyObject *__pyx_n_s_cuda;
static PyObject *__pyx_kp_u_cuda_10_0;
static PyObject *__pyx_kp_u_cuda_10_1;
static PyObject *__pyx_kp_u_cuda_10_2;
static PyObject *__pyx_n_u_cuda_2;
static PyObject *__pyx_kp_u_cuda_9_2;
static PyObject *__pyx_n_s_cuda_array_interface;
static PyObject *__pyx_n_u_cuda_array_interface;
static PyObject *__pyx_n_s_cumprod;
static PyObject *__pyx_n_s_cumsum;
static PyObject *__pyx_n_s_cupy;
static PyObject *__pyx_n_u_cupy;
static PyObject *__pyx_n_u_cupy_2;
static PyObject *__pyx_kp_u_cupy_atomics_cuh;
static PyObject *__pyx_kp_u_cupy_carray_cuh;
static PyObject *__pyx_kp_u_cupy_complex_arithmetic_h;
static PyObject *__pyx_kp_u_cupy_complex_catrig_h;
static PyObject *__pyx_kp_u_cupy_complex_catrigf_h;
static PyObject *__pyx_kp_u_cupy_complex_ccosh_h;
static PyObject *__pyx_kp_u_cupy_complex_ccoshf_h;
static PyObject *__pyx_kp_u_cupy_complex_cexp_h;
static PyObject *__pyx_kp_u_cupy_complex_cexpf_h;
static PyObject *__pyx_kp_u_cupy_complex_clog_h;
static PyObject *__pyx_kp_u_cupy_complex_clogf_h;
static PyObject *__pyx_kp_u_cupy_complex_complex_h;
static PyObject *__pyx_kp_u_cupy_complex_complex_inl_h;
static PyObject *__pyx_kp_u_cupy_complex_cpow_h;
static PyObject *__pyx_kp_u_cupy_complex_cproj_h;
static PyObject *__pyx_kp_u_cupy_complex_csinh_h;
static PyObject *__pyx_kp_u_cupy_complex_csinhf_h;
static PyObject *__pyx_kp_u_cupy_complex_csqrt_h;
static PyObject *__pyx_kp_u_cupy_complex_csqrtf_h;
static PyObject *__pyx_kp_u_cupy_complex_ctanh_h;
static PyObject *__pyx_kp_u_cupy_complex_ctanhf_h;
static PyObject *__pyx_kp_u_cupy_complex_cuh;
static PyObject *__pyx_kp_u_cupy_complex_math_private_h;
static PyObject *__pyx_n_s_cupy_core;
static PyObject *__pyx_n_s_cupy_core__kernel;
static PyObject *__pyx_n_s_cupy_core__reduction;
static PyObject *__pyx_n_s_cupy_core__ufuncs;
static PyObject *__pyx_n_s_cupy_core_core;
static PyObject *__pyx_kp_u_cupy_cuComplex_bridge_h;
static PyObject *__pyx_n_s_cupy_cuda;
static PyObject *__pyx_n_s_cupy_cuda_runtime;
static PyObject *__pyx_n_u_cupy_divmod;
static PyObject *__pyx_n_u_cupy_invert;
static PyObject *__pyx_n_u_cupy_round;
static PyObject *__pyx_n_u_d;
static PyObject *__pyx_n_u_data;
static PyObject *__pyx_kp_u_dd;
static PyObject *__pyx_kp_u_dd_dd;
static PyObject *__pyx_n_s_ddof;
static PyObject *__pyx_n_s_decimals;
static PyObject *__pyx_n_s_declare_synchronize;
static PyObject *__pyx_n_s_descr;
static PyObject *__pyx_n_u_descr;
static PyObject *__pyx_n_s_device;
static PyObject *__pyx_n_s_diagonal;
static PyObject *__pyx_n_s_dirname;
static PyObject *__pyx_n_s_divmod;
static PyObject *__pyx_n_s_doc;
static PyObject *__pyx_kp_u_double_x_inv_x_if_in1_0_x_inv_x;
static PyObject *__pyx_kp_u_dq_d;
static PyObject *__pyx_n_s_dtype;
static PyObject *__pyx_n_s_dump;
static PyObject *__pyx_n_s_dumps;
static PyObject *__pyx_n_u_e;
static PyObject *__pyx_kp_u_ee;
static PyObject *__pyx_kp_u_ee_ee;
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_enable_cooperative_groups;
static PyObject *__pyx_n_s_enter;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_kp_u_eq_e;
static PyObject *__pyx_n_s_equal;
static PyObject *__pyx_n_u_equal;
static PyObject *__pyx_n_s_exit;
static PyObject *__pyx_n_s_expand_dims;
static PyObject *__pyx_n_u_f;
static PyObject *__pyx_n_s_f_contiguous;
static PyObject *__pyx_n_u_fdFD;
static PyObject *__pyx_kp_u_ff;
static PyObject *__pyx_kp_u_ff_ff;
static PyObject *__pyx_n_s_fid;
static PyObject *__pyx_n_s_file;
static PyObject *__pyx_n_s_fill;
static PyObject *__pyx_n_u_fill;
static PyObject *__pyx_n_s_flags;
static PyObject *__pyx_n_s_flatiter;
static PyObject *__pyx_n_s_flatten;
static PyObject *__pyx_n_s_float32;
static PyObject *__pyx_n_s_float64;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_kp_u_fq_f;
static PyObject *__pyx_n_s_frombuffer;
static PyObject *__pyx_n_s_func;
static PyObject *__pyx_n_s_functools;
static PyObject *__pyx_n_s_genexpr;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_get_compute_capability;
static PyObject *__pyx_n_s_get_cublas_handle;
static PyObject *__pyx_n_s_get_cuda_path;
static PyObject *__pyx_n_s_get_device_id;
static PyObject *__pyx_n_s_getattr;
static PyObject *__pyx_n_s_greater;
static PyObject *__pyx_n_u_greater;
static PyObject *__pyx_n_s_greater_equal;
static PyObject *__pyx_n_u_greater_equal;
static PyObject *__pyx_kp_u_h_h;
static PyObject *__pyx_n_s_hex;
static PyObject *__pyx_kp_u_hh;
static PyObject *__pyx_kp_u_hh_h;
static PyObject *__pyx_kp_u_hh_hh;
static PyObject *__pyx_kp_u_hq_h;
static PyObject *__pyx_kp_u_i_i;
static PyObject *__pyx_kp_u_if_in1_0_TODO_okuta_Move_before;
static PyObject *__pyx_kp_u_if_in1_0_out0_0_out1_0_else_out;
static PyObject *__pyx_kp_u_if_in1_0_out0_round_in0_else_do;
static PyObject *__pyx_kp_u_ii;
static PyObject *__pyx_kp_u_ii_i;
static PyObject *__pyx_kp_u_ii_ii;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_u_include;
static PyObject *__pyx_kp_u_include_cupy_cuComplex_bridge_h;
static PyObject *__pyx_kp_u_include_s;
static PyObject *__pyx_n_s_indices;
static PyObject *__pyx_n_s_invert;
static PyObject *__pyx_kp_u_iq_i;
static PyObject *__pyx_n_s_is_c_contiguous;
static PyObject *__pyx_n_s_item;
static PyObject *__pyx_n_s_itemsize;
static PyObject *__pyx_n_s_iter___locals_genexpr;
static PyObject *__pyx_kp_u_iteration_over_a_0_d_array;
static PyObject *__pyx_n_s_join;
static PyObject *__pyx_n_s_k;
static PyObject *__pyx_n_s_keepdims;
static PyObject *__pyx_n_s_keepends;
static PyObject *__pyx_n_s_kind;
static PyObject *__pyx_n_s_kth;
static PyObject *__pyx_n_s_kwargs;
static PyObject *__pyx_kp_u_l_l;
static PyObject *__pyx_n_s_left_shift;
static PyObject *__pyx_n_u_left_shift;
static PyObject *__pyx_kp_u_len_of_unsized_object;
static PyObject *__pyx_kp_u_len_shape_len_strides;
static PyObject *__pyx_n_s_less;
static PyObject *__pyx_n_u_less;
static PyObject *__pyx_n_s_less_equal;
static PyObject *__pyx_n_u_less_equal;
static PyObject *__pyx_n_s_lib;
static PyObject *__pyx_kp_u_ll;
static PyObject *__pyx_kp_u_ll_l;
static PyObject *__pyx_kp_u_ll_ll;
static PyObject *__pyx_kp_u_lq_l;
static PyObject *__pyx_n_s_m;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_u_mask;
static PyObject *__pyx_n_u_mat_ptrs;
static PyObject *__pyx_n_s_match;
static PyObject *__pyx_n_s_max;
static PyObject *__pyx_n_s_mean;
static PyObject *__pyx_n_s_memory;
static PyObject *__pyx_n_s_memory_module;
static PyObject *__pyx_n_s_memptr;
static PyObject *__pyx_kp_u_memptr_is_required_if_strides_is;
static PyObject *__pyx_n_s_method;
static PyObject *__pyx_n_s_min;
static PyObject *__pyx_n_s_mode;
static PyObject *__pyx_n_s_module;
static PyObject *__pyx_n_s_n;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_name_2;
static PyObject *__pyx_n_s_nbytes;
static PyObject *__pyx_n_s_ndarray;
static PyObject *__pyx_kp_u_ndarray___getitem___line_1183;
static PyObject *__pyx_kp_u_ndarray___setitem___line_1207;
static PyObject *__pyx_kp_u_ndarray_toDlpack_line_1648;
static PyObject *__pyx_n_s_ndim;
static PyObject *__pyx_n_s_ndmin;
static PyObject *__pyx_n_s_no_bool;
static PyObject *__pyx_n_s_no_complex_dtype;
static PyObject *__pyx_kp_u_non_scalar_numpy_ndarray_cannot;
static PyObject *__pyx_n_s_nonzero;
static PyObject *__pyx_n_s_not_equal;
static PyObject *__pyx_n_u_not_equal;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_u_nvrtc;
static PyObject *__pyx_n_s_obj;
static PyObject *__pyx_n_s_oct;
static PyObject *__pyx_n_s_offset;
static PyObject *__pyx_n_s_op;
static PyObject *__pyx_n_s_open;
static PyObject *__pyx_kp_u_operands_could_not_be_broadcast;
static PyObject *__pyx_n_s_options;
static PyObject *__pyx_n_s_order;
static PyObject *__pyx_n_s_order_char;
static PyObject *__pyx_kp_u_order_not_understood_order_s;
static PyObject *__pyx_n_s_os;
static PyObject *__pyx_n_s_out;
static PyObject *__pyx_n_u_out;
static PyObject *__pyx_kp_u_out0_in0;
static PyObject *__pyx_kp_u_out0_in0_2;
static PyObject *__pyx_kp_u_out0_in0_3;
static PyObject *__pyx_kp_u_out0_in0_s_in1;
static PyObject *__pyx_kp_u_out0_type_a__floor_divide_in0_i;
static PyObject *__pyx_kp_u_out_a;
static PyObject *__pyx_kp_u_out_base__ind_get__ind_ndim_1_st;
static PyObject *__pyx_kp_u_out_cannot_be_specified_when_co;
static PyObject *__pyx_n_s_partition;
static PyObject *__pyx_n_s_path;
static PyObject *__pyx_n_s_pickle;
static PyObject *__pyx_n_s_prepend_cupy_headers;
static PyObject *__pyx_n_s_prod;
static PyObject *__pyx_n_s_promote_types;
static PyObject *__pyx_n_s_ptp;
static PyObject *__pyx_n_s_put;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_kp_u_q_e;
static PyObject *__pyx_kp_u_q_q;
static PyObject *__pyx_kp_u_qq;
static PyObject *__pyx_kp_u_qq_q;
static PyObject *__pyx_kp_u_qq_qq;
static PyObject *__pyx_n_s_radd;
static PyObject *__pyx_n_u_raise;
static PyObject *__pyx_n_s_rand;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_ravel;
static PyObject *__pyx_n_s_rdiv;
static PyObject *__pyx_n_s_rdivmod;
static PyObject *__pyx_n_s_re;
static PyObject *__pyx_n_s_read;
static PyObject *__pyx_n_s_real;
static PyObject *__pyx_n_s_record;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_dims;
static PyObject *__pyx_n_s_reduced_view;
static PyObject *__pyx_n_s_repeat;
static PyObject *__pyx_n_s_repeats;
static PyObject *__pyx_n_s_reshape;
static PyObject *__pyx_n_s_result_type;
static PyObject *__pyx_n_s_ret_shape;
static PyObject *__pyx_n_s_rfloordiv;
static PyObject *__pyx_n_s_right_shift;
static PyObject *__pyx_n_u_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_ror;
static PyObject *__pyx_n_s_round;
static PyObject *__pyx_n_s_round_ufunc;
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_u_s;
static PyObject *__pyx_kp_u_s_2;
static PyObject *__pyx_n_s_send;
static PyObject *__pyx_n_s_sep;
static PyObject *__pyx_n_s_set;
static PyObject *__pyx_n_s_set_contiguous_strides;
static PyObject *__pyx_n_s_set_shape_and_strides;
static PyObject *__pyx_n_s_shape;
static PyObject *__pyx_n_u_shape;
static PyObject *__pyx_kp_u_shapes_and_not_aligned;
static PyObject *__pyx_n_s_signature;
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_n_s_split;
static PyObject *__pyx_n_s_splitlines;
static PyObject *__pyx_n_s_squeeze;
static PyObject *__pyx_kp_u_static_cast_U_x_static_cast_U_y;
static PyObject *__pyx_n_s_status;
static PyObject *__pyx_n_s_std;
static PyObject *__pyx_n_s_str;
static PyObject *__pyx_n_s_stream;
static PyObject *__pyx_n_s_strides;
static PyObject *__pyx_n_u_strides;
static PyObject *__pyx_n_s_subok;
static PyObject *__pyx_kp_u_subok_is_not_supported_yet;
static PyObject *__pyx_n_s_sum;
static PyObject *__pyx_n_s_swapaxes;
static PyObject *__pyx_n_s_syncdetect;
static PyObject *__pyx_n_s_sys;
static PyObject *__pyx_n_s_take;
static PyObject *__pyx_kp_u_template_typename_T___device;
static PyObject *__pyx_n_u_tensordot_core_mul_sum;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_throw;
static PyObject *__pyx_n_s_toDlpack;
static PyObject *__pyx_n_s_tobytes;
static PyObject *__pyx_n_s_tofile;
static PyObject *__pyx_n_s_tolist;
static PyObject *__pyx_n_s_trace;
static PyObject *__pyx_n_s_trans;
static PyObject *__pyx_n_s_translate_cucomplex;
static PyObject *__pyx_n_s_types;
static PyObject *__pyx_n_u_typestr;
static PyObject *__pyx_n_s_ufunc;
static PyObject *__pyx_n_s_uintp;
static PyObject *__pyx_kp_u_unsupported_order;
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_update_f_contiguity_2;
static PyObject *__pyx_n_s_upper;
static PyObject *__pyx_n_s_util;
static PyObject *__pyx_n_s_value;
static PyObject *__pyx_n_s_values;
static PyObject *__pyx_n_s_var;
static PyObject *__pyx_n_u_version;
static PyObject *__pyx_n_s_version_2;
static PyObject *__pyx_n_s_view;
static PyObject *__pyx_n_s_warn;
static PyObject *__pyx_n_s_warnings;
static PyObject *__pyx_n_u_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_u_y_x;
static PyObject *__pyx_n_s_zeros;
static PyObject *__pyx_n_s_zip;
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_strides, PyObject *__pyx_v_order); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_24__cuda_array_interface_____get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* 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_4flat___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_2item(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_4tolist(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_6tobytes(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_order); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_8tofile(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_10dump(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_file); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_12dumps(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_14astype(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_16copy(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_order); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_18view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_20fill(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_22reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_order, PyObject *__pyx_v_shape); /* 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, PyObject *__pyx_v_order); /* 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_36put(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_indices, PyObject *__pyx_v_values, PyObject *__pyx_v_mode); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_38repeat(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_40choose(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_42sort(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_44argsort(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_46partition(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_kth, int __pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_48argpartition(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_50nonzero(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_52compress(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_condition, PyObject *__pyx_v_axis, PyObject *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_54diagonal(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_56max(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_58argmax(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_60min(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_62argmin(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_64ptp(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_66clip(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_68round(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_decimals, PyObject *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_70trace(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_72sum(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_74cumsum(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_76mean(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_78var(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_80std(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_82prod(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_84cumprod(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, PyObject *__pyx_v_dtype, PyObject *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_86all(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_88any(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_90__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_92__nonzero__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_94__neg__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_96__pos__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_98__abs__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_100__invert__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_102__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_104__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_106__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
#if PY_VERSION_HEX >= 0x03050000
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_108__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_110__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
#endif
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_112__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_114__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_116__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_118__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_120__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, CYTHON_UNUSED PyObject *__pyx_v_modulo); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_122__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_124__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_126__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_128__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_130__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_132__iadd__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_134__isub__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_136__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_138__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_140__itruediv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_142__ifloordiv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_144__imod__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_146__ipow__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_148__ilshift__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_150__irshift__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_152__iand__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_154__ior__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_156__ixor__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_158conj(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_160conjugate(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_162__copy__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_164__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_166__reduce__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_168__array__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_8__iter___genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_170__iter__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_pf_4cupy_4core_4core_7ndarray_172__len__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_174__getitem__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices); /* proto */
static int __pyx_pf_4cupy_4core_4core_7ndarray_176__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_178scatter_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_180scatter_max(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_182scatter_min(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_184__array_ufunc__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_ufunc, PyObject *__pyx_v_method, PyObject *__pyx_v_inputs, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_186__array_function__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_types, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_188__int__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_190__float__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_192__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_194__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_196__hex__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
#endif
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_198__bytes__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_200__repr__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_202__str__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_204dot(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_206get(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_stream, PyObject *__pyx_v_order, PyObject *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_208set(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_210reduced_view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_212_update_c_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_214_update_f_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_216_update_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_218_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, int __pyx_v_update_f_contiguity); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_220_set_contiguous_strides(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, Py_ssize_t __pyx_v_itemsize, int __pyx_v_is_c_contiguous); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_222toDlpack(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* 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__update_order_char(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, int __pyx_v_order_char); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_2_get_strides_for_order_K(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, PyObject *__pyx_v_dtype, PyObject *__pyx_v_shape); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_4_get_header_dir_path(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_6_get_header_source(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_8compile_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_v_prepend_cupy_headers, PyObject *__pyx_v_backend, PyObject *__pyx_v_translate_cucomplex, PyObject *__pyx_v_enable_cooperative_groups); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_10array(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_12_internal_ascontiguousarray(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_14_internal_asfortranarray(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_16ascontiguousarray(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_18asfortranarray(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_20_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_22dot(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_24matmul(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_26tensordot_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_28_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_30_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_32create_comparison(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_op, PyObject *__pyx_v_doc, PyObject *__pyx_v_no_complex_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_34_convert_object_with_cuda_array_interface(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a); /* 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___pyx_scope_struct____iter__(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_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_70;
static PyObject *__pyx_int_100;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_k_;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__3;
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__18;
static PyObject *__pyx_slice__23;
static PyObject *__pyx_slice__40;
static PyObject *__pyx_slice__41;
static PyObject *__pyx_slice__51;
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__19;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__22;
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__36;
static PyObject *__pyx_tuple__37;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__43;
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__52;
static PyObject *__pyx_tuple__53;
static PyObject *__pyx_tuple__54;
static PyObject *__pyx_tuple__55;
static PyObject *__pyx_tuple__56;
static PyObject *__pyx_tuple__57;
static PyObject *__pyx_tuple__58;
static PyObject *__pyx_tuple__59;
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__69;
static PyObject *__pyx_tuple__74;
static PyObject *__pyx_tuple__75;
static PyObject *__pyx_tuple__76;
static PyObject *__pyx_tuple__79;
static PyObject *__pyx_tuple__80;
/* Late includes */

/* "cupy/core/core.pyx":55
 * 
 * @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":56
 * @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_u_array_priority, __pyx_int_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_xp = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":57
 * 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_u_array_priority, __pyx_int_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_yp = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":58
 *     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, 58, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 58, __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, 58, __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":55
 * 
 * @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":97
 *     """
 * 
 *     def __init__(self, shape, dtype=float, memptr=None, strides=None,             # <<<<<<<<<<<<<<
 *                  order='C'):
 *         cdef Py_ssize_t x, itemsize
 */

/* 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_strides = 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_strides,&__pyx_n_s_order,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[1] = __pyx_k_;
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)__pyx_n_u_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 (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_strides);
          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_order);
          if (value) { values[4] = 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, 97, __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_shape = values[0];
    __pyx_v_dtype = values[1];
    __pyx_v_memptr = values[2];
    __pyx_v_strides = values[3];
    __pyx_v_order = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 97, __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_strides, __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_strides, PyObject *__pyx_v_order) {
  Py_ssize_t __pyx_v_x;
  Py_ssize_t __pyx_v_itemsize;
  PyObject *__pyx_v_s = 0;
  int __pyx_v_order_char;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  std::vector<Py_ssize_t>  __pyx_t_10;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_INCREF(__pyx_v_shape);

  /* "cupy/core/core.pyx":100
 *                  order='C'):
 *         cdef Py_ssize_t x, itemsize
 *         cdef tuple s = internal.get_size(shape)             # <<<<<<<<<<<<<<
 *         del shape
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_8internal_get_size(__pyx_v_shape, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_s = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":101
 *         cdef Py_ssize_t x, itemsize
 *         cdef tuple s = internal.get_size(shape)
 *         del shape             # <<<<<<<<<<<<<<
 * 
 *         cdef int order_char = (
 */
  __Pyx_DECREF(__pyx_v_shape);
  __pyx_v_shape = NULL;

  /* "cupy/core/core.pyx":104
 * 
 *         cdef int order_char = (
 *             b'C' if order is None else internal._normalize_order(order))             # <<<<<<<<<<<<<<
 * 
 *         # `strides` is prioritized over `order`, but invalid `order` should be
 */
  __pyx_t_3 = (__pyx_v_order == Py_None);
  if ((__pyx_t_3 != 0)) {
    __pyx_t_2 = 'C';
  } else {
    __pyx_t_4 = __pyx_f_4cupy_4core_8internal__normalize_order(__pyx_v_order, NULL); if (unlikely(__pyx_t_4 == ((int)0) && PyErr_Occurred())) __PYX_ERR(0, 104, __pyx_L1_error)
    __pyx_t_2 = __pyx_t_4;
  }
  __pyx_v_order_char = __pyx_t_2;

  /* "cupy/core/core.pyx":108
 *         # `strides` is prioritized over `order`, but invalid `order` should be
 *         # checked even if `strides` is given.
 *         if order_char != b'C' and order_char != b'F':             # <<<<<<<<<<<<<<
 *             raise TypeError('order not understood. order=%s' % order)
 * 
 */
  switch (__pyx_v_order_char) {
    case 'C':
    case 'F':
    __pyx_t_3 = 0;
    break;
    default:
    __pyx_t_3 = 1;
    break;
  }
  if (unlikely(__pyx_t_3)) {

    /* "cupy/core/core.pyx":109
 *         # checked even if `strides` is given.
 *         if order_char != b'C' and order_char != b'F':
 *             raise TypeError('order not understood. order=%s' % order)             # <<<<<<<<<<<<<<
 * 
 *         # Check for erroneous shape
 */
    __pyx_t_1 = PyUnicode_Format(__pyx_kp_u_order_not_understood_order_s, __pyx_v_order); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 109, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 109, __pyx_L1_error)

    /* "cupy/core/core.pyx":108
 *         # `strides` is prioritized over `order`, but invalid `order` should be
 *         # checked even if `strides` is given.
 *         if order_char != b'C' and order_char != b'F':             # <<<<<<<<<<<<<<
 *             raise TypeError('order not understood. order=%s' % order)
 * 
 */
  }

  /* "cupy/core/core.pyx":112
 * 
 *         # Check for erroneous shape
 *         self._shape.reserve(len(s))             # <<<<<<<<<<<<<<
 *         for x in s:
 *             if x < 0:
 */
  if (unlikely(__pyx_v_s == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 112, __pyx_L1_error)
  }
  __pyx_t_6 = PyTuple_GET_SIZE(__pyx_v_s); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 112, __pyx_L1_error)
  __pyx_v_self->_shape.reserve(__pyx_t_6);

  /* "cupy/core/core.pyx":113
 *         # Check for erroneous shape
 *         self._shape.reserve(len(s))
 *         for x in s:             # <<<<<<<<<<<<<<
 *             if x < 0:
 *                 raise ValueError('Negative dimensions are not allowed')
 */
  if (unlikely(__pyx_v_s == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 113, __pyx_L1_error)
  }
  __pyx_t_5 = __pyx_v_s; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
  for (;;) {
    if (__pyx_t_6 >= 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_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 113, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 113, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_x = __pyx_t_7;

    /* "cupy/core/core.pyx":114
 *         self._shape.reserve(len(s))
 *         for x in s:
 *             if x < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Negative dimensions are not allowed')
 *             self._shape.push_back(x)
 */
    __pyx_t_3 = ((__pyx_v_x < 0) != 0);
    if (unlikely(__pyx_t_3)) {

      /* "cupy/core/core.pyx":115
 *         for x in s:
 *             if x < 0:
 *                 raise ValueError('Negative dimensions are not allowed')             # <<<<<<<<<<<<<<
 *             self._shape.push_back(x)
 *         del s
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __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, 115, __pyx_L1_error)

      /* "cupy/core/core.pyx":114
 *         self._shape.reserve(len(s))
 *         for x in s:
 *             if x < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Negative dimensions are not allowed')
 *             self._shape.push_back(x)
 */
    }

    /* "cupy/core/core.pyx":116
 *             if x < 0:
 *                 raise ValueError('Negative dimensions are not allowed')
 *             self._shape.push_back(x)             # <<<<<<<<<<<<<<
 *         del s
 * 
 */
    try {
      __pyx_v_self->_shape.push_back(__pyx_v_x);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 116, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":113
 *         # Check for erroneous shape
 *         self._shape.reserve(len(s))
 *         for x in s:             # <<<<<<<<<<<<<<
 *             if x < 0:
 *                 raise ValueError('Negative dimensions are not allowed')
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":117
 *                 raise ValueError('Negative dimensions are not allowed')
 *             self._shape.push_back(x)
 *         del s             # <<<<<<<<<<<<<<
 * 
 *         # dtype
 */
  __Pyx_DECREF(__pyx_v_s);
  __pyx_v_s = NULL;

  /* "cupy/core/core.pyx":120
 * 
 *         # dtype
 *         self.dtype, itemsize = _dtype.get_dtype_with_itemsize(dtype)             # <<<<<<<<<<<<<<
 * 
 *         # Store shape and strides
 */
  __pyx_t_5 = __pyx_f_4cupy_4core_6_dtype_get_dtype_with_itemsize(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 120, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (likely(__pyx_t_5 != Py_None)) {
    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, 120, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_8);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 120, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 120, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 120, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __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;
  __pyx_v_itemsize = __pyx_t_6;

  /* "cupy/core/core.pyx":123
 * 
 *         # Store shape and strides
 *         if strides is not None:             # <<<<<<<<<<<<<<
 *             if memptr is None:
 *                 raise ValueError('memptr is required if strides is given.')
 */
  __pyx_t_3 = (__pyx_v_strides != Py_None);
  __pyx_t_9 = (__pyx_t_3 != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":124
 *         # Store shape and strides
 *         if strides is not None:
 *             if memptr is None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('memptr is required if strides is given.')
 *             self._set_shape_and_strides(self._shape, strides, True, True)
 */
    __pyx_t_9 = (__pyx_v_memptr == Py_None);
    __pyx_t_3 = (__pyx_t_9 != 0);
    if (unlikely(__pyx_t_3)) {

      /* "cupy/core/core.pyx":125
 *         if strides is not None:
 *             if memptr is None:
 *                 raise ValueError('memptr is required if strides is given.')             # <<<<<<<<<<<<<<
 *             self._set_shape_and_strides(self._shape, strides, True, True)
 *         elif order_char == b'C':
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 125, __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, 125, __pyx_L1_error)

      /* "cupy/core/core.pyx":124
 *         # Store shape and strides
 *         if strides is not None:
 *             if memptr is None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('memptr is required if strides is given.')
 *             self._set_shape_and_strides(self._shape, strides, True, True)
 */
    }

    /* "cupy/core/core.pyx":126
 *             if memptr is None:
 *                 raise ValueError('memptr is required if strides is given.')
 *             self._set_shape_and_strides(self._shape, strides, True, True)             # <<<<<<<<<<<<<<
 *         elif order_char == b'C':
 *             self._set_contiguous_strides(itemsize, True)
 */
    __pyx_t_10 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_strides); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 126, __pyx_L1_error)
    __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_set_shape_and_strides(__pyx_v_self, __pyx_v_self->_shape, __pyx_t_10, 1, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 126, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":123
 * 
 *         # Store shape and strides
 *         if strides is not None:             # <<<<<<<<<<<<<<
 *             if memptr is None:
 *                 raise ValueError('memptr is required if strides is given.')
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":127
 *                 raise ValueError('memptr is required if strides is given.')
 *             self._set_shape_and_strides(self._shape, strides, True, True)
 *         elif order_char == b'C':             # <<<<<<<<<<<<<<
 *             self._set_contiguous_strides(itemsize, True)
 *         elif order_char == b'F':
 */
  __pyx_t_3 = ((__pyx_v_order_char == 'C') != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":128
 *             self._set_shape_and_strides(self._shape, strides, True, True)
 *         elif order_char == b'C':
 *             self._set_contiguous_strides(itemsize, True)             # <<<<<<<<<<<<<<
 *         elif order_char == b'F':
 *             self._set_contiguous_strides(itemsize, False)
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_set_contiguous_strides(__pyx_v_self, __pyx_v_itemsize, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 128, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":127
 *                 raise ValueError('memptr is required if strides is given.')
 *             self._set_shape_and_strides(self._shape, strides, True, True)
 *         elif order_char == b'C':             # <<<<<<<<<<<<<<
 *             self._set_contiguous_strides(itemsize, True)
 *         elif order_char == b'F':
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":129
 *         elif order_char == b'C':
 *             self._set_contiguous_strides(itemsize, True)
 *         elif order_char == b'F':             # <<<<<<<<<<<<<<
 *             self._set_contiguous_strides(itemsize, False)
 *         else:
 */
  __pyx_t_3 = ((__pyx_v_order_char == 'F') != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":130
 *             self._set_contiguous_strides(itemsize, True)
 *         elif order_char == b'F':
 *             self._set_contiguous_strides(itemsize, False)             # <<<<<<<<<<<<<<
 *         else:
 *             assert False
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_set_contiguous_strides(__pyx_v_self, __pyx_v_itemsize, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 130, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":129
 *         elif order_char == b'C':
 *             self._set_contiguous_strides(itemsize, True)
 *         elif order_char == b'F':             # <<<<<<<<<<<<<<
 *             self._set_contiguous_strides(itemsize, False)
 *         else:
 */
    goto __pyx_L7;
  }

  /* "cupy/core/core.pyx":132
 *             self._set_contiguous_strides(itemsize, False)
 *         else:
 *             assert False             # <<<<<<<<<<<<<<
 * 
 *         # data
 */
  /*else*/ {
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      if (unlikely(!0)) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(0, 132, __pyx_L1_error)
      }
    }
    #endif
  }
  __pyx_L7:;

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

    /* "cupy/core/core.pyx":136
 *         # data
 *         if memptr is None:
 *             self.data = memory.alloc(self.size * itemsize)             # <<<<<<<<<<<<<<
 *         else:
 *             self.data = memptr
 */
    __pyx_t_5 = PyInt_FromSsize_t((__pyx_v_self->size * __pyx_v_itemsize)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 136, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_5, 0)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 136, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GIVEREF(__pyx_t_8);
    __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_8);
    __pyx_t_8 = 0;

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

  /* "cupy/core/core.pyx":138
 *             self.data = memory.alloc(self.size * itemsize)
 *         else:
 *             self.data = memptr             # <<<<<<<<<<<<<<
 * 
 *     cdef _init_fast(self, const vector.vector[Py_ssize_t]& shape, dtype,
 */
  /*else*/ {
    if (!(likely(((__pyx_v_memptr) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_memptr, __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer))))) __PYX_ERR(0, 138, __pyx_L1_error)
    __pyx_t_8 = __pyx_v_memptr;
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __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_8);
    __pyx_t_8 = 0;
  }
  __pyx_L9:;

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

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

/* "cupy/core/core.pyx":140
 *             self.data = memptr
 * 
 *     cdef _init_fast(self, const vector.vector[Py_ssize_t]& shape, dtype,             # <<<<<<<<<<<<<<
 *                     bint c_order):
 *         """ For internal ndarray creation. """
 */

static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__init_fast(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, std::vector<Py_ssize_t>  const &__pyx_v_shape, PyObject *__pyx_v_dtype, int __pyx_v_c_order) {
  PyObject *__pyx_v_itemsize = 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;
  __Pyx_RefNannySetupContext("_init_fast", 0);

  /* "cupy/core/core.pyx":143
 *                     bint c_order):
 *         """ For internal ndarray creation. """
 *         self._shape = shape             # <<<<<<<<<<<<<<
 *         self.dtype, itemsize = _dtype.get_dtype_with_itemsize(dtype)
 *         self._set_contiguous_strides(itemsize, c_order)
 */
  __pyx_v_self->_shape = __pyx_v_shape;

  /* "cupy/core/core.pyx":144
 *         """ For internal ndarray creation. """
 *         self._shape = shape
 *         self.dtype, itemsize = _dtype.get_dtype_with_itemsize(dtype)             # <<<<<<<<<<<<<<
 *         self._set_contiguous_strides(itemsize, c_order)
 *         self.data = memory.alloc(self.size * itemsize)
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_6_dtype_get_dtype_with_itemsize(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    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, 144, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 144, __pyx_L1_error)
  }
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->dtype);
  __Pyx_DECREF(__pyx_v_self->dtype);
  __pyx_v_self->dtype = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_itemsize = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":145
 *         self._shape = shape
 *         self.dtype, itemsize = _dtype.get_dtype_with_itemsize(dtype)
 *         self._set_contiguous_strides(itemsize, c_order)             # <<<<<<<<<<<<<<
 *         self.data = memory.alloc(self.size * itemsize)
 * 
 */
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_v_itemsize); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 145, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_set_contiguous_strides(__pyx_v_self, __pyx_t_4, __pyx_v_c_order, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":146
 *         self.dtype, itemsize = _dtype.get_dtype_with_itemsize(dtype)
 *         self._set_contiguous_strides(itemsize, c_order)
 *         self.data = memory.alloc(self.size * itemsize)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_v_itemsize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_3, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __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->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":140
 *             self.data = memptr
 * 
 *     cdef _init_fast(self, const vector.vector[Py_ssize_t]& shape, dtype,             # <<<<<<<<<<<<<<
 *                     bint c_order):
 *         """ For internal ndarray creation. """
 */

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

/* "cupy/core/core.pyx":149
 * 
 *     @property
 *     def __cuda_array_interface__(self):             # <<<<<<<<<<<<<<
 *         desc = {
 *             'shape': self.shape,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_24__cuda_array_interface___1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_24__cuda_array_interface___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_24__cuda_array_interface_____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_24__cuda_array_interface_____get__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_v_desc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":151
 *     def __cuda_array_interface__(self):
 *         desc = {
 *             'shape': self.shape,             # <<<<<<<<<<<<<<
 *             'typestr': self.dtype.str,
 *             'descr': self.dtype.descr,
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_shape, __pyx_t_2) < 0) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":152
 *         desc = {
 *             'shape': self.shape,
 *             'typestr': self.dtype.str,             # <<<<<<<<<<<<<<
 *             'descr': self.dtype.descr,
 *             'version': 2,
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_str); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_typestr, __pyx_t_2) < 0) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":153
 *             'shape': self.shape,
 *             'typestr': self.dtype.str,
 *             'descr': self.dtype.descr,             # <<<<<<<<<<<<<<
 *             'version': 2,
 *         }
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_descr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_descr, __pyx_t_2) < 0) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_version, __pyx_int_2) < 0) __PYX_ERR(0, 151, __pyx_L1_error)
  __pyx_v_desc = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":156
 *             'version': 2,
 *         }
 *         if self._c_contiguous:             # <<<<<<<<<<<<<<
 *             desc['strides'] = None
 *         else:
 */
  __pyx_t_3 = (__pyx_v_self->_c_contiguous != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":157
 *         }
 *         if self._c_contiguous:
 *             desc['strides'] = None             # <<<<<<<<<<<<<<
 *         else:
 *             desc['strides'] = self.strides
 */
    if (unlikely(PyDict_SetItem(__pyx_v_desc, __pyx_n_u_strides, Py_None) < 0)) __PYX_ERR(0, 157, __pyx_L1_error)

    /* "cupy/core/core.pyx":156
 *             'version': 2,
 *         }
 *         if self._c_contiguous:             # <<<<<<<<<<<<<<
 *             desc['strides'] = None
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":159
 *             desc['strides'] = None
 *         else:
 *             desc['strides'] = self.strides             # <<<<<<<<<<<<<<
 *         if self.size > 0:
 *             desc['data'] = (self.data.ptr, False)
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(PyDict_SetItem(__pyx_v_desc, __pyx_n_u_strides, __pyx_t_1) < 0)) __PYX_ERR(0, 159, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":160
 *         else:
 *             desc['strides'] = self.strides
 *         if self.size > 0:             # <<<<<<<<<<<<<<
 *             desc['data'] = (self.data.ptr, False)
 *         else:
 */
  __pyx_t_3 = ((__pyx_v_self->size > 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":161
 *             desc['strides'] = self.strides
 *         if self.size > 0:
 *             desc['data'] = (self.data.ptr, False)             # <<<<<<<<<<<<<<
 *         else:
 *             desc['data'] = (0, False)
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->data->ptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __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(Py_False);
    __Pyx_GIVEREF(Py_False);
    PyTuple_SET_ITEM(__pyx_t_2, 1, Py_False);
    __pyx_t_1 = 0;
    if (unlikely(PyDict_SetItem(__pyx_v_desc, __pyx_n_u_data, __pyx_t_2) < 0)) __PYX_ERR(0, 161, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":160
 *         else:
 *             desc['strides'] = self.strides
 *         if self.size > 0:             # <<<<<<<<<<<<<<
 *             desc['data'] = (self.data.ptr, False)
 *         else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":163
 *             desc['data'] = (self.data.ptr, False)
 *         else:
 *             desc['data'] = (0, False)             # <<<<<<<<<<<<<<
 * 
 *         return desc
 */
  /*else*/ {
    if (unlikely(PyDict_SetItem(__pyx_v_desc, __pyx_n_u_data, __pyx_tuple__4) < 0)) __PYX_ERR(0, 163, __pyx_L1_error)
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":165
 *             desc['data'] = (0, False)
 * 
 *         return desc             # <<<<<<<<<<<<<<
 * 
 *     # The definition order of attributes and methods are borrowed from the
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_desc);
  __pyx_r = __pyx_v_desc;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":149
 * 
 *     @property
 *     def __cuda_array_interface__(self):             # <<<<<<<<<<<<<<
 *         desc = {
 *             'shape': self.shape,
 */

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

/* "cupy/core/core.pyx":175
 *     # -------------------------------------------------------------------------
 *     @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":185
 * 
 *         """
 *         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, 185, __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, 185, __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, 185, __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, 185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":186
 *         """
 *         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, 186, __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, 185, __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, 185, __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, 185, __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, 185, __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":175
 *     # -------------------------------------------------------------------------
 *     @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":198
 *         """
 * 
 *         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":199
 * 
 *         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, 199, __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, 199, __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":198
 *         """
 * 
 *         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":201
 *             return tuple(self._shape)
 * 
 *         def __set__(self, newshape):             # <<<<<<<<<<<<<<
 *             _manipulation._ndarray_shape_setter(self, 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) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "cupy/core/core.pyx":202
 * 
 *         def __set__(self, newshape):
 *             _manipulation._ndarray_shape_setter(self, newshape)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_22_routines_manipulation__ndarray_shape_setter(__pyx_v_self, __pyx_v_newshape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":201
 *             return tuple(self._shape)
 * 
 *         def __set__(self, newshape):             # <<<<<<<<<<<<<<
 *             _manipulation._ndarray_shape_setter(self, newshape)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __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.pyx":205
 * 
 *     @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":211
 * 
 *         """
 *         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, 211, __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, 211, __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":205
 * 
 *     @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":214
 * 
 *     @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":222
 * 
 *         """
 *         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, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":214
 * 
 *     @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":225
 * 
 *     @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":231
 * 
 *         """
 *         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, 231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":225
 * 
 *     @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":234
 * 
 *     @property
 *     def nbytes(self):             # <<<<<<<<<<<<<<
 *         """Total size of all 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":242
 * 
 *         """
 *         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, 242, __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, 242, __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, 242, __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":234
 * 
 *     @property
 *     def nbytes(self):             # <<<<<<<<<<<<<<
 *         """Total size of all 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":248
 *     # -------------------------------------------------------------------------
 *     @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;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":254
 * 
 *         """
 *         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, 254, __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, 254, __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, 254, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":255
 *         """
 *         if self.ndim < 2:
 *             return self             # <<<<<<<<<<<<<<
 *         else:
 *             return _manipulation._T(self)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = ((PyObject *)__pyx_v_self);
    goto __pyx_L0;

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

  /* "cupy/core/core.pyx":257
 *             return self
 *         else:
 *             return _manipulation._T(self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__T(__pyx_v_self, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":248
 *     # -------------------------------------------------------------------------
 *     @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":260
 * 
 *     @property
 *     def flat(self):             # <<<<<<<<<<<<<<
 *         return cupy.flatiter(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_4flat_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_4flat_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_4flat___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_4flat___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;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":261
 *     @property
 *     def flat(self):
 *         return cupy.flatiter(self)             # <<<<<<<<<<<<<<
 * 
 *     __array_priority__ = 100
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_flatiter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __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, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __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, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __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, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __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, 261, __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(((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_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __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":260
 * 
 *     @property
 *     def flat(self):             # <<<<<<<<<<<<<<
 *         return cupy.flatiter(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.flat.__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":274
 *     # -------------------------------------------------------------------------
 *     @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":282
 * 
 *         """
 *         return _CArray_from_ndarray(self)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__CArray_from_ndarray(__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":274
 *     # -------------------------------------------------------------------------
 *     @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":287
 *     # Array conversion
 *     # -------------------------------------------------------------------------
 *     cpdef item(self):             # <<<<<<<<<<<<<<
 *         """Converts the array with one element to a Python scalar
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_3item(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_item(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("item", 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_item); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __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_3item)) {
      __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, 287, __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, 287, __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
 * 
 *         """
 *         if self.size != 1:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'can only convert an array of size 1 to a Python scalar')
 */
  __pyx_t_5 = ((__pyx_v_self->size != 1) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "cupy/core/core.pyx":297
 *         """
 *         if self.size != 1:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'can only convert an array of size 1 to a Python scalar')
 *         return self.get().item()
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __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, 297, __pyx_L1_error)

    /* "cupy/core/core.pyx":296
 * 
 *         """
 *         if self.size != 1:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'can only convert an array of size 1 to a Python scalar')
 */
  }

  /* "cupy/core/core.pyx":299
 *             raise ValueError(
 *                 'can only convert an array of size 1 to a Python scalar')
 *         return self.get().item()             # <<<<<<<<<<<<<<
 * 
 *     cpdef tolist(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, 299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_item); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 299, __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, 299, __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, 299, __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":287
 *     # Array conversion
 *     # -------------------------------------------------------------------------
 *     cpdef item(self):             # <<<<<<<<<<<<<<
 *         """Converts the array with one element to a Python scalar
 * 
 */

  /* 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.item", __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_3item(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_2item[] = "ndarray.item(self)\nConverts the array with one element to a Python scalar\n\n        Returns:\n            int or float or complex: The element of the array.\n\n        .. seealso:: :meth:`numpy.ndarray.item`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_3item(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("item (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_2item(((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_2item(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("item", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray_item(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __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.item", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":301
 *         return self.get().item()
 * 
 *     cpdef tolist(self):             # <<<<<<<<<<<<<<
 *         """Converts the array to a (possibly nested) Python list.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_5tolist(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, 301, __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_5tolist)) {
      __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, 301, __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, 301, __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":310
 * 
 *         """
 *         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, 310, __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, 310, __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, 310, __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, 310, __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":301
 *         return self.get().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_5tolist(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_4tolist[] = "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_5tolist(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_4tolist(((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_4tolist(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, 301, __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":315
 *     # TODO(okuta): Implement tostring
 * 
 *     cpdef bytes tobytes(self, order='C'):             # <<<<<<<<<<<<<<
 *         """Turns the array into a Python bytes object."""
 *         return self.get().tobytes(order)
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_7tobytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_tobytes(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tobytes *__pyx_optional_args) {
  PyObject *__pyx_v_order = ((PyObject *)__pyx_n_u_C);
  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("tobytes", 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_tobytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 315, __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_7tobytes)) {
      __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_order); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 315, __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, 315, __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, 315, __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, 315, __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, 315, __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(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 315, __pyx_L1_error)
      __pyx_r = ((PyObject*)__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":317
 *     cpdef bytes tobytes(self, order='C'):
 *         """Turns the array into a Python bytes object."""
 *         return self.get().tobytes(order)             # <<<<<<<<<<<<<<
 * 
 *     cpdef tofile(self, fid, sep='', format='%s'):
 */
  __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, 317, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tobytes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 317, __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_v_order); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __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_order};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __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_order};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 317, __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_INCREF(__pyx_v_order);
      __Pyx_GIVEREF(__pyx_v_order);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_order);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __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;
  if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 317, __pyx_L1_error)
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":315
 *     # TODO(okuta): Implement tostring
 * 
 *     cpdef bytes tobytes(self, order='C'):             # <<<<<<<<<<<<<<
 *         """Turns the array into a Python bytes object."""
 *         return self.get().tobytes(order)
 */

  /* 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.tobytes", __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_7tobytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_6tobytes[] = "ndarray.tobytes(self, order=u'C') -> bytes\nTurns the array into a Python bytes object.";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_7tobytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_order = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tobytes (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_order,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_n_u_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, "tobytes") < 0)) __PYX_ERR(0, 315, __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("tobytes", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 315, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.tobytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_6tobytes(((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_6tobytes(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_tobytes __pyx_t_2;
  __Pyx_RefNannySetupContext("tobytes", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.order = __pyx_v_order;
  __pyx_t_1 = __pyx_vtabptr_4cupy_4core_4core_ndarray->tobytes(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 315, __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.tobytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":319
 *         return self.get().tobytes(order)
 * 
 *     cpdef tofile(self, fid, sep='', format='%s'):             # <<<<<<<<<<<<<<
 *         """Writes the array to a file.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_9tofile(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_u__6);
  PyObject *__pyx_v_format = ((PyObject *)__pyx_kp_u_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, 319, __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_9tofile)) {
      __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, 319, __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, 319, __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, 319, __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, 319, __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":325
 * 
 *         """
 *         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, 325, __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, 325, __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, 325, __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, 325, __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, 325, __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, 325, __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":319
 *         return self.get().tobytes(order)
 * 
 *     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_9tofile(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_8tofile[] = "ndarray.tofile(self, fid, sep=u'', format=u'%s')\nWrites the array to a file.\n\n        .. seealso:: :meth:`numpy.ndarray.tolist`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_9tofile(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_u__6);
    values[2] = ((PyObject *)__pyx_kp_u_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, 319, __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, 319, __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_8tofile(((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_8tofile(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, 319, __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":327
 *         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_11dump(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, 327, __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_11dump)) {
      __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, 327, __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, 327, __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, 327, __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, 327, __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, 327, __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":334
 * 
 *         """
 *         pickle.dump(self, file, -1)             # <<<<<<<<<<<<<<
 * 
 *     cpdef bytes dumps(self):
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_pickle); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dump); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 334, __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 && 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_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, 334, __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, 334, __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, 334, __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, 334, __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":327
 *         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_11dump(PyObject *__pyx_v_self, PyObject *__pyx_v_file); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_10dump[] = "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_11dump(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_10dump(((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_10dump(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, 327, __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":336
 *         pickle.dump(self, file, -1)
 * 
 *     cpdef bytes dumps(self):             # <<<<<<<<<<<<<<
 *         """Dumps a pickle of the array to a string."""
 *         return pickle.dumps(self, -1)
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_13dumps(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, 336, __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_13dumps)) {
      __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, 336, __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, 336, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 336, __pyx_L1_error)
      __pyx_r = ((PyObject*)__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":338
 *     cpdef bytes dumps(self):
 *         """Dumps a pickle of the array to a string."""
 *         return pickle.dumps(self, -1)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray astype(
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_pickle); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dumps); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 338, __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 && 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, ((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, 338, __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, 338, __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, 338, __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, 338, __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;
  if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 338, __pyx_L1_error)
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":336
 *         pickle.dump(self, file, -1)
 * 
 *     cpdef bytes dumps(self):             # <<<<<<<<<<<<<<
 *         """Dumps a pickle of the array to a string."""
 *         return pickle.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_13dumps(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_12dumps[] = "ndarray.dumps(self) -> bytes\nDumps a pickle of the array to a string.";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_13dumps(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_12dumps(((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_12dumps(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, 336, __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":340
 *         return pickle.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_15astype(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_u_K);

  /* "cupy/core/core.pyx":341
 * 
 *     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;
  int __pyx_v_order_char;
  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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  __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":340
 *         return pickle.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, 340, __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_15astype)) {
      __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, 340, __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, 340, __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, 340, __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, 340, __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, 340, __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":371
 * 
 *         # 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":372
 *         # 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, 372, __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, 372, __pyx_L1_error)

    /* "cupy/core/core.pyx":371
 * 
 *         # 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":373
 *         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":374
 *             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, 374, __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, 374, __pyx_L1_error)

    /* "cupy/core/core.pyx":373
 *         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":376
 *             raise TypeError('subok is not supported yet')
 * 
 *         if order is None:             # <<<<<<<<<<<<<<
 *             order = 'K'
 *         cdef int order_char = internal._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":377
 * 
 *         if order is None:
 *             order = 'K'             # <<<<<<<<<<<<<<
 *         cdef int order_char = internal._normalize_order(order)
 * 
 */
    __Pyx_INCREF(__pyx_n_u_K);
    __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_u_K);

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

  /* "cupy/core/core.pyx":378
 *         if order is None:
 *             order = 'K'
 *         cdef int order_char = internal._normalize_order(order)             # <<<<<<<<<<<<<<
 * 
 *         dtype = get_dtype(dtype)
 */
  __pyx_t_5 = __pyx_f_4cupy_4core_8internal__normalize_order(__pyx_v_order, NULL); if (unlikely(__pyx_t_5 == ((int)0) && PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L1_error)
  __pyx_v_order_char = __pyx_t_5;

  /* "cupy/core/core.pyx":380
 *         cdef int order_char = internal._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, 380, __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":381
 * 
 *         dtype = get_dtype(dtype)
 *         if dtype == self.dtype:             # <<<<<<<<<<<<<<
 *             if not copy and (
 *                     order_char == b'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, 381, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":382
 *         dtype = get_dtype(dtype)
 *         if dtype == self.dtype:
 *             if not copy and (             # <<<<<<<<<<<<<<
 *                     order_char == b'K' or
 *                     order_char == b'A' and (self._c_contiguous or
 */
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_copy); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 382, __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":383
 *         if dtype == self.dtype:
 *             if not copy and (
 *                     order_char == b'K' or             # <<<<<<<<<<<<<<
 *                     order_char == b'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":384
 *             if not copy and (
 *                     order_char == b'K' or
 *                     order_char == b'A' and (self._c_contiguous or             # <<<<<<<<<<<<<<
 *                                             self._f_contiguous) or
 *                     order_char == b'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":385
 *                     order_char == b'K' or
 *                     order_char == b'A' and (self._c_contiguous or
 *                                             self._f_contiguous) or             # <<<<<<<<<<<<<<
 *                     order_char == b'C' and self._c_contiguous or
 *                     order_char == b'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":386
 *                     order_char == b'A' and (self._c_contiguous or
 *                                             self._f_contiguous) or
 *                     order_char == b'C' and self._c_contiguous or             # <<<<<<<<<<<<<<
 *                     order_char == b'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":387
 *                                             self._f_contiguous) or
 *                     order_char == b'C' and self._c_contiguous or
 *                     order_char == b'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":382
 *         dtype = get_dtype(dtype)
 *         if dtype == self.dtype:
 *             if not copy and (             # <<<<<<<<<<<<<<
 *                     order_char == b'K' or
 *                     order_char == b'A' and (self._c_contiguous or
 */
    if (__pyx_t_8) {

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

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

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

  /* "cupy/core/core.pyx":390
 *                 return self
 * 
 *         order_char = _update_order_char(self, order_char)             # <<<<<<<<<<<<<<
 * 
 *         if order_char == b'K':
 */
  __pyx_v_order_char = __pyx_f_4cupy_4core_4core__update_order_char(__pyx_v_self, __pyx_v_order_char, 0);

  /* "cupy/core/core.pyx":392
 *         order_char = _update_order_char(self, order_char)
 * 
 *         if order_char == b'K':             # <<<<<<<<<<<<<<
 *             strides = _get_strides_for_order_K(self, dtype)
 *             newarray = _ndarray_init(self._shape, dtype)
 */
  __pyx_t_8 = ((__pyx_v_order_char == 'K') != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":393
 * 
 *         if order_char == b'K':
 *             strides = _get_strides_for_order_K(self, dtype)             # <<<<<<<<<<<<<<
 *             newarray = _ndarray_init(self._shape, dtype)
 *             # TODO(niboshi): Confirm update_x_contiguity flags
 */
    __pyx_v_strides = __pyx_f_4cupy_4core_4core__get_strides_for_order_K(__pyx_v_self, __pyx_v_dtype, 0, NULL);

    /* "cupy/core/core.pyx":394
 *         if order_char == b'K':
 *             strides = _get_strides_for_order_K(self, dtype)
 *             newarray = _ndarray_init(self._shape, dtype)             # <<<<<<<<<<<<<<
 *             # TODO(niboshi): Confirm update_x_contiguity flags
 *             newarray._set_shape_and_strides(self._shape, strides, True, True)
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__ndarray_init(__pyx_v_self->_shape, __pyx_v_dtype)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 394, __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":396
 *             newarray = _ndarray_init(self._shape, dtype)
 *             # TODO(niboshi): Confirm update_x_contiguity flags
 *             newarray._set_shape_and_strides(self._shape, strides, True, True)             # <<<<<<<<<<<<<<
 *         else:
 *             newarray = ndarray(self.shape, dtype=dtype, order=chr(order_char))
 */
    __pyx_t_1 = ((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, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":392
 *         order_char = _update_order_char(self, order_char)
 * 
 *         if order_char == b'K':             # <<<<<<<<<<<<<<
 *             strides = _get_strides_for_order_K(self, dtype)
 *             newarray = _ndarray_init(self._shape, dtype)
 */
    goto __pyx_L17;
  }

  /* "cupy/core/core.pyx":398
 *             newarray._set_shape_and_strides(self._shape, strides, True, True)
 *         else:
 *             newarray = ndarray(self.shape, dtype=dtype, order=chr(order_char))             # <<<<<<<<<<<<<<
 * 
 *         if self.size == 0:
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 398, __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(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __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, 398, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_order_char); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 398, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_chr, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 398, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_order, __pyx_t_6) < 0) __PYX_ERR(0, 398, __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_2, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 398, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __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_6);
    __pyx_t_6 = 0;
  }
  __pyx_L17:;

  /* "cupy/core/core.pyx":400
 *             newarray = ndarray(self.shape, dtype=dtype, order=chr(order_char))
 * 
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             # skip copy
 *             pass
 */
  __pyx_t_8 = ((__pyx_v_self->size == 0) != 0);
  if (__pyx_t_8) {
    goto __pyx_L18;
  }

  /* "cupy/core/core.pyx":403
 *             # skip copy
 *             pass
 *         elif 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, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = (__Pyx_PyUnicode_Equals(__pyx_t_6, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 403, __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_L19_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, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = (__Pyx_PyUnicode_Equals(__pyx_t_6, __pyx_n_u_b, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_8 = __pyx_t_9;
  __pyx_L19_bool_binop_done:;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":404
 *             pass
 *         elif 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, 404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_not_equal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __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, 404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 404, __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_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 404, __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, 404, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 404, __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_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":403
 *             # skip copy
 *             pass
 *         elif 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_L18;
  }

  /* "cupy/core/core.pyx":405
 *         elif 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_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 405, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_9 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 405, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_9) {
  } else {
    __pyx_t_8 = __pyx_t_9;
    goto __pyx_L21_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_newarray->dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 405, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_9 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_c, Py_NE)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 405, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_8 = __pyx_t_9;
  __pyx_L21_bool_binop_done:;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":406
 *             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, 406, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_warn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 406, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":408
 *             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, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ComplexWarning); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __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_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_kp_u_Casting_complex_values_to_real_d, __pyx_t_1};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 406, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_u_Casting_complex_values_to_real_d, __pyx_t_1};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 406, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 406, __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_u_Casting_complex_values_to_real_d);
      __Pyx_GIVEREF(__pyx_kp_u_Casting_complex_values_to_real_d);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_kp_u_Casting_complex_values_to_real_d);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 406, __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_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":409
 *                 'Casting complex values to real discards the imaginary part',
 *                 numpy.ComplexWarning)
 *             elementwise_copy(self.real, newarray)             # <<<<<<<<<<<<<<
 *         else:
 *             elementwise_copy(self, newarray)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_real); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __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[3] = {__pyx_t_1, __pyx_t_4, ((PyObject *)__pyx_v_newarray)};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 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[3] = {__pyx_t_1, __pyx_t_4, ((PyObject *)__pyx_v_newarray)};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __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, 409, __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_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_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __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_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":405
 *         elif 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_L18;
  }

  /* "cupy/core/core.pyx":411
 *             elementwise_copy(self.real, newarray)
 *         else:
 *             elementwise_copy(self, newarray)             # <<<<<<<<<<<<<<
 *         return newarray
 * 
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 411, __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[3] = {__pyx_t_6, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_newarray)};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 411, __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[3] = {__pyx_t_6, ((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_newarray)};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 411, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 411, __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_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 411, __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_3); __pyx_t_3 = 0;
  }
  __pyx_L18:;

  /* "cupy/core/core.pyx":412
 *         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":340
 *         return pickle.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_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_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_15astype(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_14astype[] = "ndarray.astype(self, dtype, order=u'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_15astype(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_u_K);

    /* "cupy/core/core.pyx":341
 * 
 *     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, 340, __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, 340, __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_14astype(((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":340
 *         return pickle.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_14astype(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, 340, __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":416
 *     # TODO(okuta): Implement byteswap
 * 
 *     cpdef ndarray copy(self, order='C'):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_17copy(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_u_C);
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  PyObject *__pyx_v_dev_id = 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;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  char const *__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;
  int __pyx_t_18;
  std::vector<Py_ssize_t>  __pyx_t_19;
  size_t __pyx_t_20;
  __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, 416, __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_17copy)) {
      __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, 416, __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, 416, __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, 416, __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, 416, __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, 416, __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, 416, __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":437
 *         """
 *         cdef ndarray x
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return self.astype(self.dtype, order=order)
 * 
 */
  __pyx_t_6 = ((__pyx_v_self->size == 0) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":438
 *         cdef ndarray x
 *         if self.size == 0:
 *             return self.astype(self.dtype, order=order)             # <<<<<<<<<<<<<<
 * 
 *         dev_id = device.get_device_id()
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_1 = __pyx_v_self->dtype;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_7.__pyx_n = 1;
    __pyx_t_7.order = __pyx_v_order;
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->astype(__pyx_v_self, __pyx_t_1, 0, &__pyx_t_7)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":437
 *         """
 *         cdef ndarray x
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return self.astype(self.dtype, order=order)
 * 
 */
  }

  /* "cupy/core/core.pyx":440
 *             return self.astype(self.dtype, order=order)
 * 
 *         dev_id = device.get_device_id()             # <<<<<<<<<<<<<<
 *         if self.data.device_id == dev_id:
 *             return self.astype(self.dtype, order=order)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get_device_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __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_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 440, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 440, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_dev_id = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":441
 * 
 *         dev_id = device.get_device_id()
 *         if self.data.device_id == dev_id:             # <<<<<<<<<<<<<<
 *             return self.astype(self.dtype, order=order)
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->data->device_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_v_dev_id, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 441, __pyx_L1_error)
  __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
 *         dev_id = device.get_device_id()
 *         if self.data.device_id == dev_id:
 *             return self.astype(self.dtype, order=order)             # <<<<<<<<<<<<<<
 * 
 *         # It need to make a contiguous copy for copying from another device
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_3 = __pyx_v_self->dtype;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_7.__pyx_n = 1;
    __pyx_t_7.order = __pyx_v_order;
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->astype(__pyx_v_self, __pyx_t_3, 0, &__pyx_t_7)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":441
 * 
 *         dev_id = device.get_device_id()
 *         if self.data.device_id == dev_id:             # <<<<<<<<<<<<<<
 *             return self.astype(self.dtype, order=order)
 * 
 */
  }

  /* "cupy/core/core.pyx":445
 * 
 *         # It need to make a contiguous copy for copying from another device
 *         runtime.setDevice(self.data.device_id)             # <<<<<<<<<<<<<<
 *         try:
 *             x = self.astype(self.dtype, order=order, copy=False)
 */
  __pyx_t_2 = __pyx_f_4cupy_4cuda_7runtime_setDevice(__pyx_v_self->data->device_id, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":446
 *         # It need to make a contiguous copy for copying from another device
 *         runtime.setDevice(self.data.device_id)
 *         try:             # <<<<<<<<<<<<<<
 *             x = self.astype(self.dtype, order=order, copy=False)
 *         finally:
 */
  /*try:*/ {

    /* "cupy/core/core.pyx":447
 *         runtime.setDevice(self.data.device_id)
 *         try:
 *             x = self.astype(self.dtype, order=order, copy=False)             # <<<<<<<<<<<<<<
 *         finally:
 *             runtime.setDevice(dev_id)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 447, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 447, __pyx_L6_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_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 447, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 447, __pyx_L6_error)
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 447, __pyx_L6_error)
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 447, __pyx_L6_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;
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 447, __pyx_L6_error)
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
    __pyx_t_5 = 0;
  }

  /* "cupy/core/core.pyx":449
 *             x = self.astype(self.dtype, order=order, copy=False)
 *         finally:
 *             runtime.setDevice(dev_id)             # <<<<<<<<<<<<<<
 *         newarray = _ndarray_init(x._shape, x.dtype)
 *         if not x._c_contiguous and not x._f_contiguous:
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_dev_id); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 449, __pyx_L1_error)
      __pyx_t_5 = __pyx_f_4cupy_4cuda_7runtime_setDevice(__pyx_t_8, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 449, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L7;
    }
    __pyx_L6_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __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_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;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_15);
      __Pyx_XGOTREF(__pyx_t_16);
      __pyx_t_8 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename;
      {
        __pyx_t_17 = __Pyx_PyInt_As_int(__pyx_v_dev_id); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 449, __pyx_L9_error)
        __pyx_t_5 = __pyx_f_4cupy_4cuda_7runtime_setDevice(__pyx_t_17, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 449, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
      }
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      __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_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10;
      goto __pyx_L1_error;
      __pyx_L9_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
      }
      __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;
      __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L7:;
  }

  /* "cupy/core/core.pyx":450
 *         finally:
 *             runtime.setDevice(dev_id)
 *         newarray = _ndarray_init(x._shape, x.dtype)             # <<<<<<<<<<<<<<
 *         if not x._c_contiguous and not x._f_contiguous:
 *             raise NotImplementedError(
 */
  __pyx_t_5 = __pyx_v_x->dtype;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__ndarray_init(__pyx_v_x->_shape, __pyx_t_5)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":451
 *             runtime.setDevice(dev_id)
 *         newarray = _ndarray_init(x._shape, x.dtype)
 *         if not x._c_contiguous and not x._f_contiguous:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError(
 *                 'CuPy cannot copy non-contiguous array between devices.')
 */
  __pyx_t_18 = ((!(__pyx_v_x->_c_contiguous != 0)) != 0);
  if (__pyx_t_18) {
  } else {
    __pyx_t_6 = __pyx_t_18;
    goto __pyx_L11_bool_binop_done;
  }
  __pyx_t_18 = ((!(__pyx_v_x->_f_contiguous != 0)) != 0);
  __pyx_t_6 = __pyx_t_18;
  __pyx_L11_bool_binop_done:;
  if (unlikely(__pyx_t_6)) {

    /* "cupy/core/core.pyx":452
 *         newarray = _ndarray_init(x._shape, x.dtype)
 *         if not x._c_contiguous and not x._f_contiguous:
 *             raise NotImplementedError(             # <<<<<<<<<<<<<<
 *                 'CuPy cannot copy non-contiguous array between devices.')
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __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, 452, __pyx_L1_error)

    /* "cupy/core/core.pyx":451
 *             runtime.setDevice(dev_id)
 *         newarray = _ndarray_init(x._shape, x.dtype)
 *         if not x._c_contiguous and not x._f_contiguous:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError(
 *                 'CuPy cannot copy non-contiguous array between devices.')
 */
  }

  /* "cupy/core/core.pyx":455
 *                 'CuPy cannot copy non-contiguous array between devices.')
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 *         newarray._strides = x._strides             # <<<<<<<<<<<<<<
 *         newarray._c_contiguous = x._c_contiguous
 *         newarray._f_contiguous = x._f_contiguous
 */
  __pyx_t_19 = __pyx_v_x->_strides;
  __pyx_v_newarray->_strides = __pyx_t_19;

  /* "cupy/core/core.pyx":456
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 *         newarray._strides = x._strides
 *         newarray._c_contiguous = x._c_contiguous             # <<<<<<<<<<<<<<
 *         newarray._f_contiguous = x._f_contiguous
 *         newarray.data.copy_from_device(x.data, x.nbytes)
 */
  __pyx_t_6 = __pyx_v_x->_c_contiguous;
  __pyx_v_newarray->_c_contiguous = __pyx_t_6;

  /* "cupy/core/core.pyx":457
 *         newarray._strides = x._strides
 *         newarray._c_contiguous = x._c_contiguous
 *         newarray._f_contiguous = x._f_contiguous             # <<<<<<<<<<<<<<
 *         newarray.data.copy_from_device(x.data, x.nbytes)
 *         return newarray
 */
  __pyx_t_6 = __pyx_v_x->_f_contiguous;
  __pyx_v_newarray->_f_contiguous = __pyx_t_6;

  /* "cupy/core/core.pyx":458
 *         newarray._c_contiguous = x._c_contiguous
 *         newarray._f_contiguous = x._f_contiguous
 *         newarray.data.copy_from_device(x.data, x.nbytes)             # <<<<<<<<<<<<<<
 *         return newarray
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_x->data);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_20 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_20 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = ((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_1), __pyx_t_20, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":459
 *         newarray._f_contiguous = x._f_contiguous
 *         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":416
 *     # 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(__pyx_v_dev_id);
  __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_17copy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_16copy[] = "ndarray.copy(self, order=u'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_17copy(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_u_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, 416, __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, 416, __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_16copy(((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_16copy(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, 416, __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":461
 *         return newarray
 * 
 *     cpdef ndarray view(self, dtype=None):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_19view(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);
  Py_ssize_t __pyx_v_ndim;
  int __pyx_v_self_is;
  int __pyx_v_v_is;
  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;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  __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, 461, __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_19view)) {
      __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, 461, __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, 461, __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, 461, __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, 461, __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, 461, __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, 461, __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":479
 *         cdef Py_ssize_t ndim
 *         cdef int self_is, v_is
 *         v = self._view(self._shape, self._strides, False, False)             # <<<<<<<<<<<<<<
 *         if dtype is None:
 *             return v
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_view(__pyx_v_self, __pyx_v_self->_shape, __pyx_v_self->_strides, 0, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 479, __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":480
 *         cdef int self_is, v_is
 *         v = self._view(self._shape, self._strides, False, False)
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             return v
 * 
 */
  __pyx_t_6 = (__pyx_v_dtype == Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":481
 *         v = self._view(self._shape, self._strides, False, False)
 *         if dtype is None:
 *             return v             # <<<<<<<<<<<<<<
 * 
 *         v.dtype, v_is = _dtype.get_dtype_with_itemsize(dtype)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_v));
    __pyx_r = __pyx_v_v;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":480
 *         cdef int self_is, v_is
 *         v = self._view(self._shape, self._strides, False, False)
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             return v
 * 
 */
  }

  /* "cupy/core/core.pyx":483
 *             return v
 * 
 *         v.dtype, v_is = _dtype.get_dtype_with_itemsize(dtype)             # <<<<<<<<<<<<<<
 *         self_is = self.dtype.itemsize
 *         if v_is == self_is:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_6_dtype_get_dtype_with_itemsize(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    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, 483, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 483, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 483, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 483, __pyx_L1_error)
  }
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 483, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_v->dtype);
  __Pyx_DECREF(__pyx_v_v->dtype);
  __pyx_v_v->dtype = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_v_is = __pyx_t_8;

  /* "cupy/core/core.pyx":484
 * 
 *         v.dtype, v_is = _dtype.get_dtype_with_itemsize(dtype)
 *         self_is = self.dtype.itemsize             # <<<<<<<<<<<<<<
 *         if v_is == self_is:
 *             return v
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self_is = __pyx_t_8;

  /* "cupy/core/core.pyx":485
 *         v.dtype, v_is = _dtype.get_dtype_with_itemsize(dtype)
 *         self_is = self.dtype.itemsize
 *         if v_is == self_is:             # <<<<<<<<<<<<<<
 *             return v
 * 
 */
  __pyx_t_7 = ((__pyx_v_v_is == __pyx_v_self_is) != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":486
 *         self_is = self.dtype.itemsize
 *         if v_is == self_is:
 *             return v             # <<<<<<<<<<<<<<
 * 
 *         ndim = self._shape.size()
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_v));
    __pyx_r = __pyx_v_v;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":485
 *         v.dtype, v_is = _dtype.get_dtype_with_itemsize(dtype)
 *         self_is = self.dtype.itemsize
 *         if v_is == self_is:             # <<<<<<<<<<<<<<
 *             return v
 * 
 */
  }

  /* "cupy/core/core.pyx":488
 *             return v
 * 
 *         ndim = self._shape.size()             # <<<<<<<<<<<<<<
 *         if ndim == 0:
 *             raise ValueError(
 */
  __pyx_v_ndim = __pyx_v_self->_shape.size();

  /* "cupy/core/core.pyx":489
 * 
 *         ndim = self._shape.size()
 *         if ndim == 0:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'Changing the dtype of a 0d array is only supported if '
 */
  __pyx_t_7 = ((__pyx_v_ndim == 0) != 0);
  if (unlikely(__pyx_t_7)) {

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

    /* "cupy/core/core.pyx":489
 * 
 *         ndim = self._shape.size()
 *         if ndim == 0:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'Changing the dtype of a 0d array is only supported if '
 */
  }

  /* "cupy/core/core.pyx":493
 *                 '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_7 = ((!(__pyx_v_self->_c_contiguous != 0)) != 0);
  if (unlikely(__pyx_t_7)) {

    /* "cupy/core/core.pyx":494
 *                 '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_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 494, __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, 494, __pyx_L1_error)

    /* "cupy/core/core.pyx":493
 *                 '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":497
 *                 'To change to a dtype of a different size, the array must '
 *                 'be C-contiguous')
 *         v._shape[ndim - 1] = v._shape[ndim - 1] * self_is // v_is             # <<<<<<<<<<<<<<
 *         v._strides[ndim - 1] = v._strides[ndim - 1] * v_is // self_is
 *         v.size = v.size * self_is // v_is
 */
  __pyx_t_9 = ((__pyx_v_v->_shape[(__pyx_v_ndim - 1)]) * __pyx_v_self_is);
  if (unlikely(__pyx_v_v_is == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 497, __pyx_L1_error)
  }
  else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((int)-1) > 0)) && unlikely(__pyx_v_v_is == (int)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_9))) {
    PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
    __PYX_ERR(0, 497, __pyx_L1_error)
  }
  (__pyx_v_v->_shape[(__pyx_v_ndim - 1)]) = __Pyx_div_Py_ssize_t(__pyx_t_9, __pyx_v_v_is);

  /* "cupy/core/core.pyx":498
 *                 'be C-contiguous')
 *         v._shape[ndim - 1] = v._shape[ndim - 1] * self_is // v_is
 *         v._strides[ndim - 1] = v._strides[ndim - 1] * v_is // self_is             # <<<<<<<<<<<<<<
 *         v.size = v.size * self_is // v_is
 *         return v
 */
  __pyx_t_9 = ((__pyx_v_v->_strides[(__pyx_v_ndim - 1)]) * __pyx_v_v_is);
  if (unlikely(__pyx_v_self_is == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 498, __pyx_L1_error)
  }
  else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((int)-1) > 0)) && unlikely(__pyx_v_self_is == (int)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_9))) {
    PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
    __PYX_ERR(0, 498, __pyx_L1_error)
  }
  (__pyx_v_v->_strides[(__pyx_v_ndim - 1)]) = __Pyx_div_Py_ssize_t(__pyx_t_9, __pyx_v_self_is);

  /* "cupy/core/core.pyx":499
 *         v._shape[ndim - 1] = v._shape[ndim - 1] * self_is // v_is
 *         v._strides[ndim - 1] = v._strides[ndim - 1] * v_is // self_is
 *         v.size = v.size * self_is // v_is             # <<<<<<<<<<<<<<
 *         return v
 * 
 */
  __pyx_t_9 = (__pyx_v_v->size * __pyx_v_self_is);
  if (unlikely(__pyx_v_v_is == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 499, __pyx_L1_error)
  }
  else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((int)-1) > 0)) && unlikely(__pyx_v_v_is == (int)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_9))) {
    PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
    __PYX_ERR(0, 499, __pyx_L1_error)
  }
  __pyx_v_v->size = __Pyx_div_Py_ssize_t(__pyx_t_9, __pyx_v_v_is);

  /* "cupy/core/core.pyx":500
 *         v._strides[ndim - 1] = v._strides[ndim - 1] * v_is // self_is
 *         v.size = v.size * self_is // v_is
 *         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":461
 *         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_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_19view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_18view[] = "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_19view(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, 461, __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, 461, __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_18view(((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_18view(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, 461, __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":505
 *     # TODO(okuta): Implement setflags
 * 
 *     cpdef fill(self, value):             # <<<<<<<<<<<<<<
 *         """Fills the array with a scalar value.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_21fill(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;
  int __pyx_t_9;
  __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, 505, __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_21fill)) {
      __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, 505, __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, 505, __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, 505, __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, 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 = 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, 505, __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":514
 * 
 *         """
 *         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, 514, __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, 514, __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, 514, __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":515
 *         """
 *         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, 515, __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, 515, __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, 515, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(__pyx_t_7)) {

      /* "cupy/core/core.pyx":516
 *         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, 516, __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, 516, __pyx_L1_error)

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

    /* "cupy/core/core.pyx":518
 *                 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, 518, __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, 518, __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, 518, __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":514
 * 
 *         """
 *         if isinstance(value, numpy.ndarray):             # <<<<<<<<<<<<<<
 *             if value.shape != ():
 *                 raise ValueError(
 */
  }

  /* "cupy/core/core.pyx":520
 *             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, 520, __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, 520, __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":521
 * 
 *         if value == 0 and self._c_contiguous:
 *             self.data.memset_async(0, self.nbytes)             # <<<<<<<<<<<<<<
 *         else:
 *             fill_kernel(value, self)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 521, __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, 521, __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, 521, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":520
 *             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":523
 *             self.data.memset_async(0, self.nbytes)
 *         else:
 *             fill_kernel(value, self)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  /*else*/ {
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core_fill_kernel);
    __pyx_t_2 = __pyx_v_4cupy_4core_4core_fill_kernel; __pyx_t_3 = NULL;
    __pyx_t_9 = 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_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_value, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 523, __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[3] = {__pyx_t_3, __pyx_v_value, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 523, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 523, __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(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_v_value);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, ((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, 523, __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_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L5:;

  /* "cupy/core/core.pyx":505
 *     # 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_21fill(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_20fill[] = "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_21fill(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_20fill(((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_20fill(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, 505, __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":528
 *     # Shape manipulation
 *     # -------------------------------------------------------------------------
 *     def reshape(self, *shape, order='C'):             # <<<<<<<<<<<<<<
 *         """Returns an array of a different shape and the same content.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_23reshape(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_22reshape[] = "ndarray.reshape(self, *shape, order=u'C')\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_23reshape(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_order = 0;
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reshape (wrapper)", 0);
  if (PyTuple_GET_SIZE(__pyx_args) > 0) {
    __pyx_v_shape = PyTuple_GetSlice(__pyx_args, 0, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_shape)) {
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_shape);
  } else {
    __pyx_v_shape = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_order,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_n_u_C);
    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  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (kw_args == 1) {
        const Py_ssize_t index = 0;
        PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
        if (value) { values[index] = value; kw_args--; }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "reshape") < 0)) __PYX_ERR(0, 528, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 0) {
      goto __pyx_L5_argtuple_error;
    } else {
    }
    __pyx_v_order = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("reshape", 0, 0, 0, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 528, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_shape); __pyx_v_shape = 0;
  __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_22reshape(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_order, __pyx_v_shape);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_22reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_order, PyObject *__pyx_v_shape) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("reshape", 0);

  /* "cupy/core/core.pyx":536
 * 
 *         """
 *         return _manipulation._ndarray_reshape(self, shape, order)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement resize
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_reshape(__pyx_v_self, __pyx_v_shape, __pyx_v_order)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":528
 *     # Shape manipulation
 *     # -------------------------------------------------------------------------
 *     def reshape(self, *shape, order='C'):             # <<<<<<<<<<<<<<
 *         """Returns an array of a different shape and the same content.
 * 
 */

  /* 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":540
 *     # TODO(okuta): Implement resize
 * 
 *     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_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("transpose", 0);

  /* "cupy/core/core.pyx":548
 * 
 *         """
 *         return _manipulation._ndarray_transpose(self, axes)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray swapaxes(self, Py_ssize_t axis1, Py_ssize_t axis2):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_transpose(__pyx_v_self, __pyx_v_axes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 548, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":540
 *     # TODO(okuta): Implement resize
 * 
 *     def transpose(self, *axes):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array with axes permuted.
 * 
 */

  /* 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":550
 *         return _manipulation._ndarray_transpose(self, 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) {
  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;
  __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, 550, __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, 550, __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, 550, __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, 550, __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, 550, __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, 550, __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, 550, __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, 550, __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":558
 * 
 *         """
 *         return _manipulation._ndarray_swapaxes(self, axis1, axis2)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray flatten(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_swapaxes(__pyx_v_self, __pyx_v_axis1, __pyx_v_axis2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 558, __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":550
 *         return _manipulation._ndarray_transpose(self, 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, 550, __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, 550, __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, 550, __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, 550, __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, 550, __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, 550, __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":560
 *         return _manipulation._ndarray_swapaxes(self, axis1, axis2)
 * 
 *     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_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("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, 560, __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, 560, __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, 560, __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, 560, __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":572
 *         """
 *         # TODO(beam2d): Support ordering option
 *         return _manipulation._ndarray_flatten(self)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray ravel(self, order='C'):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_flatten(__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 572, __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":560
 *         return _manipulation._ndarray_swapaxes(self, axis1, axis2)
 * 
 *     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_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, 560, __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":574
 *         return _manipulation._ndarray_flatten(self)
 * 
 *     cpdef ndarray ravel(self, order='C'):             # <<<<<<<<<<<<<<
 *         """Returns an array flattened into one dimension.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_31ravel(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_ravel(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_ravel *__pyx_optional_args) {
  PyObject *__pyx_v_order = ((PyObject *)__pyx_n_u_C);
  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;
  __Pyx_RefNannySetupContext("ravel", 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_ravel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 574, __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_v_order); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 574, __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, 574, __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, 574, __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, 574, __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, 574, __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, 574, __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":582
 * 
 *         """
 *         return _manipulation._ndarray_ravel(self, order)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray squeeze(self, axis=None):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_ravel(__pyx_v_self, __pyx_v_order)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 582, __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":574
 *         return _manipulation._ndarray_flatten(self)
 * 
 *     cpdef ndarray ravel(self, order='C'):             # <<<<<<<<<<<<<<
 *         """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_XDECREF(__pyx_t_5);
  __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, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_30ravel[] = "ndarray.ravel(self, order=u'C') -> 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, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_order = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ravel (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_order,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_n_u_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, "ravel") < 0)) __PYX_ERR(0, 574, __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("ravel", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 574, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.ravel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_30ravel(((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_30ravel(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_ravel __pyx_t_2;
  __Pyx_RefNannySetupContext("ravel", 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->ravel(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 574, __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":584
 *         return _manipulation._ndarray_ravel(self, order)
 * 
 *     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);
  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;
  __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, 584, __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, 584, __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, 584, __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, 584, __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, 584, __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, 584, __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, 584, __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":592
 * 
 *         """
 *         return _manipulation._ndarray_squeeze(self, axis)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_squeeze(__pyx_v_self, __pyx_v_axis)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 592, __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":584
 *         return _manipulation._ndarray_ravel(self, order)
 * 
 *     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_AddTraceback("cupy.core.core.ndarray.squeeze", __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_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, 584, __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, 584, __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, 584, __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":597
 *     # 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;
  __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, 597, __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, 597, __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, 597, __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, 597, __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, 597, __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, 597, __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":605
 * 
 *         """
 *         return _indexing._ndarray_take(self, indices, axis, out)             # <<<<<<<<<<<<<<
 * 
 *     cpdef put(self, indices, values, mode='wrap'):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_18_routines_indexing__ndarray_take(__pyx_v_self, __pyx_v_indices, __pyx_v_axis, __pyx_v_out)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 605, __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":597
 *     # 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, 597, __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, 597, __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, 597, __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":607
 *         return _indexing._ndarray_take(self, indices, axis, out)
 * 
 *     cpdef put(self, indices, values, mode='wrap'):             # <<<<<<<<<<<<<<
 *         """Replaces specified elements of an array with given values.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_37put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_put(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_indices, PyObject *__pyx_v_values, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_put *__pyx_optional_args) {
  PyObject *__pyx_v_mode = ((PyObject *)__pyx_n_u_wrap);
  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("put", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_mode = __pyx_optional_args->mode;
    }
  }
  /* 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_put); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 607, __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_37put)) {
      __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_indices, __pyx_v_values, __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, 607, __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_values, __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, 607, __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, 607, __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_values);
        __Pyx_GIVEREF(__pyx_v_values);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_values);
        __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, 607, __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":614
 *            :meth:`numpy.ndarray.put`
 *         """
 *         return _indexing._ndarray_put(self, indices, values, mode)             # <<<<<<<<<<<<<<
 * 
 *     cpdef repeat(self, repeats, axis=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_18_routines_indexing__ndarray_put(__pyx_v_self, __pyx_v_indices, __pyx_v_values, __pyx_v_mode)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 614, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":607
 *         return _indexing._ndarray_take(self, indices, axis, out)
 * 
 *     cpdef put(self, indices, values, mode='wrap'):             # <<<<<<<<<<<<<<
 *         """Replaces specified elements of an array with given values.
 * 
 */

  /* 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.put", __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_37put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_36put[] = "ndarray.put(self, indices, values, mode=u'wrap')\nReplaces specified elements of an array with given values.\n\n        .. seealso::\n           :func:`cupy.put` for full documentation,\n           :meth:`numpy.ndarray.put`\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_37put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_indices = 0;
  PyObject *__pyx_v_values = 0;
  PyObject *__pyx_v_mode = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("put (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_indices,&__pyx_n_s_values,&__pyx_n_s_mode,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)__pyx_n_u_wrap);
    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 (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_values)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("put", 0, 2, 3, 1); __PYX_ERR(0, 607, __pyx_L3_error)
        }
        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, "put") < 0)) __PYX_ERR(0, 607, __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_indices = values[0];
    __pyx_v_values = values[1];
    __pyx_v_mode = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("put", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 607, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_36put(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_indices, __pyx_v_values, __pyx_v_mode);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_36put(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_indices, PyObject *__pyx_v_values, PyObject *__pyx_v_mode) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_put __pyx_t_2;
  __Pyx_RefNannySetupContext("put", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.mode = __pyx_v_mode;
  __pyx_t_1 = __pyx_vtabptr_4cupy_4core_4core_ndarray->put(__pyx_v_self, __pyx_v_indices, __pyx_v_values, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 607, __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.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":616
 *         return _indexing._ndarray_put(self, indices, values, mode)
 * 
 *     cpdef repeat(self, repeats, axis=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with repeated arrays along an axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_39repeat(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;
  __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, 616, __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_39repeat)) {
      __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, 616, __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, 616, __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, 616, __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, 616, __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":624
 * 
 *         """
 *         return _manipulation._ndarray_repeat(self, repeats, axis)             # <<<<<<<<<<<<<<
 * 
 *     cpdef choose(self, choices, out=None, mode='raise'):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_repeat(__pyx_v_self, __pyx_v_repeats, __pyx_v_axis)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":616
 *         return _indexing._ndarray_put(self, indices, values, mode)
 * 
 *     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_39repeat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_38repeat[] = "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_39repeat(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, 616, __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, 616, __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_38repeat(((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_38repeat(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, 616, __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":626
 *         return _manipulation._ndarray_repeat(self, repeats, axis)
 * 
 *     cpdef choose(self, choices, out=None, mode='raise'):             # <<<<<<<<<<<<<<
 *         # TODO(niboshi): Write docstring
 *         return _indexing._ndarray_choose(self, choices, out, mode)
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_41choose(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_u_raise);
  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("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;
      }
    }
  }
  /* 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, 626, __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_41choose)) {
      __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, 626, __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, 626, __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, 626, __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, 626, __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":628
 *     cpdef choose(self, choices, out=None, mode='raise'):
 *         # TODO(niboshi): Write docstring
 *         return _indexing._ndarray_choose(self, choices, out, mode)             # <<<<<<<<<<<<<<
 * 
 *     cpdef sort(self, int axis=-1):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_18_routines_indexing__ndarray_choose(__pyx_v_self, __pyx_v_choices, __pyx_v_out, __pyx_v_mode)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 628, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":626
 *         return _manipulation._ndarray_repeat(self, repeats, axis)
 * 
 *     cpdef choose(self, choices, out=None, mode='raise'):             # <<<<<<<<<<<<<<
 *         # TODO(niboshi): Write docstring
 *         return _indexing._ndarray_choose(self, choices, out, mode)
 */

  /* 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_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_41choose(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_40choose[] = "ndarray.choose(self, choices, out=None, mode=u'raise')";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_41choose(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_u_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, 626, __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, 626, __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_40choose(((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_40choose(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, 626, __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":630
 *         return _indexing._ndarray_choose(self, choices, out, mode)
 * 
 *     cpdef sort(self, int axis=-1):             # <<<<<<<<<<<<<<
 *         """Sort an array, in-place with a stable sorting algorithm.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_43sort(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_sort(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sort *__pyx_optional_args) {
  int __pyx_v_axis = ((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;
  __Pyx_RefNannySetupContext("sort", 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_sort); 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_43sort)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 630, __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, 630, __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, 630, __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, 630, __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, 630, __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, 630, __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_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":648
 *         """
 *         # TODO(takagi): Support kind argument.
 *         _sorting._ndarray_sort(self, axis)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray argsort(self, axis=-1):
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_17_routines_sorting__ndarray_sort(__pyx_v_self, __pyx_v_axis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 648, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":630
 *         return _indexing._ndarray_choose(self, choices, out, mode)
 * 
 *     cpdef sort(self, int 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_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.sort", __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_43sort(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_42sort[] = "ndarray.sort(self, int 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_43sort(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_axis;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sort (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,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 (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, 630, __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;
      }
    }
    if (values[0]) {
      __pyx_v_axis = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_axis == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 630, __pyx_L3_error)
    } else {
      __pyx_v_axis = ((int)-1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sort", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 630, __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_42sort(((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_42sort(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sort __pyx_t_2;
  __Pyx_RefNannySetupContext("sort", 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->sort(__pyx_v_self, 1, &__pyx_t_2); 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.sort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":650
 *         _sorting._ndarray_sort(self, axis)
 * 
 *     cpdef ndarray argsort(self, axis=-1):             # <<<<<<<<<<<<<<
 *         """Returns the indices that would sort an array with stable sorting
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_45argsort(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_argsort(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argsort *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)__pyx_int_neg_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;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("argsort", 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_argsort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 650, __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_45argsort)) {
      __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, 650, __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, 650, __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, 650, __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, 650, __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, 650, __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, 650, __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":667
 *         """
 *         # TODO(takagi): Support kind argument.
 *         return _sorting._ndarray_argsort(self, axis)             # <<<<<<<<<<<<<<
 * 
 *     cpdef partition(self, kth, int axis=-1):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_17_routines_sorting__ndarray_argsort(__pyx_v_self, __pyx_v_axis)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 667, __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":650
 *         _sorting._ndarray_sort(self, axis)
 * 
 *     cpdef ndarray 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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.core.core.ndarray.argsort", __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_45argsort(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_44argsort[] = "ndarray.argsort(self, axis=-1) -> ndarray\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_45argsort(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, 650, __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, 650, __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_44argsort(((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_44argsort(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_argsort __pyx_t_2;
  __Pyx_RefNannySetupContext("argsort", 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->argsort(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 650, __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.argsort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":669
 *         return _sorting._ndarray_argsort(self, axis)
 * 
 *     cpdef partition(self, kth, int axis=-1):             # <<<<<<<<<<<<<<
 *         """Partitions an array.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_47partition(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_partition(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_kth, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_partition *__pyx_optional_args) {
  int __pyx_v_axis = ((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;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("partition", 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_partition); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 669, __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_47partition)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 669, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __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_v_kth, __pyx_t_3};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 669, __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[3] = {__pyx_t_5, __pyx_v_kth, __pyx_t_3};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 669, __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_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 669, __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(__pyx_v_kth);
        __Pyx_GIVEREF(__pyx_v_kth);
        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_kth);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 669, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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":685
 * 
 *         """
 *         _sorting._ndarray_partition(self, kth, axis)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray argpartition(self, kth, axis=-1):
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_17_routines_sorting__ndarray_partition(__pyx_v_self, __pyx_v_kth, __pyx_v_axis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 685, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":669
 *         return _sorting._ndarray_argsort(self, axis)
 * 
 *     cpdef partition(self, kth, int 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_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core.ndarray.partition", __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_47partition(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_46partition[] = "ndarray.partition(self, kth, int 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_47partition(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_kth = 0;
  int __pyx_v_axis;
  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};
    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, 669, __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];
    if (values[1]) {
      __pyx_v_axis = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_axis == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 669, __pyx_L3_error)
    } else {
      __pyx_v_axis = ((int)-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, 669, __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_46partition(((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_46partition(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_kth, int __pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_partition __pyx_t_2;
  __Pyx_RefNannySetupContext("partition", 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->partition(__pyx_v_self, __pyx_v_kth, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 669, __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.partition", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":687
 *         _sorting._ndarray_partition(self, kth, axis)
 * 
 *     cpdef ndarray argpartition(self, kth, axis=-1):             # <<<<<<<<<<<<<<
 *         """Returns the indices that would partially sort an array.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_49argpartition(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_argpartition(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_kth, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argpartition *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)__pyx_int_neg_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;
  __Pyx_RefNannySetupContext("argpartition", 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_argpartition); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 687, __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_49argpartition)) {
      __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[3] = {__pyx_t_4, __pyx_v_kth, __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, 687, __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_kth, __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, 687, __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, 687, __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_kth);
        __Pyx_GIVEREF(__pyx_v_kth);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_kth);
        __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, 687, __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, 687, __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":706
 * 
 *         """
 *         return _sorting._ndarray_argpartition(self, kth, axis)             # <<<<<<<<<<<<<<
 * 
 *     cpdef tuple nonzero(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_17_routines_sorting__ndarray_argpartition(((PyObject *)__pyx_v_self), __pyx_v_kth, __pyx_v_axis)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 706, __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":687
 *         _sorting._ndarray_partition(self, kth, axis)
 * 
 *     cpdef ndarray argpartition(self, kth, axis=-1):             # <<<<<<<<<<<<<<
 *         """Returns the indices that would partially sort an 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.argpartition", __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_49argpartition(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_48argpartition[] = "ndarray.argpartition(self, kth, axis=-1) -> ndarray\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_49argpartition(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, 687, __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, 687, __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_48argpartition(((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_48argpartition(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_kth, PyObject *__pyx_v_axis) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argpartition __pyx_t_2;
  __Pyx_RefNannySetupContext("argpartition", 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->argpartition(__pyx_v_self, __pyx_v_kth, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 687, __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.argpartition", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":708
 *         return _sorting._ndarray_argpartition(self, kth, axis)
 * 
 *     cpdef tuple nonzero(self):             # <<<<<<<<<<<<<<
 *         """Return the indices of the elements that are non-zero.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_51nonzero(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_nonzero(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("nonzero", 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_nonzero); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 708, __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_51nonzero)) {
      __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, 708, __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, 708, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 708, __pyx_L1_error)
      __pyx_r = ((PyObject*)__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":725
 * 
 *         """
 *         if self.ndim == 0:             # <<<<<<<<<<<<<<
 *             warnings.warn(
 *                 'calling nonzero on 0d arrays is deprecated',
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 725, __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, 725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 725, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_5) {

    /* "cupy/core/core.pyx":726
 *         """
 *         if self.ndim == 0:
 *             warnings.warn(             # <<<<<<<<<<<<<<
 *                 'calling nonzero on 0d arrays is deprecated',
 *                 DeprecationWarning)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_warnings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 726, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_warn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 726, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":728
 *             warnings.warn(
 *                 'calling nonzero on 0d arrays is deprecated',
 *                 DeprecationWarning)             # <<<<<<<<<<<<<<
 * 
 *         return _indexing._ndarray_nonzero(self)
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 726, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":725
 * 
 *         """
 *         if self.ndim == 0:             # <<<<<<<<<<<<<<
 *             warnings.warn(
 *                 'calling nonzero on 0d arrays is deprecated',
 */
  }

  /* "cupy/core/core.pyx":730
 *                 DeprecationWarning)
 * 
 *         return _indexing._ndarray_nonzero(self)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray compress(self, condition, axis=None, out=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_f_4cupy_4core_18_routines_indexing__ndarray_nonzero(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":708
 *         return _sorting._ndarray_argpartition(self, kth, axis)
 * 
 *     cpdef tuple 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_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.core.core.ndarray.nonzero", __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_51nonzero(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_50nonzero[] = "ndarray.nonzero(self) -> tuple\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        .. warning::\n\n            This function may synchronize the device.\n\n        .. seealso::\n            :func:`numpy.nonzero`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_51nonzero(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_50nonzero(((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_50nonzero(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("nonzero", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray_nonzero(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 708, __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.nonzero", __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
 *         return _indexing._ndarray_nonzero(self)
 * 
 *     cpdef ndarray compress(self, condition, axis=None, out=None):             # <<<<<<<<<<<<<<
 *         """Returns selected slices of this array along given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_53compress(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_compress(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_condition, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_compress *__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;
  __Pyx_RefNannySetupContext("compress", 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_compress); 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_53compress)) {
      __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_condition, __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, 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[4] = {__pyx_t_4, __pyx_v_condition, __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, 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(3+__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_condition);
        __Pyx_GIVEREF(__pyx_v_condition);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_condition);
        __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, 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;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 732, __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":744
 * 
 *         """
 *         return _indexing._ndarray_compress(self, condition, axis, out)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray diagonal(self, offset=0, axis1=0, axis2=1):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_18_routines_indexing__ndarray_compress(__pyx_v_self, __pyx_v_condition, __pyx_v_axis, __pyx_v_out)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 744, __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":732
 *         return _indexing._ndarray_nonzero(self)
 * 
 *     cpdef ndarray compress(self, condition, axis=None, out=None):             # <<<<<<<<<<<<<<
 *         """Returns selected slices of this array along 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.compress", __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_53compress(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_52compress[] = "ndarray.compress(self, condition, axis=None, out=None) -> ndarray\nReturns selected slices of this array along given axis.\n\n        .. warning::\n\n            This function may synchronize the device.\n\n        .. seealso::\n           :func:`cupy.compress` for full documentation,\n           :meth:`numpy.ndarray.compress`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_53compress(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_condition = 0;
  PyObject *__pyx_v_axis = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compress (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_condition,&__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_condition)) != 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, "compress") < 0)) __PYX_ERR(0, 732, __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_condition = values[0];
    __pyx_v_axis = values[1];
    __pyx_v_out = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("compress", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 732, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.compress", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_52compress(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_condition, __pyx_v_axis, __pyx_v_out);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_52compress(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_condition, 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_compress __pyx_t_2;
  __Pyx_RefNannySetupContext("compress", 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->compress(__pyx_v_self, __pyx_v_condition, 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.compress", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":746
 *         return _indexing._ndarray_compress(self, condition, axis, out)
 * 
 *     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_55diagonal(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;
  __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, 746, __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_55diagonal)) {
      __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, 746, __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, 746, __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, 746, __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, 746, __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, 746, __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":754
 * 
 *         """
 *         return _indexing._ndarray_diagonal(self, offset, axis1, axis2)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_18_routines_indexing__ndarray_diagonal(__pyx_v_self, __pyx_v_offset, __pyx_v_axis1, __pyx_v_axis2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 754, __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":746
 *         return _indexing._ndarray_compress(self, condition, axis, out)
 * 
 *     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_55diagonal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_54diagonal[] = "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_55diagonal(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, 746, __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, 746, __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_54diagonal(((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_54diagonal(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, 746, __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":759
 *     # Calculation
 *     # -------------------------------------------------------------------------
 *     cpdef ndarray max(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the maximum along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_57max(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_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_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, 759, __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_57max)) {
      __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, 759, __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, 759, __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, 759, __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, 759, __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, 759, __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":767
 * 
 *         """
 *         return _statistics._ndarray_max(self, axis, out, None, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray argmax(self, axis=None, out=None, dtype=None,
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_20_routines_statistics__ndarray_max(__pyx_v_self, __pyx_v_axis, __pyx_v_out, Py_None, __pyx_v_keepdims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 767, __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":759
 *     # Calculation
 *     # -------------------------------------------------------------------------
 *     cpdef ndarray max(self, axis=None, out=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_57max(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_56max[] = "ndarray.max(self, axis=None, out=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_57max(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("max (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, "max") < 0)) __PYX_ERR(0, 759, __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("max", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 759, __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_56max(((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_56max(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_max __pyx_t_2;
  __Pyx_RefNannySetupContext("max", 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->max(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 759, __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":769
 *         return _statistics._ndarray_max(self, axis, out, None, 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_59argmax(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":770
 * 
 *     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":769
 *         return _statistics._ndarray_max(self, axis, out, None, 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, 769, __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_59argmax)) {
      __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, 769, __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, 769, __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, 769, __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, 769, __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, 769, __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":786
 * 
 *         """
 *         return _statistics._ndarray_argmax(self, axis, out, dtype, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray min(self, axis=None, out=None, keepdims=False):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_20_routines_statistics__ndarray_argmax(__pyx_v_self, __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 786, __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":769
 *         return _statistics._ndarray_max(self, axis, out, None, 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_59argmax(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_58argmax[] = "ndarray.argmax(self, axis=None, out=None, dtype=None, keepdims=False) -> ndarray\nReturns the indices of the maximum along a given axis.\n\n        .. note::\n           ``dtype`` and ``keepdim`` arguments are specific to CuPy. They are\n           not in NumPy.\n\n        .. note::\n           ``axis`` argument accepts a tuple of ints, but this is specific to\n           CuPy. NumPy does not support it.\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_59argmax(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":770
 * 
 *     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, 769, __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, 769, __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_58argmax(((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":769
 *         return _statistics._ndarray_max(self, axis, out, None, 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_58argmax(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, 769, __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":788
 *         return _statistics._ndarray_argmax(self, axis, out, dtype, keepdims)
 * 
 *     cpdef ndarray min(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns the minimum along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_61min(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_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_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, 788, __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_61min)) {
      __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, 788, __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, 788, __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, 788, __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, 788, __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, 788, __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":796
 * 
 *         """
 *         return _statistics._ndarray_min(self, axis, out, None, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray argmin(self, axis=None, out=None, dtype=None,
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_20_routines_statistics__ndarray_min(__pyx_v_self, __pyx_v_axis, __pyx_v_out, Py_None, __pyx_v_keepdims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 796, __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":788
 *         return _statistics._ndarray_argmax(self, axis, out, dtype, keepdims)
 * 
 *     cpdef ndarray min(self, axis=None, out=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_61min(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_60min[] = "ndarray.min(self, axis=None, out=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_61min(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("min (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, "min") < 0)) __PYX_ERR(0, 788, __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("min", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 788, __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_60min(((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_60min(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_min __pyx_t_2;
  __Pyx_RefNannySetupContext("min", 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->min(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 788, __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":798
 *         return _statistics._ndarray_min(self, axis, out, None, 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_63argmin(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":799
 * 
 *     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":798
 *         return _statistics._ndarray_min(self, axis, out, None, 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, 798, __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_63argmin)) {
      __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, 798, __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, 798, __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, 798, __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, 798, __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, 798, __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":815
 * 
 *         """
 *         return _statistics._ndarray_argmin(self, axis, out, dtype, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray ptp(self, axis=None, out=None, keepdims=False):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_20_routines_statistics__ndarray_argmin(__pyx_v_self, __pyx_v_axis, __pyx_v_out, __pyx_v_dtype, __pyx_v_keepdims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 815, __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":798
 *         return _statistics._ndarray_min(self, axis, out, None, 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_63argmin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_62argmin[] = "ndarray.argmin(self, axis=None, out=None, dtype=None, keepdims=False) -> ndarray\nReturns the indices of the minimum along a given axis.\n\n        .. note::\n           ``dtype`` and ``keepdim`` arguments are specific to CuPy. They are\n           not in NumPy.\n\n        .. note::\n           ``axis`` argument accepts a tuple of ints, but this is specific to\n           CuPy. NumPy does not support it.\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_63argmin(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":799
 * 
 *     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, 798, __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, 798, __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_62argmin(((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":798
 *         return _statistics._ndarray_min(self, axis, out, None, 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_62argmin(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, 798, __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":817
 *         return _statistics._ndarray_argmin(self, axis, out, dtype, keepdims)
 * 
 *     cpdef ndarray ptp(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns (maximum - minimum) along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_65ptp(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_ptp(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_ptp *__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("ptp", 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_ptp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 817, __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_65ptp)) {
      __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, 817, __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, 817, __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, 817, __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, 817, __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, 817, __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":825
 * 
 *         """
 *         return _statistics._ndarray_ptp(self, axis, out, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray clip(self, a_min=None, a_max=None, out=None):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_20_routines_statistics__ndarray_ptp(__pyx_v_self, __pyx_v_axis, __pyx_v_out, __pyx_v_keepdims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 825, __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":817
 *         return _statistics._ndarray_argmin(self, axis, out, dtype, keepdims)
 * 
 *     cpdef ndarray ptp(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         """Returns (maximum - 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.ptp", __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_65ptp(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_64ptp[] = "ndarray.ptp(self, axis=None, out=None, keepdims=False) -> ndarray\nReturns (maximum - minimum) along a given axis.\n\n        .. seealso::\n           :func:`cupy.ptp` for full documentation,\n           :meth:`numpy.ndarray.ptp`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_65ptp(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("ptp (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, "ptp") < 0)) __PYX_ERR(0, 817, __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("ptp", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 817, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.ptp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_64ptp(((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_64ptp(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_ptp __pyx_t_2;
  __Pyx_RefNannySetupContext("ptp", 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->ptp(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 817, __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.ptp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":827
 *         return _statistics._ndarray_ptp(self, axis, out, keepdims)
 * 
 *     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_67clip(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;
  __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;
        }
      }
    }
  }
  /* 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, 827, __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_67clip)) {
      __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, 827, __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, 827, __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, 827, __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, 827, __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, 827, __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":835
 * 
 *         """
 *         return _math._ndarray_clip(self, a_min, a_max, out)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray round(self, decimals=0, out=None):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_14_routines_math__ndarray_clip(__pyx_v_self, __pyx_v_a_min, __pyx_v_a_max, __pyx_v_out)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 835, __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":827
 *         return _statistics._ndarray_ptp(self, axis, out, keepdims)
 * 
 *     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_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_67clip(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_66clip[] = "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_67clip(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, 827, __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, 827, __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_66clip(((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_66clip(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, 827, __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":837
 *         return _math._ndarray_clip(self, a_min, a_max, out)
 * 
 *     cpdef ndarray round(self, decimals=0, out=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with values rounded to the given number of decimals.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_69round(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_round(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_round *__pyx_optional_args) {
  PyObject *__pyx_v_decimals = ((PyObject *)__pyx_int_0);
  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;
  __Pyx_RefNannySetupContext("round", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_decimals = __pyx_optional_args->decimals;
      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_round); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 837, __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_69round)) {
      __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[3] = {__pyx_t_4, __pyx_v_decimals, __pyx_v_out};
        __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, 837, __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_decimals, __pyx_v_out};
        __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, 837, __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, 837, __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_decimals);
        __Pyx_GIVEREF(__pyx_v_decimals);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_decimals);
        __Pyx_INCREF(__pyx_v_out);
        __Pyx_GIVEREF(__pyx_v_out);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__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, 837, __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, 837, __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":845
 * 
 *         """
 *         return _round_ufunc(self, decimals, out=out)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray trace(self, offset=0, axis1=0, axis2=1, dtype=None,
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_round_ufunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 845, __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_decimals);
  __Pyx_GIVEREF(__pyx_v_decimals);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_decimals);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out, __pyx_v_out) < 0) __PYX_ERR(0, 845, __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, 845, __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, 845, __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":837
 *         return _math._ndarray_clip(self, a_min, a_max, out)
 * 
 *     cpdef ndarray round(self, decimals=0, out=None):             # <<<<<<<<<<<<<<
 *         """Returns an array with values rounded to the given number of decimals.
 * 
 */

  /* 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.round", __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_69round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_68round[] = "ndarray.round(self, decimals=0, out=None) -> ndarray\nReturns an array with values rounded to the given number of decimals.\n\n        .. seealso::\n           :func:`cupy.around` for full documentation,\n           :meth:`numpy.ndarray.round`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_69round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_decimals = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("round (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_decimals,&__pyx_n_s_out,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)__pyx_int_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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_decimals);
          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--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "round") < 0)) __PYX_ERR(0, 837, __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);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_decimals = values[0];
    __pyx_v_out = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("round", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 837, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.round", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_68round(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_decimals, __pyx_v_out);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_68round(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_decimals, PyObject *__pyx_v_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_round __pyx_t_2;
  __Pyx_RefNannySetupContext("round", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.decimals = __pyx_v_decimals;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->round(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 837, __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.round", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":847
 *         return _round_ufunc(self, decimals, out=out)
 * 
 *     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_71trace(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":848
 * 
 *     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":847
 *         return _round_ufunc(self, decimals, out=out)
 * 
 *     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, 847, __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_71trace)) {
      __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, 847, __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, 847, __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, 847, __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, 847, __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, 847, __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":856
 * 
 *         """
 *         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, 856, __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":857
 *         """
 *         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, 857, __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":847
 *         return _round_ufunc(self, decimals, out=out)
 * 
 *     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_71trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_70trace[] = "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_71trace(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":848
 * 
 *     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, 847, __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, 847, __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_70trace(((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":847
 *         return _round_ufunc(self, decimals, out=out)
 * 
 *     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_70trace(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, 847, __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":859
 *         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_73sum(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;
  __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, 859, __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_73sum)) {
      __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, 859, __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, 859, __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, 859, __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, 859, __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, 859, __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":867
 * 
 *         """
 *         return _math._ndarray_sum(self, axis, dtype, out, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray cumsum(self, axis=None, dtype=None, out=None):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_14_routines_math__ndarray_sum(__pyx_v_self, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 867, __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":859
 *         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_73sum(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_72sum[] = "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_73sum(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, 859, __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, 859, __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_72sum(((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_72sum(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, 859, __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":869
 *         return _math._ndarray_sum(self, axis, dtype, out, keepdims)
 * 
 *     cpdef ndarray cumsum(self, axis=None, dtype=None, out=None):             # <<<<<<<<<<<<<<
 *         """Returns the cumulative sum of an array along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_75cumsum(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_cumsum(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_cumsum *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((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;
  __Pyx_RefNannySetupContext("cumsum", 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;
        }
      }
    }
  }
  /* 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_cumsum); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 869, __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_75cumsum)) {
      __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_dtype, __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, 869, __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_dtype, __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, 869, __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, 869, __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_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 869, __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, 869, __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":877
 * 
 *         """
 *         return _math._ndarray_cumsum(self, axis, dtype, out)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray mean(self, axis=None, dtype=None, out=None, keepdims=False):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_14_routines_math__ndarray_cumsum(__pyx_v_self, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 877, __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":869
 *         return _math._ndarray_sum(self, axis, dtype, out, keepdims)
 * 
 *     cpdef ndarray cumsum(self, axis=None, dtype=None, out=None):             # <<<<<<<<<<<<<<
 *         """Returns the cumulative sum of an array 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.cumsum", __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_75cumsum(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_74cumsum[] = "ndarray.cumsum(self, axis=None, dtype=None, out=None) -> ndarray\nReturns the cumulative sum of an array along a given axis.\n\n        .. seealso::\n           :func:`cupy.cumsum` for full documentation,\n           :meth:`numpy.ndarray.cumsum`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_75cumsum(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_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cumsum (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_dtype,&__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_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--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cumsum") < 0)) __PYX_ERR(0, 869, __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_dtype = values[1];
    __pyx_v_out = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("cumsum", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 869, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.cumsum", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_74cumsum(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_74cumsum(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, 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_cumsum __pyx_t_2;
  __Pyx_RefNannySetupContext("cumsum", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->cumsum(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 869, __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.cumsum", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":879
 *         return _math._ndarray_cumsum(self, axis, dtype, out)
 * 
 *     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_77mean(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, 879, __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_77mean)) {
      __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, 879, __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, 879, __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, 879, __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, 879, __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, 879, __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":887
 * 
 *         """
 *         return _statistics._ndarray_mean(self, axis, dtype, out, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray var(self, axis=None, dtype=None, out=None, ddof=0,
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_20_routines_statistics__ndarray_mean(__pyx_v_self, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 887, __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":879
 *         return _math._ndarray_cumsum(self, axis, dtype, out)
 * 
 *     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_77mean(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_76mean[] = "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_77mean(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, 879, __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, 879, __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_76mean(((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_76mean(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, 879, __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":889
 *         return _statistics._ndarray_mean(self, axis, dtype, out, 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_79var(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":890
 * 
 *     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;
  __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":889
 *         return _statistics._ndarray_mean(self, axis, dtype, out, 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, 889, __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_79var)) {
      __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, 889, __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, 889, __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, 889, __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, 889, __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, 889, __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":898
 * 
 *         """
 *         return _statistics._ndarray_var(             # <<<<<<<<<<<<<<
 *             self, axis, dtype, out, ddof, keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":899
 *         """
 *         return _statistics._ndarray_var(
 *             self, axis, dtype, out, ddof, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray std(self, axis=None, dtype=None, out=None, ddof=0,
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_20_routines_statistics__ndarray_var(__pyx_v_self, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 898, __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":889
 *         return _statistics._ndarray_mean(self, axis, dtype, out, 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_79var(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_78var[] = "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_79var(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":890
 * 
 *     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, 889, __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, 889, __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_78var(((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":889
 *         return _statistics._ndarray_mean(self, axis, dtype, out, 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_78var(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, 889, __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":901
 *             self, axis, dtype, out, ddof, 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_81std(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":902
 * 
 *     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;
  __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":901
 *             self, axis, dtype, out, ddof, 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, 901, __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_81std)) {
      __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, 901, __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, 901, __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, 901, __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, 901, __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, 901, __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":910
 * 
 *         """
 *         return _statistics._ndarray_std(self, axis, dtype, out, ddof, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray prod(self, axis=None, dtype=None, out=None, keepdims=None):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_20_routines_statistics__ndarray_std(__pyx_v_self, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_ddof, __pyx_v_keepdims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 910, __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":901
 *             self, axis, dtype, out, ddof, 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_81std(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_80std[] = "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_81std(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":902
 * 
 *     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, 901, __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, 901, __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_80std(((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":901
 *             self, axis, dtype, out, ddof, 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_80std(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, 901, __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":912
 *         return _statistics._ndarray_std(self, axis, dtype, out, ddof, 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_83prod(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;
  __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, 912, __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_83prod)) {
      __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, 912, __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, 912, __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, 912, __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, 912, __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, 912, __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":920
 * 
 *         """
 *         return _math._ndarray_prod(self, axis, dtype, out, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray cumprod(self, axis=None, dtype=None, out=None):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_14_routines_math__ndarray_prod(__pyx_v_self, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out, __pyx_v_keepdims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 920, __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":912
 *         return _statistics._ndarray_std(self, axis, dtype, out, ddof, 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_83prod(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_82prod[] = "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_83prod(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, 912, __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, 912, __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_82prod(((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_82prod(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, 912, __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":922
 *         return _math._ndarray_prod(self, axis, dtype, out, keepdims)
 * 
 *     cpdef ndarray cumprod(self, axis=None, dtype=None, out=None):             # <<<<<<<<<<<<<<
 *         """Returns the cumulative product of an array along a given axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_85cumprod(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_cumprod(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_cumprod *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_dtype = ((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;
  __Pyx_RefNannySetupContext("cumprod", 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;
        }
      }
    }
  }
  /* 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_cumprod); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 922, __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_85cumprod)) {
      __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_dtype, __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, 922, __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_dtype, __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, 922, __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, 922, __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_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 922, __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, 922, __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":930
 * 
 *         """
 *         return _math._ndarray_cumprod(self, axis, dtype, out)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray all(self, axis=None, out=None, keepdims=False):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_14_routines_math__ndarray_cumprod(__pyx_v_self, __pyx_v_axis, __pyx_v_dtype, __pyx_v_out)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 930, __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":922
 *         return _math._ndarray_prod(self, axis, dtype, out, keepdims)
 * 
 *     cpdef ndarray cumprod(self, axis=None, dtype=None, out=None):             # <<<<<<<<<<<<<<
 *         """Returns the cumulative product of an array 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.cumprod", __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_85cumprod(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_84cumprod[] = "ndarray.cumprod(self, axis=None, dtype=None, out=None) -> ndarray\nReturns the cumulative product of an array along a given axis.\n\n        .. seealso::\n           :func:`cupy.cumprod` for full documentation,\n           :meth:`numpy.ndarray.cumprod`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_85cumprod(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_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cumprod (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axis,&__pyx_n_s_dtype,&__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_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--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cumprod") < 0)) __PYX_ERR(0, 922, __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_dtype = values[1];
    __pyx_v_out = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("cumprod", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 922, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.cumprod", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_84cumprod(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_axis, __pyx_v_dtype, __pyx_v_out);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_84cumprod(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis, 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_cumprod __pyx_t_2;
  __Pyx_RefNannySetupContext("cumprod", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.axis = __pyx_v_axis;
  __pyx_t_2.dtype = __pyx_v_dtype;
  __pyx_t_2.out = __pyx_v_out;
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cupy_4core_4core_ndarray->cumprod(__pyx_v_self, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 922, __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.cumprod", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":932
 *         return _math._ndarray_cumprod(self, axis, dtype, out)
 * 
 *     cpdef ndarray all(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         # TODO(niboshi): Write docstring
 *         return _logic._ndarray_all(self, axis, out, keepdims)
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_87all(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, 932, __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_87all)) {
      __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, 932, __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, 932, __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, 932, __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, 932, __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, 932, __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":934
 *     cpdef ndarray all(self, axis=None, out=None, keepdims=False):
 *         # TODO(niboshi): Write docstring
 *         return _logic._ndarray_all(self, axis, out, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray any(self, axis=None, out=None, keepdims=False):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_15_routines_logic__ndarray_all(__pyx_v_self, __pyx_v_axis, __pyx_v_out, __pyx_v_keepdims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 934, __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":932
 *         return _math._ndarray_cumprod(self, axis, dtype, out)
 * 
 *     cpdef ndarray all(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         # TODO(niboshi): Write docstring
 *         return _logic._ndarray_all(self, axis, out, 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_87all(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_86all[] = "ndarray.all(self, axis=None, out=None, keepdims=False) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_87all(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, 932, __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, 932, __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_86all(((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_86all(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, 932, __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":936
 *         return _logic._ndarray_all(self, axis, out, keepdims)
 * 
 *     cpdef ndarray any(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         # TODO(niboshi): Write docstring
 *         return _logic._ndarray_any(self, axis, out, keepdims)
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_89any(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, 936, __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_89any)) {
      __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, 936, __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, 936, __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, 936, __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, 936, __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, 936, __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":938
 *     cpdef ndarray any(self, axis=None, out=None, keepdims=False):
 *         # TODO(niboshi): Write docstring
 *         return _logic._ndarray_any(self, axis, out, keepdims)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_15_routines_logic__ndarray_any(__pyx_v_self, __pyx_v_axis, __pyx_v_out, __pyx_v_keepdims)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 938, __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":936
 *         return _logic._ndarray_all(self, axis, out, keepdims)
 * 
 *     cpdef ndarray any(self, axis=None, out=None, keepdims=False):             # <<<<<<<<<<<<<<
 *         # TODO(niboshi): Write docstring
 *         return _logic._ndarray_any(self, axis, out, 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_89any(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_88any[] = "ndarray.any(self, axis=None, out=None, keepdims=False) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_89any(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, 936, __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, 936, __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_88any(((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_88any(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, 936, __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":945
 *     # Comparison operators:
 * 
 *     def __richcmp__(object self, object other, int op):             # <<<<<<<<<<<<<<
 *         if isinstance(other, numpy.ndarray) and other.ndim == 0:
 *             other = other.item()  # Workaround for numpy<1.13
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_91__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_91__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_90__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_90__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;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__richcmp__", 0);
  __Pyx_INCREF(__pyx_v_other);

  /* "cupy/core/core.pyx":946
 * 
 *     def __richcmp__(object self, object other, int op):
 *         if isinstance(other, numpy.ndarray) and other.ndim == 0:             # <<<<<<<<<<<<<<
 *             other = other.item()  # Workaround for numpy<1.13
 *         if op == 0:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 946, __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, 946, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = PyObject_IsInstance(__pyx_v_other, __pyx_t_3); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 946, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 946, __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, 946, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 946, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_1 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":947
 *     def __richcmp__(object self, object other, int op):
 *         if isinstance(other, numpy.ndarray) and other.ndim == 0:
 *             other = other.item()  # Workaround for numpy<1.13             # <<<<<<<<<<<<<<
 *         if op == 0:
 *             return less(self, other)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_item); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 947, __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_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 947, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 947, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_other, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":946
 * 
 *     def __richcmp__(object self, object other, int op):
 *         if isinstance(other, numpy.ndarray) and other.ndim == 0:             # <<<<<<<<<<<<<<
 *             other = other.item()  # Workaround for numpy<1.13
 *         if op == 0:
 */
  }

  /* "cupy/core/core.pyx":948
 *         if isinstance(other, numpy.ndarray) and other.ndim == 0:
 *             other = other.item()  # Workaround for numpy<1.13
 *         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":949
 *             other = other.item()  # Workaround for numpy<1.13
 *         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, 949, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __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[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_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 949, __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_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 949, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 949, __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(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 949, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 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":948
 *         if isinstance(other, numpy.ndarray) and other.ndim == 0:
 *             other = other.item()  # Workaround for numpy<1.13
 *         if op == 0:             # <<<<<<<<<<<<<<
 *             return less(self, other)
 *         if op == 1:
 */
  }

  /* "cupy/core/core.pyx":950
 *         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":951
 *             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, 951, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_8);
        __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_8, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 951, __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_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 951, __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_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 951, __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(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 951, __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":950
 *         if op == 0:
 *             return less(self, other)
 *         if op == 1:             # <<<<<<<<<<<<<<
 *             return less_equal(self, other)
 *         if op == 2:
 */
  }

  /* "cupy/core/core.pyx":952
 *         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":953
 *             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, 953, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __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[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_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 953, __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_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 953, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 953, __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(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 953, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 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":952
 *         if op == 1:
 *             return less_equal(self, other)
 *         if op == 2:             # <<<<<<<<<<<<<<
 *             return equal(self, other)
 *         if op == 3:
 */
  }

  /* "cupy/core/core.pyx":954
 *         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":955
 *             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, 955, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_8);
        __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_8, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 955, __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_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 955, __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_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 955, __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(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 955, __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":954
 *         if op == 2:
 *             return equal(self, other)
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             return not_equal(self, other)
 *         if op == 4:
 */
  }

  /* "cupy/core/core.pyx":956
 *         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":957
 *             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, 957, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __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[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_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 957, __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_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 957, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 957, __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(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 957, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 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":956
 *         if op == 3:
 *             return not_equal(self, other)
 *         if op == 4:             # <<<<<<<<<<<<<<
 *             return greater(self, other)
 *         if op == 5:
 */
  }

  /* "cupy/core/core.pyx":958
 *         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":959
 *             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, 959, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_8);
        __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_8, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 959, __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_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_self), __pyx_v_other};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 959, __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_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 959, __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(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_v_other);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 959, __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":958
 *         if op == 4:
 *             return greater(self, other)
 *         if op == 5:             # <<<<<<<<<<<<<<
 *             return greater_equal(self, other)
 *         return NotImplemented
 */
  }

  /* "cupy/core/core.pyx":960
 *         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":945
 *     # Comparison operators:
 * 
 *     def __richcmp__(object self, object other, int op):             # <<<<<<<<<<<<<<
 *         if isinstance(other, numpy.ndarray) and other.ndim == 0:
 *             other = other.item()  # Workaround for numpy<1.13
 */

  /* 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_8);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_other);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":964
 *     # 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_93__nonzero__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_93__nonzero__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__nonzero__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_92__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_92__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":965
 * 
 *     def __nonzero__(self):
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return False
 *         elif self.size == 1:
 */
  switch (__pyx_v_self->size) {
    case 0:

    /* "cupy/core/core.pyx":966
 *     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":965
 * 
 *     def __nonzero__(self):
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return False
 *         elif self.size == 1:
 */
    break;

    /* "cupy/core/core.pyx":967
 *         if self.size == 0:
 *             return False
 *         elif self.size == 1:             # <<<<<<<<<<<<<<
 *             return bool(self.get())
 *         else:
 */
    case 1:

    /* "cupy/core/core.pyx":968
 *             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, 968, __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, 968, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = (!(!__pyx_t_2));
    goto __pyx_L0;

    /* "cupy/core/core.pyx":967
 *         if self.size == 0:
 *             return False
 *         elif self.size == 1:             # <<<<<<<<<<<<<<
 *             return bool(self.get())
 *         else:
 */
    break;
    default:

    /* "cupy/core/core.pyx":970
 *             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_u_The_truth_value_of_an_array_with);
    __pyx_v_msg = __pyx_kp_u_The_truth_value_of_an_array_with;

    /* "cupy/core/core.pyx":972
 *             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, 972, __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, 972, __pyx_L1_error)
    break;
  }

  /* "cupy/core/core.pyx":964
 *     # 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":976
 *     # Unary operations:
 * 
 *     def __neg__(self):             # <<<<<<<<<<<<<<
 *         return _math._negative(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_95__neg__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_95__neg__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__neg__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_94__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_94__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":977
 * 
 *     def __neg__(self):
 *         return _math._negative(self)             # <<<<<<<<<<<<<<
 * 
 *     def __pos__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__negative);
  __pyx_t_2 = __pyx_v_4cupy_4core_14_routines_math__negative; __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, 977, __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, 977, __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, 977, __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, 977, __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, 977, __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":976
 *     # Unary operations:
 * 
 *     def __neg__(self):             # <<<<<<<<<<<<<<
 *         return _math._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":979
 *         return _math._negative(self)
 * 
 *     def __pos__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_97__pos__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_97__pos__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pos__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_96__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_96__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":980
 * 
 *     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":979
 *         return _math._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":982
 *         return self
 * 
 *     def __abs__(self):             # <<<<<<<<<<<<<<
 *         return _math._absolute(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_99__abs__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_99__abs__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__abs__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_98__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_98__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":983
 * 
 *     def __abs__(self):
 *         return _math._absolute(self)             # <<<<<<<<<<<<<<
 * 
 *     def __invert__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__absolute);
  __pyx_t_2 = __pyx_v_4cupy_4core_14_routines_math__absolute; __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, 983, __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, 983, __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, 983, __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, 983, __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, 983, __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":982
 *         return self
 * 
 *     def __abs__(self):             # <<<<<<<<<<<<<<
 *         return _math._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":985
 *         return _math._absolute(self)
 * 
 *     def __invert__(self):             # <<<<<<<<<<<<<<
 *         return invert(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_101__invert__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_101__invert__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__invert__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_100__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_100__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":986
 * 
 *     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, 986, __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, 986, __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, 986, __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, 986, __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, 986, __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, 986, __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":985
 *         return _math._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":990
 *     # 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_103__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_103__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_102__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_102__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":991
 * 
 *     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, 991, __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, 991, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":992
 *     def __add__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__radd__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return _math._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, 992, __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, 992, __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, 992, __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, 992, __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, 992, __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, 992, __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":991
 * 
 *     def __add__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__radd__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":994
 *             return y.__radd__(x)
 *         else:
 *             return _math._add(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __sub__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__add);
    __pyx_t_3 = __pyx_v_4cupy_4core_14_routines_math__add; __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, 994, __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, 994, __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, 994, __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, 994, __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":990
 *     # 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":996
 *             return _math._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_105__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_105__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_104__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_104__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":997
 * 
 *     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, 997, __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, 997, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":998
 *     def __sub__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rsub__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return _math._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, 998, __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, 998, __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, 998, __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, 998, __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, 998, __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, 998, __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":997
 * 
 *     def __sub__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rsub__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1000
 *             return y.__rsub__(x)
 *         else:
 *             return _math._subtract(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __mul__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__subtract);
    __pyx_t_3 = __pyx_v_4cupy_4core_14_routines_math__subtract; __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, 1000, __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, 1000, __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, 1000, __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, 1000, __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":996
 *             return _math._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":1002
 *             return _math._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_107__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_107__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_106__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_106__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":1003
 * 
 *     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, 1003, __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, 1003, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1004
 *     def __mul__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rmul__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return _math._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, 1004, __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, 1004, __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, 1004, __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, 1004, __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, 1004, __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, 1004, __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":1003
 * 
 *     def __mul__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmul__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1006
 *             return y.__rmul__(x)
 *         else:
 *             return _math._multiply(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __matmul__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__multiply);
    __pyx_t_3 = __pyx_v_4cupy_4core_14_routines_math__multiply; __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, 1006, __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, 1006, __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, 1006, __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, 1006, __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":1002
 *             return _math._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":1008
 *             return _math._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_109__matmul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_109__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_108__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_108__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":1009
 * 
 *     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, 1009, __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, 1009, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1010
 *     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, 1010, __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, 1010, __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, 1010, __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, 1010, __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, 1010, __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, 1010, __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":1009
 * 
 *     def __matmul__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmatmul__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1012
 *             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, 1012, __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, 1012, __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, 1012, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1008
 *             return _math._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":1014
 *             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_111__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_111__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_110__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_110__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":1015
 * 
 *     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, 1015, __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, 1015, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1016
 *     def __div__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rdiv__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return _math._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, 1016, __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, 1016, __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, 1016, __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, 1016, __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, 1016, __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, 1016, __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":1015
 * 
 *     def __div__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rdiv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1018
 *             return y.__rdiv__(x)
 *         else:
 *             return _math._divide(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __truediv__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__divide);
    __pyx_t_3 = __pyx_v_4cupy_4core_14_routines_math__divide; __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, 1018, __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, 1018, __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, 1018, __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, 1018, __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":1014
 *             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":1020
 *             return _math._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_113__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_113__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_112__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_112__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":1021
 * 
 *     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, 1021, __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, 1021, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1022
 *     def __truediv__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rtruediv__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return _math._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, 1022, __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, 1022, __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, 1022, __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, 1022, __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, 1022, __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, 1022, __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":1021
 * 
 *     def __truediv__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rtruediv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1024
 *             return y.__rtruediv__(x)
 *         else:
 *             return _math._true_divide(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __floordiv__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__true_divide);
    __pyx_t_3 = __pyx_v_4cupy_4core_14_routines_math__true_divide; __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, 1024, __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, 1024, __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, 1024, __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, 1024, __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":1020
 *             return _math._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":1026
 *             return _math._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_115__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_115__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_114__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_114__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":1027
 * 
 *     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, 1027, __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, 1027, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1028
 *     def __floordiv__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rfloordiv__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return _math._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, 1028, __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, 1028, __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, 1028, __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, 1028, __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, 1028, __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, 1028, __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":1027
 * 
 *     def __floordiv__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rfloordiv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1030
 *             return y.__rfloordiv__(x)
 *         else:
 *             return _math._floor_divide(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __mod__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__floor_divide);
    __pyx_t_3 = __pyx_v_4cupy_4core_14_routines_math__floor_divide; __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, 1030, __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, 1030, __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, 1030, __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, 1030, __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":1026
 *             return _math._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":1032
 *             return _math._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_117__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_117__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_116__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_116__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":1033
 * 
 *     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, 1033, __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, 1033, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1034
 *     def __mod__(x, y):
 *         if _should_use_rop(x, y):
 *             return y.__rmod__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return _math._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, 1034, __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, 1034, __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, 1034, __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, 1034, __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, 1034, __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, 1034, __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":1033
 * 
 *     def __mod__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmod__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1036
 *             return y.__rmod__(x)
 *         else:
 *             return _math._remainder(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __divmod__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__remainder);
    __pyx_t_3 = __pyx_v_4cupy_4core_14_routines_math__remainder; __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, 1036, __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, 1036, __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, 1036, __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, 1036, __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":1032
 *             return _math._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":1038
 *             return _math._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_119__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_119__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_118__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_118__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":1039
 * 
 *     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, 1039, __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, 1039, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1040
 *     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, 1040, __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, 1040, __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, 1040, __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, 1040, __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, 1040, __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, 1040, __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":1039
 * 
 *     def __divmod__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rdivmod__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1042
 *             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, 1042, __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, 1042, __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, 1042, __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, 1042, __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, 1042, __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":1038
 *             return _math._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":1044
 *             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_121__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_modulo); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_121__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_120__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_120__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":1046
 *     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, 1046, __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, 1046, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1047
 *         # Note that we ignore the modulo argument as well as NumPy.
 *         if _should_use_rop(x, y):
 *             return y.__rpow__(x)             # <<<<<<<<<<<<<<
 *         else:
 *             return _math._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, 1047, __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, 1047, __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, 1047, __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, 1047, __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, 1047, __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, 1047, __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":1046
 *     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":1049
 *             return y.__rpow__(x)
 *         else:
 *             return _math._power(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __lshift__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__power);
    __pyx_t_3 = __pyx_v_4cupy_4core_14_routines_math__power; __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, 1049, __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, 1049, __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, 1049, __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, 1049, __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":1044
 *             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":1051
 *             return _math._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_123__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_123__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_122__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_122__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":1052
 * 
 *     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, 1052, __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, 1052, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1053
 *     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, 1053, __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, 1053, __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, 1053, __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, 1053, __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, 1053, __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, 1053, __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":1052
 * 
 *     def __lshift__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rlshift__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1055
 *             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, 1055, __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, 1055, __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, 1055, __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, 1055, __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, 1055, __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":1051
 *             return _math._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":1057
 *             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_125__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_125__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_124__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_124__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":1058
 * 
 *     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, 1058, __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, 1058, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1059
 *     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, 1059, __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, 1059, __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, 1059, __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, 1059, __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, 1059, __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, 1059, __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":1058
 * 
 *     def __rshift__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rrshift__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1061
 *             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, 1061, __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, 1061, __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, 1061, __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, 1061, __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, 1061, __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":1057
 *             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":1063
 *             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_127__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_127__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_126__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_126__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":1064
 * 
 *     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, 1064, __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, 1064, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1065
 *     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, 1065, __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, 1065, __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, 1065, __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, 1065, __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, 1065, __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, 1065, __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":1064
 * 
 *     def __and__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rand__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1067
 *             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, 1067, __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, 1067, __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, 1067, __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, 1067, __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, 1067, __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":1063
 *             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":1069
 *             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_129__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_129__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_128__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_128__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":1070
 * 
 *     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, 1070, __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, 1070, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1071
 *     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, 1071, __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, 1071, __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, 1071, __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, 1071, __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, 1071, __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, 1071, __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":1070
 * 
 *     def __or__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__ror__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1073
 *             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, 1073, __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, 1073, __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, 1073, __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, 1073, __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, 1073, __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":1069
 *             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":1075
 *             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_131__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_131__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_130__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_130__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":1076
 * 
 *     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, 1076, __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, 1076, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1077
 *     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, 1077, __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, 1077, __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, 1077, __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, 1077, __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, 1077, __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, 1077, __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":1076
 * 
 *     def __xor__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rxor__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1079
 *             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, 1079, __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, 1079, __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, 1079, __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, 1079, __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, 1079, __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":1075
 *             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":1083
 *     # Arithmetic, in-place:
 * 
 *     def __iadd__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._add(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_133__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_133__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_132__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_132__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":1084
 * 
 *     def __iadd__(self, other):
 *         return _math._add(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __isub__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__add);
  __pyx_t_2 = __pyx_v_4cupy_4core_14_routines_math__add; __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, 1084, __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, 1084, __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, 1084, __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, 1084, __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":1083
 *     # Arithmetic, in-place:
 * 
 *     def __iadd__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._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":1086
 *         return _math._add(self, other, self)
 * 
 *     def __isub__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._subtract(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_135__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_135__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_134__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_134__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":1087
 * 
 *     def __isub__(self, other):
 *         return _math._subtract(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __imul__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__subtract);
  __pyx_t_2 = __pyx_v_4cupy_4core_14_routines_math__subtract; __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, 1087, __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, 1087, __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, 1087, __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, 1087, __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":1086
 *         return _math._add(self, other, self)
 * 
 *     def __isub__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._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":1089
 *         return _math._subtract(self, other, self)
 * 
 *     def __imul__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._multiply(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_137__imul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_137__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_136__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_136__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":1090
 * 
 *     def __imul__(self, other):
 *         return _math._multiply(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __idiv__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__multiply);
  __pyx_t_2 = __pyx_v_4cupy_4core_14_routines_math__multiply; __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, 1090, __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, 1090, __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, 1090, __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, 1090, __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":1089
 *         return _math._subtract(self, other, self)
 * 
 *     def __imul__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._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":1092
 *         return _math._multiply(self, other, self)
 * 
 *     def __idiv__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._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_139__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_139__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_138__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_138__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":1093
 * 
 *     def __idiv__(self, other):
 *         return _math._divide(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __itruediv__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__divide);
  __pyx_t_2 = __pyx_v_4cupy_4core_14_routines_math__divide; __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, 1093, __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, 1093, __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, 1093, __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, 1093, __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":1092
 *         return _math._multiply(self, other, self)
 * 
 *     def __idiv__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._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":1095
 *         return _math._divide(self, other, self)
 * 
 *     def __itruediv__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._true_divide(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_141__itruediv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_141__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_140__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_140__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":1096
 * 
 *     def __itruediv__(self, other):
 *         return _math._true_divide(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __ifloordiv__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__true_divide);
  __pyx_t_2 = __pyx_v_4cupy_4core_14_routines_math__true_divide; __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, 1096, __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, 1096, __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, 1096, __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, 1096, __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":1095
 *         return _math._divide(self, other, self)
 * 
 *     def __itruediv__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._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":1098
 *         return _math._true_divide(self, other, self)
 * 
 *     def __ifloordiv__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._floor_divide(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_143__ifloordiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_143__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_142__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_142__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":1099
 * 
 *     def __ifloordiv__(self, other):
 *         return _math._floor_divide(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __imod__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__floor_divide);
  __pyx_t_2 = __pyx_v_4cupy_4core_14_routines_math__floor_divide; __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, 1099, __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, 1099, __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, 1099, __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, 1099, __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":1098
 *         return _math._true_divide(self, other, self)
 * 
 *     def __ifloordiv__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._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":1101
 *         return _math._floor_divide(self, other, self)
 * 
 *     def __imod__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._remainder(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_145__imod__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_145__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_144__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_144__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":1102
 * 
 *     def __imod__(self, other):
 *         return _math._remainder(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __ipow__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__remainder);
  __pyx_t_2 = __pyx_v_4cupy_4core_14_routines_math__remainder; __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, 1102, __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, 1102, __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, 1102, __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, 1102, __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":1101
 *         return _math._floor_divide(self, other, self)
 * 
 *     def __imod__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._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":1104
 *         return _math._remainder(self, other, self)
 * 
 *     def __ipow__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._power(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_147__ipow__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_147__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_146__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_146__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":1105
 * 
 *     def __ipow__(self, other):
 *         return _math._power(self, other, self)             # <<<<<<<<<<<<<<
 * 
 *     def __ilshift__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_4cupy_4core_14_routines_math__power);
  __pyx_t_2 = __pyx_v_4cupy_4core_14_routines_math__power; __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, 1105, __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, 1105, __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, 1105, __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, 1105, __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":1104
 *         return _math._remainder(self, other, self)
 * 
 *     def __ipow__(self, other):             # <<<<<<<<<<<<<<
 *         return _math._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":1107
 *         return _math._power(self, other, self)
 * 
 *     def __ilshift__(self, other):             # <<<<<<<<<<<<<<
 *         return left_shift(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_149__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_149__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_148__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_148__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":1108
 * 
 *     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, 1108, __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, 1108, __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, 1108, __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, 1108, __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, 1108, __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":1107
 *         return _math._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":1110
 *         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_151__irshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_151__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_150__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_150__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":1111
 * 
 *     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, 1111, __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, 1111, __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, 1111, __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, 1111, __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, 1111, __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":1110
 *         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":1113
 *         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_153__iand__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_153__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_152__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_152__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":1114
 * 
 *     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, 1114, __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, 1114, __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, 1114, __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, 1114, __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, 1114, __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":1113
 *         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":1116
 *         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_155__ior__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_155__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_154__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_154__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":1117
 * 
 *     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, 1117, __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, 1117, __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, 1117, __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, 1117, __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, 1117, __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":1116
 *         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":1119
 *         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_157__ixor__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_157__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_156__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_156__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":1120
 * 
 *     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, 1120, __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, 1120, __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, 1120, __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, 1120, __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, 1120, __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":1119
 *         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":1122
 *         return bitwise_xor(self, other, self)
 * 
 *     cpdef ndarray conj(self):             # <<<<<<<<<<<<<<
 *         return _math._ndarray_conj(self)
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_159conj(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;
  __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, 1122, __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_159conj)) {
      __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, 1122, __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, 1122, __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, 1122, __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
 * 
 *     cpdef ndarray conj(self):
 *         return _math._ndarray_conj(self)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ndarray conjugate(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_14_routines_math__ndarray_conj(__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1123, __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":1122
 *         return bitwise_xor(self, other, self)
 * 
 *     cpdef ndarray conj(self):             # <<<<<<<<<<<<<<
 *         return _math._ndarray_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_159conj(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_158conj[] = "ndarray.conj(self) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_159conj(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_158conj(((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_158conj(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, 1122, __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":1125
 *         return _math._ndarray_conj(self)
 * 
 *     cpdef ndarray conjugate(self):             # <<<<<<<<<<<<<<
 *         return _math._ndarray_conj(self)
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_161conjugate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core_7ndarray_conjugate(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;
  __Pyx_RefNannySetupContext("conjugate", 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_conjugate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1125, __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_161conjugate)) {
      __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, 1125, __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, 1125, __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, 1125, __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":1126
 * 
 *     cpdef ndarray conjugate(self):
 *         return _math._ndarray_conj(self)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_14_routines_math__ndarray_conj(__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1126, __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":1125
 *         return _math._ndarray_conj(self)
 * 
 *     cpdef ndarray conjugate(self):             # <<<<<<<<<<<<<<
 *         return _math._ndarray_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.conjugate", __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_161conjugate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_160conjugate[] = "ndarray.conjugate(self) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_161conjugate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("conjugate (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_160conjugate(((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_160conjugate(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("conjugate", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core_7ndarray_conjugate(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1125, __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.conjugate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1129
 * 
 *     @property
 *     def real(self):             # <<<<<<<<<<<<<<
 *         return _math._ndarray_real_getter(self)
 * 
 */

/* 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) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":1130
 *     @property
 *     def real(self):
 *         return _math._ndarray_real_getter(self)             # <<<<<<<<<<<<<<
 * 
 *     @real.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_14_routines_math__ndarray_real_getter(__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1129
 * 
 *     @property
 *     def real(self):             # <<<<<<<<<<<<<<
 *         return _math._ndarray_real_getter(self)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.real.__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":1133
 * 
 *     @real.setter
 *     def real(self, value):             # <<<<<<<<<<<<<<
 *         _math._ndarray_real_setter(self, value)
 * 
 */

/* 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;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "cupy/core/core.pyx":1134
 *     @real.setter
 *     def real(self, value):
 *         _math._ndarray_real_setter(self, value)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_14_routines_math__ndarray_real_setter(__pyx_v_self, __pyx_v_value)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1133
 * 
 *     @real.setter
 *     def real(self, value):             # <<<<<<<<<<<<<<
 *         _math._ndarray_real_setter(self, value)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __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":1137
 * 
 *     @property
 *     def imag(self):             # <<<<<<<<<<<<<<
 *         return _math._ndarray_imag_getter(self)
 * 
 */

/* 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) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":1138
 *     @property
 *     def imag(self):
 *         return _math._ndarray_imag_getter(self)             # <<<<<<<<<<<<<<
 * 
 *     @imag.setter
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_14_routines_math__ndarray_imag_getter(__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1137
 * 
 *     @property
 *     def imag(self):             # <<<<<<<<<<<<<<
 *         return _math._ndarray_imag_getter(self)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.imag.__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":1141
 * 
 *     @imag.setter
 *     def imag(self, value):             # <<<<<<<<<<<<<<
 *         _math._ndarray_imag_setter(self, value)
 * 
 */

/* 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;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "cupy/core/core.pyx":1142
 *     @imag.setter
 *     def imag(self, value):
 *         _math._ndarray_imag_setter(self, value)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_14_routines_math__ndarray_imag_setter(__pyx_v_self, __pyx_v_value)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1141
 * 
 *     @imag.setter
 *     def imag(self, value):             # <<<<<<<<<<<<<<
 *         _math._ndarray_imag_setter(self, value)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __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":1149
 *     # For standard library functions:
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         return self.copy()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_163__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_162__copy__[] = "ndarray.__copy__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_163__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_162__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_162__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":1150
 * 
 *     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, 1150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1149
 *     # 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":1152
 *         return self.copy()
 * 
 *     def __deepcopy__(self, memo):             # <<<<<<<<<<<<<<
 *         with self.device:
 *             return self.copy()
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_165__deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_164__deepcopy__[] = "ndarray.__deepcopy__(self, memo)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_165__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_164__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_164__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;
  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;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  __Pyx_RefNannySetupContext("__deepcopy__", 0);

  /* "cupy/core/core.pyx":1153
 * 
 *     def __deepcopy__(self, memo):
 *         with self.device:             # <<<<<<<<<<<<<<
 *             return self.copy()
 * 
 */
  /*with:*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1153, __pyx_L3_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_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1153, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1153, __pyx_L3_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __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;
    /*try:*/ {
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_6);
        __Pyx_XGOTREF(__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_8);
        /*try:*/ {

          /* "cupy/core/core.pyx":1154
 *     def __deepcopy__(self, memo):
 *         with self.device:
 *             return self.copy()             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self):
 */
          __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, 1154, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_r = __pyx_t_1;
          __pyx_t_1 = 0;
          goto __pyx_L11_try_return;

          /* "cupy/core/core.pyx":1153
 * 
 *     def __deepcopy__(self, memo):
 *         with self.device:             # <<<<<<<<<<<<<<
 *             return self.copy()
 * 
 */
        }
        __pyx_L7_error:;
        __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;
        __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_3, &__pyx_t_4) < 0) __PYX_ERR(0, 1153, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_5 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1153, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1153, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (__pyx_t_10 < 0) __PYX_ERR(0, 1153, __pyx_L9_except_error)
          __pyx_t_11 = ((!(__pyx_t_10 != 0)) != 0);
          if (__pyx_t_11) {
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_3);
            __Pyx_XGIVEREF(__pyx_t_4);
            __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_3, __pyx_t_4);
            __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0; 
            __PYX_ERR(0, 1153, __pyx_L9_except_error)
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          goto __pyx_L8_exception_handled;
        }
        __pyx_L9_except_error:;
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
        goto __pyx_L1_error;
        __pyx_L11_try_return:;
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
        goto __pyx_L4_return;
        __pyx_L8_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_2) {
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__14, NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1153, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
        goto __pyx_L6;
      }
      __pyx_L4_return: {
        __pyx_t_8 = __pyx_r;
        __pyx_r = 0;
        if (__pyx_t_2) {
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__15, NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1153, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        }
        __pyx_r = __pyx_t_8;
        __pyx_t_8 = 0;
        goto __pyx_L0;
      }
      __pyx_L6:;
    }
    goto __pyx_L16;
    __pyx_L3_error:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L1_error;
    __pyx_L16:;
  }

  /* "cupy/core/core.pyx":1152
 *         return self.copy()
 * 
 *     def __deepcopy__(self, memo):             # <<<<<<<<<<<<<<
 *         with self.device:
 *             return self.copy()
 */

  /* 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_4);
  __Pyx_XDECREF(__pyx_t_5);
  __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":1156
 *             return self.copy()
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return array, (self.get(),)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_167__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_166__reduce__[] = "ndarray.__reduce__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_167__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_166__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_166__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":1157
 * 
 *     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, 1157, __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, 1157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1157, __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, 1157, __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":1156
 *             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":1163
 *     # 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_169__array__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_168__array__[] = "ndarray.__array__(self, dtype=None)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_169__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, 1163, __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, 1163, __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_168__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_168__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":1164
 * 
 *     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, 1164, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1164, __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":1165
 *     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":1164
 * 
 *     def __array__(self, dtype=None):
 *         if dtype is None or self.dtype == dtype:             # <<<<<<<<<<<<<<
 *             return self
 *         else:
 */
  }

  /* "cupy/core/core.pyx":1167
 *             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, 1167, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1163
 *     # 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":1173
 *     # Container customization:
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         if self._shape.size() == 0:
 *             raise TypeError('iteration over a 0-d array')
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_171__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_171__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_170__iter__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4cupy_4core_4core_7ndarray_8__iter___2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "cupy/core/core.pyx":1176
 *         if self._shape.size() == 0:
 *             raise TypeError('iteration over a 0-d array')
 *         return (self[i] for i in range(self._shape[0]))             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_8__iter___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(0, 1176, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__ *) __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_7ndarray_8__iter___2generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_iter___locals_genexpr, __pyx_n_s_cupy_core_core); if (unlikely(!gen)) __PYX_ERR(0, 1176, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.__iter__.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_7ndarray_8__iter___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;
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = 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(0, 1176, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1176, __pyx_L1_error) }
  __pyx_t_1 = (__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->_shape[0]);
  __pyx_t_2 = __pyx_t_1;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_3;
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1176, __pyx_L1_error) }
    __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1176, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __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_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __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(0, 1176, __pyx_L1_error)
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __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/core.pyx":1173
 *     # Container customization:
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         if self._shape.size() == 0:
 *             raise TypeError('iteration over a 0-d array')
 */

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_170__iter__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__ *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__iter__", 0);
  __pyx_cur_scope = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__ *)__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct____iter__(__pyx_ptype_4cupy_4core_4core___pyx_scope_struct____iter__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1173, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "cupy/core/core.pyx":1174
 * 
 *     def __iter__(self):
 *         if self._shape.size() == 0:             # <<<<<<<<<<<<<<
 *             raise TypeError('iteration over a 0-d array')
 *         return (self[i] for i in range(self._shape[0]))
 */
  __pyx_t_1 = ((__pyx_cur_scope->__pyx_v_self->_shape.size() == 0) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cupy/core/core.pyx":1175
 *     def __iter__(self):
 *         if self._shape.size() == 0:
 *             raise TypeError('iteration over a 0-d array')             # <<<<<<<<<<<<<<
 *         return (self[i] for i in range(self._shape[0]))
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1175, __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, 1175, __pyx_L1_error)

    /* "cupy/core/core.pyx":1174
 * 
 *     def __iter__(self):
 *         if self._shape.size() == 0:             # <<<<<<<<<<<<<<
 *             raise TypeError('iteration over a 0-d array')
 *         return (self[i] for i in range(self._shape[0]))
 */
  }

  /* "cupy/core/core.pyx":1176
 *         if self._shape.size() == 0:
 *             raise TypeError('iteration over a 0-d array')
 *         return (self[i] for i in range(self._shape[0]))             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_pf_4cupy_4core_4core_7ndarray_8__iter___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1176, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1173
 *     # Container customization:
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         if self._shape.size() == 0:
 *             raise TypeError('iteration over a 0-d array')
 */

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

/* "cupy/core/core.pyx":1178
 *         return (self[i] for i in range(self._shape[0]))
 * 
 *     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_173__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_4cupy_4core_4core_7ndarray_173__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_172__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_172__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":1179
 * 
 *     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":1180
 *     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__17, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1180, __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, 1180, __pyx_L1_error)

    /* "cupy/core/core.pyx":1179
 * 
 *     def __len__(self):
 *         if self._shape.size() == 0:             # <<<<<<<<<<<<<<
 *             raise TypeError('len() of unsized object')
 *         return self._shape[0]
 */
  }

  /* "cupy/core/core.pyx":1181
 *         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":1178
 *         return (self[i] for i in range(self._shape[0]))
 * 
 *     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":1183
 *         return self._shape[0]
 * 
 *     def __getitem__(self, slices):             # <<<<<<<<<<<<<<
 *         """x.__getitem__(y) <==> x[y]
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_175__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_slices); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_174__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_174__getitem__;
#endif
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_175__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_174__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_174__getitem__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "cupy/core/core.pyx":1205
 * 
 *         """
 *         return _indexing._ndarray_getitem(self, slices)             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, slices, value):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_18_routines_indexing__ndarray_getitem(__pyx_v_self, __pyx_v_slices)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/core/core.pyx":1207
 *         return _indexing._ndarray_getitem(self, slices)
 * 
 *     def __setitem__(self, slices, value):             # <<<<<<<<<<<<<<
 *         """x.__setitem__(slices, y) <==> x[slices] = y
 * 
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_177__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_176__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_176__setitem__;
#endif
static int __pyx_pw_4cupy_4core_4core_7ndarray_177__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_176__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_176__setitem__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value) {
  PyObject *__pyx_v_ptr = NULL;
  PyObject *__pyx_v_order = NULL;
  PyObject *__pyx_v_tmp = NULL;
  intptr_t __pyx_v_stream_ptr;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __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;
  size_t __pyx_t_9;
  __Pyx_RefNannySetupContext("__setitem__", 0);

  /* "cupy/core/core.pyx":1255
 * 
 *         """
 *         if util.ENABLE_SLICE_COPY and (             # <<<<<<<<<<<<<<
 *                 type(slices) is slice
 *                 and slices == slice(None, None, None)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ENABLE_SLICE_COPY); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __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(0, 1255, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }

  /* "cupy/core/core.pyx":1256
 *         """
 *         if util.ENABLE_SLICE_COPY and (
 *                 type(slices) is slice             # <<<<<<<<<<<<<<
 *                 and slices == slice(None, None, None)
 *                 and isinstance(value, numpy.ndarray)
 */
  __pyx_t_4 = (((PyObject *)Py_TYPE(__pyx_v_slices)) == ((PyObject *)(&PySlice_Type)));
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }

  /* "cupy/core/core.pyx":1257
 *         if util.ENABLE_SLICE_COPY and (
 *                 type(slices) is slice
 *                 and slices == slice(None, None, None)             # <<<<<<<<<<<<<<
 *                 and isinstance(value, numpy.ndarray)
 *         ):
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_slices, __pyx_slice__18, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1257, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1257, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }

  /* "cupy/core/core.pyx":1258
 *                 type(slices) is slice
 *                 and slices == slice(None, None, None)
 *                 and isinstance(value, numpy.ndarray)             # <<<<<<<<<<<<<<
 *         ):
 *             if self.dtype == value.dtype and self.shape == value.shape:
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1258, __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, 1258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = PyObject_IsInstance(__pyx_v_value, __pyx_t_2); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1258, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = (__pyx_t_5 != 0);
  __pyx_t_1 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;

  /* "cupy/core/core.pyx":1255
 * 
 *         """
 *         if util.ENABLE_SLICE_COPY and (             # <<<<<<<<<<<<<<
 *                 type(slices) is slice
 *                 and slices == slice(None, None, None)
 */
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1260
 *                 and isinstance(value, numpy.ndarray)
 *         ):
 *             if self.dtype == value.dtype and self.shape == value.shape:             # <<<<<<<<<<<<<<
 *                 if self.strides == value.strides:
 *                     ptr = ctypes.c_void_p(value.__array_interface__['data'][0])
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1260, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_self->dtype, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1260, __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(0, 1260, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_4) {
    } else {
      __pyx_t_1 = __pyx_t_4;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1260, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1260, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1260, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1260, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_1 = __pyx_t_4;
    __pyx_L9_bool_binop_done:;
    if (likely(__pyx_t_1)) {

      /* "cupy/core/core.pyx":1261
 *         ):
 *             if self.dtype == value.dtype and self.shape == value.shape:
 *                 if self.strides == value.strides:             # <<<<<<<<<<<<<<
 *                     ptr = ctypes.c_void_p(value.__array_interface__['data'][0])
 *                 else:
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_strides); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1261, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_strides); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1261, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_6, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1261, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1261, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":1262
 *             if self.dtype == value.dtype and self.shape == value.shape:
 *                 if self.strides == value.strides:
 *                     ptr = ctypes.c_void_p(value.__array_interface__['data'][0])             # <<<<<<<<<<<<<<
 *                 else:
 *                     order = 'F' if self.flags.f_contiguous else 'C'
 */
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1262, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_c_void_p); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1262, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_array_interface); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1262, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_7 = __Pyx_PyObject_Dict_GetItem(__pyx_t_2, __pyx_n_u_data); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1262, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_7, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1262, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = NULL;
        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);
          }
        }
        if (!__pyx_t_7) {
          __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1262, __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_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_2};
            __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1262, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 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_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_2};
            __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1262, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          } else
          #endif
          {
            __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1262, __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_2);
            PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_2);
            __pyx_t_2 = 0;
            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1262, __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_ptr = __pyx_t_3;
        __pyx_t_3 = 0;

        /* "cupy/core/core.pyx":1261
 *         ):
 *             if self.dtype == value.dtype and self.shape == value.shape:
 *                 if self.strides == value.strides:             # <<<<<<<<<<<<<<
 *                     ptr = ctypes.c_void_p(value.__array_interface__['data'][0])
 *                 else:
 */
        goto __pyx_L11;
      }

      /* "cupy/core/core.pyx":1264
 *                     ptr = ctypes.c_void_p(value.__array_interface__['data'][0])
 *                 else:
 *                     order = 'F' if self.flags.f_contiguous else 'C'             # <<<<<<<<<<<<<<
 *                     tmp = value.ravel(order)
 *                     ptr = ctypes.c_void_p(tmp.__array_interface__['data'][0])
 */
      /*else*/ {
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_flags); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1264, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_f_contiguous); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1264, __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, 1264, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (__pyx_t_1) {
          __Pyx_INCREF(__pyx_n_u_F);
          __pyx_t_3 = __pyx_n_u_F;
        } else {
          __Pyx_INCREF(__pyx_n_u_C);
          __pyx_t_3 = __pyx_n_u_C;
        }
        __pyx_v_order = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;

        /* "cupy/core/core.pyx":1265
 *                 else:
 *                     order = 'F' if self.flags.f_contiguous else 'C'
 *                     tmp = value.ravel(order)             # <<<<<<<<<<<<<<
 *                     ptr = ctypes.c_void_p(tmp.__array_interface__['data'][0])
 *                 stream_ptr = stream_module.get_current_stream_ptr()
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_ravel); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1265, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_order); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1265, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_8)) {
            PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_order};
            __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1265, __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_8)) {
            PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_order};
            __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1265, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_GOTREF(__pyx_t_3);
          } else
          #endif
          {
            __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1265, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); __pyx_t_6 = NULL;
            __Pyx_INCREF(__pyx_v_order);
            __Pyx_GIVEREF(__pyx_v_order);
            PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_order);
            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1265, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_v_tmp = __pyx_t_3;
        __pyx_t_3 = 0;

        /* "cupy/core/core.pyx":1266
 *                     order = 'F' if self.flags.f_contiguous else 'C'
 *                     tmp = value.ravel(order)
 *                     ptr = ctypes.c_void_p(tmp.__array_interface__['data'][0])             # <<<<<<<<<<<<<<
 *                 stream_ptr = stream_module.get_current_stream_ptr()
 *                 if stream_ptr == 0:
 */
        __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1266, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_c_void_p); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1266, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_tmp, __pyx_n_s_array_interface); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1266, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_8, __pyx_n_u_data); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1266, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_6, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1266, __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 && 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);
          }
        }
        if (!__pyx_t_6) {
          __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1266, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_2)) {
            PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_8};
            __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1266, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
            PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_8};
            __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1266, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          } else
          #endif
          {
            __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1266, __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_8);
            PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_8);
            __pyx_t_8 = 0;
            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1266, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_v_ptr = __pyx_t_3;
        __pyx_t_3 = 0;
      }
      __pyx_L11:;

      /* "cupy/core/core.pyx":1267
 *                     tmp = value.ravel(order)
 *                     ptr = ctypes.c_void_p(tmp.__array_interface__['data'][0])
 *                 stream_ptr = stream_module.get_current_stream_ptr()             # <<<<<<<<<<<<<<
 *                 if stream_ptr == 0:
 *                     self.data.copy_from_host(ptr, self.nbytes)
 */
      __pyx_v_stream_ptr = __pyx_f_4cupy_4cuda_6stream_get_current_stream_ptr();

      /* "cupy/core/core.pyx":1268
 *                     ptr = ctypes.c_void_p(tmp.__array_interface__['data'][0])
 *                 stream_ptr = stream_module.get_current_stream_ptr()
 *                 if stream_ptr == 0:             # <<<<<<<<<<<<<<
 *                     self.data.copy_from_host(ptr, self.nbytes)
 *                 else:
 */
      __pyx_t_1 = ((__pyx_v_stream_ptr == 0) != 0);
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":1269
 *                 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_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1269, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1269, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = ((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_9, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1269, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "cupy/core/core.pyx":1268
 *                     ptr = ctypes.c_void_p(tmp.__array_interface__['data'][0])
 *                 stream_ptr = stream_module.get_current_stream_ptr()
 *                 if stream_ptr == 0:             # <<<<<<<<<<<<<<
 *                     self.data.copy_from_host(ptr, self.nbytes)
 *                 else:
 */
        goto __pyx_L12;
      }

      /* "cupy/core/core.pyx":1271
 *                     self.data.copy_from_host(ptr, self.nbytes)
 *                 else:
 *                     self.data.copy_from_host_async(ptr, self.nbytes)             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError(
 */
      /*else*/ {
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1271, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1271, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = ((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_9, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1271, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __pyx_L12:;

      /* "cupy/core/core.pyx":1260
 *                 and isinstance(value, numpy.ndarray)
 *         ):
 *             if self.dtype == value.dtype and self.shape == value.shape:             # <<<<<<<<<<<<<<
 *                 if self.strides == value.strides:
 *                     ptr = ctypes.c_void_p(value.__array_interface__['data'][0])
 */
      goto __pyx_L8;
    }

    /* "cupy/core/core.pyx":1273
 *                     self.data.copy_from_host_async(ptr, self.nbytes)
 *             else:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'copying a numpy.ndarray to a cupy.ndarray by empty slice '
 *                     'assignment must ensure arrays have same shape and dtype')
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1273, __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, 1273, __pyx_L1_error)
    }
    __pyx_L8:;

    /* "cupy/core/core.pyx":1255
 * 
 *         """
 *         if util.ENABLE_SLICE_COPY and (             # <<<<<<<<<<<<<<
 *                 type(slices) is slice
 *                 and slices == slice(None, None, None)
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1277
 *                     'assignment must ensure arrays have same shape and dtype')
 *         else:
 *             _indexing._ndarray_setitem(self, slices, value)             # <<<<<<<<<<<<<<
 * 
 *     def scatter_add(self, slices, value):
 */
  /*else*/ {
    __pyx_t_3 = __pyx_f_4cupy_4core_18_routines_indexing__ndarray_setitem(__pyx_v_self, __pyx_v_slices, __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1277, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1207
 *         return _indexing._ndarray_getitem(self, slices)
 * 
 *     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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ptr);
  __Pyx_XDECREF(__pyx_v_order);
  __Pyx_XDECREF(__pyx_v_tmp);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1279
 *             _indexing._ndarray_setitem(self, slices, value)
 * 
 *     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_179scatter_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_178scatter_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_179scatter_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, 1279, __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, 1279, __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, 1279, __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_178scatter_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_178scatter_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":1286
 * 
 *         """
 *         _indexing._ndarray_scatter_add(self, slices, value)             # <<<<<<<<<<<<<<
 * 
 *     def scatter_max(self, slices, value):
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_18_routines_indexing__ndarray_scatter_add(__pyx_v_self, __pyx_v_slices, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1279
 *             _indexing._ndarray_setitem(self, slices, value)
 * 
 *     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":1288
 *         _indexing._ndarray_scatter_add(self, slices, value)
 * 
 *     def scatter_max(self, slices, value):             # <<<<<<<<<<<<<<
 *         """Stores a maximum value of elements specified by indices to an array.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_181scatter_max(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_180scatter_max[] = "ndarray.scatter_max(self, slices, value)\nStores a maximum value of elements specified by indices to an array.\n\n        .. seealso::\n            :func:`cupyx.scatter_max` for full documentation.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_181scatter_max(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_max (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_max", 1, 2, 2, 1); __PYX_ERR(0, 1288, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scatter_max") < 0)) __PYX_ERR(0, 1288, __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_max", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1288, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.scatter_max", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_180scatter_max(((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_180scatter_max(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_max", 0);

  /* "cupy/core/core.pyx":1295
 * 
 *         """
 *         _indexing._ndarray_scatter_max(self, slices, value)             # <<<<<<<<<<<<<<
 * 
 *     def scatter_min(self, slices, value):
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_18_routines_indexing__ndarray_scatter_max(__pyx_v_self, __pyx_v_slices, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1288
 *         _indexing._ndarray_scatter_add(self, slices, value)
 * 
 *     def scatter_max(self, slices, value):             # <<<<<<<<<<<<<<
 *         """Stores a maximum value of elements specified by indices to 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_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":1297
 *         _indexing._ndarray_scatter_max(self, slices, value)
 * 
 *     def scatter_min(self, slices, value):             # <<<<<<<<<<<<<<
 *         """Stores a minimum value of elements specified by indices to an array.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_183scatter_min(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_182scatter_min[] = "ndarray.scatter_min(self, slices, value)\nStores a minimum value of elements specified by indices to an array.\n\n        .. seealso::\n            :func:`cupyx.scatter_min` for full documentation.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_183scatter_min(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_min (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_min", 1, 2, 2, 1); __PYX_ERR(0, 1297, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scatter_min") < 0)) __PYX_ERR(0, 1297, __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_min", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1297, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.scatter_min", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_182scatter_min(((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_182scatter_min(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_min", 0);

  /* "cupy/core/core.pyx":1304
 * 
 *         """
 *         _indexing._ndarray_scatter_min(self, slices, value)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement __getslice__
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_18_routines_indexing__ndarray_scatter_min(__pyx_v_self, __pyx_v_slices, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1297
 *         _indexing._ndarray_scatter_max(self, slices, value)
 * 
 *     def scatter_min(self, slices, value):             # <<<<<<<<<<<<<<
 *         """Stores a minimum value of elements specified by indices to 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_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":1311
 * 
 *     # numpy/ufunc compat
 *     def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):             # <<<<<<<<<<<<<<
 * 
 *         """Apply unary or binary ufunc to this array
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_185__array_ufunc__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_184__array_ufunc__[] = "ndarray.__array_ufunc__(self, ufunc, method, *inputs, **kwargs)\nApply unary or binary ufunc to this array\n\n        If binary, only allow if second argument is another cupy ndarray or\n        a number, i.e., raise ValueError instead of silently converting a\n        numpy array.\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_185__array_ufunc__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ufunc = 0;
  PyObject *__pyx_v_method = 0;
  PyObject *__pyx_v_inputs = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__array_ufunc__ (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) > 2) {
    __pyx_v_inputs = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_inputs)) {
      __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_inputs);
  } else {
    __pyx_v_inputs = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ufunc,&__pyx_n_s_method,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) {
        default:
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ufunc)) != 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_method)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__array_ufunc__", 0, 2, 2, 1); __PYX_ERR(0, 1311, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "__array_ufunc__") < 0)) __PYX_ERR(0, 1311, __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_ufunc = values[0];
    __pyx_v_method = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__array_ufunc__", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1311, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_inputs); __pyx_v_inputs = 0;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("cupy.core.core.ndarray.__array_ufunc__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_184__array_ufunc__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_ufunc, __pyx_v_method, __pyx_v_inputs, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_184__array_ufunc__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_ufunc, PyObject *__pyx_v_method, PyObject *__pyx_v_inputs, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_cupy = NULL;
  PyObject *__pyx_v_out = NULL;
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_cp_ufunc = NULL;
  PyObject *__pyx_8genexpr1__pyx_v_x = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __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;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_RefNannySetupContext("__array_ufunc__", 0);
  __Pyx_INCREF(__pyx_v_inputs);

  /* "cupy/core/core.pyx":1319
 *         numpy array.
 *         """
 *         import cupy  # top-level ufuncs             # <<<<<<<<<<<<<<
 *         if 'out' in kwargs:
 *             # need to unfold tuple argument in kwargs
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_cupy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_cupy = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1320
 *         """
 *         import cupy  # top-level ufuncs
 *         if 'out' in kwargs:             # <<<<<<<<<<<<<<
 *             # need to unfold tuple argument in kwargs
 *             out = kwargs['out']
 */
  __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_n_u_out, __pyx_v_kwargs, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1320, __pyx_L1_error)
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":1322
 *         if 'out' in kwargs:
 *             # need to unfold tuple argument in kwargs
 *             out = kwargs['out']             # <<<<<<<<<<<<<<
 *             if len(out) != 1:
 *                 raise ValueError('The \'out\' parameter must have exactly one '
 */
    __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_kwargs, __pyx_n_u_out); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1322, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_out = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1323
 *             # need to unfold tuple argument in kwargs
 *             out = kwargs['out']
 *             if len(out) != 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError('The \'out\' parameter must have exactly one '
 *                                  'array value')
 */
    __pyx_t_4 = PyObject_Length(__pyx_v_out); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1323, __pyx_L1_error)
    __pyx_t_3 = ((__pyx_t_4 != 1) != 0);
    if (unlikely(__pyx_t_3)) {

      /* "cupy/core/core.pyx":1324
 *             out = kwargs['out']
 *             if len(out) != 1:
 *                 raise ValueError('The \'out\' parameter must have exactly one '             # <<<<<<<<<<<<<<
 *                                  'array value')
 *             kwargs['out'] = out[0]
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1324, __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, 1324, __pyx_L1_error)

      /* "cupy/core/core.pyx":1323
 *             # need to unfold tuple argument in kwargs
 *             out = kwargs['out']
 *             if len(out) != 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError('The \'out\' parameter must have exactly one '
 *                                  'array value')
 */
    }

    /* "cupy/core/core.pyx":1326
 *                 raise ValueError('The \'out\' parameter must have exactly one '
 *                                  'array value')
 *             kwargs['out'] = out[0]             # <<<<<<<<<<<<<<
 * 
 *         if method == '__call__':
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_out, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_n_u_out, __pyx_t_1) < 0)) __PYX_ERR(0, 1326, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1320
 *         """
 *         import cupy  # top-level ufuncs
 *         if 'out' in kwargs:             # <<<<<<<<<<<<<<
 *             # need to unfold tuple argument in kwargs
 *             out = kwargs['out']
 */
  }

  /* "cupy/core/core.pyx":1328
 *             kwargs['out'] = out[0]
 * 
 *         if method == '__call__':             # <<<<<<<<<<<<<<
 *             if ufunc.signature is not None:
 *                 # we don't support generalised-ufuncs (gufuncs)
 */
  __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_method, __pyx_n_u_call, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1328, __pyx_L1_error)
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":1329
 * 
 *         if method == '__call__':
 *             if ufunc.signature is not None:             # <<<<<<<<<<<<<<
 *                 # we don't support generalised-ufuncs (gufuncs)
 *                 return NotImplemented
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_ufunc, __pyx_n_s_signature); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1329, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = (__pyx_t_1 != Py_None);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_2 = (__pyx_t_3 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1331
 *             if ufunc.signature is not None:
 *                 # we don't support generalised-ufuncs (gufuncs)
 *                 return NotImplemented             # <<<<<<<<<<<<<<
 *             name = ufunc.__name__
 *             try:
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_builtin_NotImplemented);
      __pyx_r = __pyx_builtin_NotImplemented;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":1329
 * 
 *         if method == '__call__':
 *             if ufunc.signature is not None:             # <<<<<<<<<<<<<<
 *                 # we don't support generalised-ufuncs (gufuncs)
 *                 return NotImplemented
 */
    }

    /* "cupy/core/core.pyx":1332
 *                 # we don't support generalised-ufuncs (gufuncs)
 *                 return NotImplemented
 *             name = ufunc.__name__             # <<<<<<<<<<<<<<
 *             try:
 *                 cp_ufunc = getattr(cupy, name)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_ufunc, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1332, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_name = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1333
 *                 return NotImplemented
 *             name = ufunc.__name__
 *             try:             # <<<<<<<<<<<<<<
 *                 cp_ufunc = getattr(cupy, name)
 *             except AttributeError:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      /*try:*/ {

        /* "cupy/core/core.pyx":1334
 *             name = ufunc.__name__
 *             try:
 *                 cp_ufunc = getattr(cupy, name)             # <<<<<<<<<<<<<<
 *             except AttributeError:
 *                 return NotImplemented
 */
        __pyx_t_1 = __Pyx_GetAttr(__pyx_v_cupy, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1334, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_v_cp_ufunc = __pyx_t_1;
        __pyx_t_1 = 0;

        /* "cupy/core/core.pyx":1333
 *                 return NotImplemented
 *             name = ufunc.__name__
 *             try:             # <<<<<<<<<<<<<<
 *                 cp_ufunc = getattr(cupy, name)
 *             except AttributeError:
 */
      }
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L12_try_end;
      __pyx_L7_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":1335
 *             try:
 *                 cp_ufunc = getattr(cupy, name)
 *             except AttributeError:             # <<<<<<<<<<<<<<
 *                 return NotImplemented
 *             if name in [
 */
      __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
      if (__pyx_t_8) {
        __Pyx_AddTraceback("cupy.core.core.ndarray.__array_ufunc__", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_9, &__pyx_t_10) < 0) __PYX_ERR(0, 1335, __pyx_L9_except_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_t_10);

        /* "cupy/core/core.pyx":1336
 *                 cp_ufunc = getattr(cupy, name)
 *             except AttributeError:
 *                 return NotImplemented             # <<<<<<<<<<<<<<
 *             if name in [
 *                     'greater', 'greater_equal', 'less', 'less_equal',
 */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_builtin_NotImplemented);
        __pyx_r = __pyx_builtin_NotImplemented;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L10_except_return;
      }
      goto __pyx_L9_except_error;
      __pyx_L9_except_error:;

      /* "cupy/core/core.pyx":1333
 *                 return NotImplemented
 *             name = ufunc.__name__
 *             try:             # <<<<<<<<<<<<<<
 *                 cp_ufunc = getattr(cupy, name)
 *             except AttributeError:
 */
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      goto __pyx_L1_error;
      __pyx_L10_except_return:;
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      goto __pyx_L0;
      __pyx_L12_try_end:;
    }

    /* "cupy/core/core.pyx":1337
 *             except AttributeError:
 *                 return NotImplemented
 *             if name in [             # <<<<<<<<<<<<<<
 *                     'greater', 'greater_equal', 'less', 'less_equal',
 *                     'equal', 'not_equal']:
 */
    __Pyx_INCREF(__pyx_v_name);
    __pyx_t_10 = __pyx_v_name;
    __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_10, __pyx_n_u_greater, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1337, __pyx_L1_error)
    if (!__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L16_bool_binop_done;
    }
    __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_10, __pyx_n_u_greater_equal, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1337, __pyx_L1_error)
    if (!__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L16_bool_binop_done;
    }
    __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_10, __pyx_n_u_less, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1337, __pyx_L1_error)
    if (!__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L16_bool_binop_done;
    }
    __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_10, __pyx_n_u_less_equal, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1337, __pyx_L1_error)
    if (!__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L16_bool_binop_done;
    }
    __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_10, __pyx_n_u_equal, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1337, __pyx_L1_error)
    if (!__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L16_bool_binop_done;
    }
    __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_10, __pyx_n_u_not_equal, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1337, __pyx_L1_error)
    __pyx_t_2 = __pyx_t_3;
    __pyx_L16_bool_binop_done:;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_3 = (__pyx_t_2 != 0);
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":1341
 *                     'equal', 'not_equal']:
 *                 # workaround for numpy/numpy#12142
 *                 inputs = tuple([             # <<<<<<<<<<<<<<
 *                     x.item()
 *                     if isinstance(x, numpy.ndarray) and x.ndim == 0
 */
      { /* enter inner scope */
        __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1341, __pyx_L24_error)
        __Pyx_GOTREF(__pyx_t_10);

        /* "cupy/core/core.pyx":1345
 *                     if isinstance(x, numpy.ndarray) and x.ndim == 0
 *                     else x
 *                     for x in inputs             # <<<<<<<<<<<<<<
 *                 ])
 *             return cp_ufunc(*inputs, **kwargs)
 */
        __pyx_t_9 = __pyx_v_inputs; __Pyx_INCREF(__pyx_t_9); __pyx_t_4 = 0;
        for (;;) {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 1345, __pyx_L24_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_9, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1345, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
          __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_x, __pyx_t_1);
          __pyx_t_1 = 0;

          /* "cupy/core/core.pyx":1343
 *                 inputs = tuple([
 *                     x.item()
 *                     if isinstance(x, numpy.ndarray) and x.ndim == 0             # <<<<<<<<<<<<<<
 *                     else x
 *                     for x in inputs
 */
          __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1343, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1343, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_2 = PyObject_IsInstance(__pyx_8genexpr1__pyx_v_x, __pyx_t_12); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1343, __pyx_L24_error)
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_13 = (__pyx_t_2 != 0);
          if (__pyx_t_13) {
          } else {
            __pyx_t_3 = __pyx_t_13;
            goto __pyx_L27_bool_binop_done;
          }
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr1__pyx_v_x, __pyx_n_s_ndim); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1343, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_11 = __Pyx_PyInt_EqObjC(__pyx_t_12, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1343, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 1343, __pyx_L24_error)
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_3 = __pyx_t_13;
          __pyx_L27_bool_binop_done:;
          if (__pyx_t_3) {

            /* "cupy/core/core.pyx":1342
 *                 # workaround for numpy/numpy#12142
 *                 inputs = tuple([
 *                     x.item()             # <<<<<<<<<<<<<<
 *                     if isinstance(x, numpy.ndarray) and x.ndim == 0
 *                     else x
 */
            __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr1__pyx_v_x, __pyx_n_s_item); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1342, __pyx_L24_error)
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_14 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
              __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_12);
              if (likely(__pyx_t_14)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
                __Pyx_INCREF(__pyx_t_14);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_12, function);
              }
            }
            if (__pyx_t_14) {
              __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1342, __pyx_L24_error)
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            } else {
              __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1342, __pyx_L24_error)
            }
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __pyx_t_1 = __pyx_t_11;
            __pyx_t_11 = 0;
          } else {

            /* "cupy/core/core.pyx":1344
 *                     x.item()
 *                     if isinstance(x, numpy.ndarray) and x.ndim == 0
 *                     else x             # <<<<<<<<<<<<<<
 *                     for x in inputs
 *                 ])
 */
            __Pyx_INCREF(__pyx_8genexpr1__pyx_v_x);
            __pyx_t_1 = __pyx_8genexpr1__pyx_v_x;
          }
          if (unlikely(__Pyx_ListComp_Append(__pyx_t_10, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 1341, __pyx_L24_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "cupy/core/core.pyx":1345
 *                     if isinstance(x, numpy.ndarray) and x.ndim == 0
 *                     else x
 *                     for x in inputs             # <<<<<<<<<<<<<<
 *                 ])
 *             return cp_ufunc(*inputs, **kwargs)
 */
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_x); __pyx_8genexpr1__pyx_v_x = 0;
        goto __pyx_L29_exit_scope;
        __pyx_L24_error:;
        __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_x); __pyx_8genexpr1__pyx_v_x = 0;
        goto __pyx_L1_error;
        __pyx_L29_exit_scope:;
      } /* exit inner scope */

      /* "cupy/core/core.pyx":1341
 *                     'equal', 'not_equal']:
 *                 # workaround for numpy/numpy#12142
 *                 inputs = tuple([             # <<<<<<<<<<<<<<
 *                     x.item()
 *                     if isinstance(x, numpy.ndarray) and x.ndim == 0
 */
      __pyx_t_9 = PyList_AsTuple(((PyObject*)__pyx_t_10)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1341, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF_SET(__pyx_v_inputs, ((PyObject*)__pyx_t_9));
      __pyx_t_9 = 0;

      /* "cupy/core/core.pyx":1337
 *             except AttributeError:
 *                 return NotImplemented
 *             if name in [             # <<<<<<<<<<<<<<
 *                     'greater', 'greater_equal', 'less', 'less_equal',
 *                     'equal', 'not_equal']:
 */
    }

    /* "cupy/core/core.pyx":1347
 *                     for x in inputs
 *                 ])
 *             return cp_ufunc(*inputs, **kwargs)             # <<<<<<<<<<<<<<
 *         # Don't use for now, interface uncertain
 *         # elif method =='at' and name == 'add':
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_v_cp_ufunc, __pyx_v_inputs, __pyx_v_kwargs); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1347, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_r = __pyx_t_9;
    __pyx_t_9 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1328
 *             kwargs['out'] = out[0]
 * 
 *         if method == '__call__':             # <<<<<<<<<<<<<<
 *             if ufunc.signature is not None:
 *                 # we don't support generalised-ufuncs (gufuncs)
 */
  }

  /* "cupy/core/core.pyx":1354
 *             # self.scatter_add(*inputs, **kwargs)
 *         else:
 *             return NotImplemented             # <<<<<<<<<<<<<<
 * 
 *     def __array_function__(self, func, types, args, kwargs):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":1311
 * 
 *     # numpy/ufunc compat
 *     def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):             # <<<<<<<<<<<<<<
 * 
 *         """Apply unary or binary ufunc to this array
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__array_ufunc__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_inputs);
  __Pyx_XDECREF(__pyx_v_cupy);
  __Pyx_XDECREF(__pyx_v_out);
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_cp_ufunc);
  __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_x);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1356
 *             return NotImplemented
 * 
 *     def __array_function__(self, func, types, args, kwargs):             # <<<<<<<<<<<<<<
 *         try:
 *             module = functools.reduce(
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_187__array_function__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_186__array_function__[] = "ndarray.__array_function__(self, func, types, args, kwargs)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_187__array_function__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_func = 0;
  PyObject *__pyx_v_types = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__array_function__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_func,&__pyx_n_s_types,&__pyx_n_s_args,&__pyx_n_s_kwargs,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_func)) != 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("__array_function__", 1, 4, 4, 1); __PYX_ERR(0, 1356, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__array_function__", 1, 4, 4, 2); __PYX_ERR(0, 1356, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__array_function__", 1, 4, 4, 3); __PYX_ERR(0, 1356, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__array_function__") < 0)) __PYX_ERR(0, 1356, __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_func = values[0];
    __pyx_v_types = values[1];
    __pyx_v_args = values[2];
    __pyx_v_kwargs = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__array_function__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1356, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray.__array_function__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_186__array_function__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_func, __pyx_v_types, __pyx_v_args, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_186__array_function__(CYTHON_UNUSED struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_types, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_module = NULL;
  PyObject *__pyx_v_cupy_func = NULL;
  PyObject *__pyx_v_t = 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;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  int __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  PyObject *(*__pyx_t_15)(PyObject *);
  __Pyx_RefNannySetupContext("__array_function__", 0);

  /* "cupy/core/core.pyx":1357
 * 
 *     def __array_function__(self, func, types, args, kwargs):
 *         try:             # <<<<<<<<<<<<<<
 *             module = functools.reduce(
 *                 getattr, func.__module__.split('.')[1:], cupy)
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "cupy/core/core.pyx":1358
 *     def __array_function__(self, func, types, args, kwargs):
 *         try:
 *             module = functools.reduce(             # <<<<<<<<<<<<<<
 *                 getattr, func.__module__.split('.')[1:], cupy)
 *             cupy_func = getattr(module, func.__name__)
 */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_functools); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1358, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_reduce); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1358, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/core/core.pyx":1359
 *         try:
 *             module = functools.reduce(
 *                 getattr, func.__module__.split('.')[1:], cupy)             # <<<<<<<<<<<<<<
 *             cupy_func = getattr(module, func.__name__)
 *         except AttributeError:
 */
      __pyx_t_5 = __Pyx_GetBuiltinName(__pyx_n_s_getattr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1359, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_func, __pyx_n_s_module); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1359, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_split); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1359, __pyx_L3_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__22, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1359, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_GetSlice(__pyx_t_7, 1, 0, NULL, NULL, &__pyx_slice__23, 1, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1359, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1359, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);
      __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[4] = {__pyx_t_9, __pyx_t_5, __pyx_t_8, __pyx_t_7};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1358, __pyx_L3_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __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[4] = {__pyx_t_9, __pyx_t_5, __pyx_t_8, __pyx_t_7};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1358, __pyx_L3_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1358, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_11);
        if (__pyx_t_9) {
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_7);
        __pyx_t_5 = 0;
        __pyx_t_8 = 0;
        __pyx_t_7 = 0;
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1358, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_module = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1360
 *             module = functools.reduce(
 *                 getattr, func.__module__.split('.')[1:], cupy)
 *             cupy_func = getattr(module, func.__name__)             # <<<<<<<<<<<<<<
 *         except AttributeError:
 *             return NotImplemented
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_func, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1360, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_GetAttr(__pyx_v_module, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1360, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_cupy_func = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "cupy/core/core.pyx":1357
 * 
 *     def __array_function__(self, func, types, args, kwargs):
 *         try:             # <<<<<<<<<<<<<<
 *             module = functools.reduce(
 *                 getattr, func.__module__.split('.')[1:], cupy)
 */
    }
    __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;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":1361
 *                 getattr, func.__module__.split('.')[1:], cupy)
 *             cupy_func = getattr(module, func.__name__)
 *         except AttributeError:             # <<<<<<<<<<<<<<
 *             return NotImplemented
 *         if cupy_func is func:
 */
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_t_10) {
      __Pyx_AddTraceback("cupy.core.core.ndarray.__array_function__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_4, &__pyx_t_11) < 0) __PYX_ERR(0, 1361, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_11);

      /* "cupy/core/core.pyx":1362
 *             cupy_func = getattr(module, func.__name__)
 *         except AttributeError:
 *             return NotImplemented             # <<<<<<<<<<<<<<
 *         if cupy_func is func:
 *             # avoid NumPy func
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_builtin_NotImplemented);
      __pyx_r = __pyx_builtin_NotImplemented;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "cupy/core/core.pyx":1357
 * 
 *     def __array_function__(self, func, types, args, kwargs):
 *         try:             # <<<<<<<<<<<<<<
 *             module = functools.reduce(
 *                 getattr, func.__module__.split('.')[1:], cupy)
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L8_try_end:;
  }

  /* "cupy/core/core.pyx":1363
 *         except AttributeError:
 *             return NotImplemented
 *         if cupy_func is func:             # <<<<<<<<<<<<<<
 *             # avoid NumPy func
 *             return NotImplemented
 */
  __pyx_t_12 = (__pyx_v_cupy_func == __pyx_v_func);
  __pyx_t_13 = (__pyx_t_12 != 0);
  if (__pyx_t_13) {

    /* "cupy/core/core.pyx":1365
 *         if cupy_func is func:
 *             # avoid NumPy func
 *             return NotImplemented             # <<<<<<<<<<<<<<
 *         for t in types:
 *             if t not in _HANDLED_TYPES:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1363
 *         except AttributeError:
 *             return NotImplemented
 *         if cupy_func is func:             # <<<<<<<<<<<<<<
 *             # avoid NumPy func
 *             return NotImplemented
 */
  }

  /* "cupy/core/core.pyx":1366
 *             # avoid NumPy func
 *             return NotImplemented
 *         for t in types:             # <<<<<<<<<<<<<<
 *             if t not in _HANDLED_TYPES:
 *                 return NotImplemented
 */
  if (likely(PyList_CheckExact(__pyx_v_types)) || PyTuple_CheckExact(__pyx_v_types)) {
    __pyx_t_11 = __pyx_v_types; __Pyx_INCREF(__pyx_t_11); __pyx_t_14 = 0;
    __pyx_t_15 = NULL;
  } else {
    __pyx_t_14 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_v_types); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_15 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1366, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_15)) {
      if (likely(PyList_CheckExact(__pyx_t_11))) {
        if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_11)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_14); __Pyx_INCREF(__pyx_t_4); __pyx_t_14++; if (unlikely(0 < 0)) __PYX_ERR(0, 1366, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_11, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1366, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_14 >= PyTuple_GET_SIZE(__pyx_t_11)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_14); __Pyx_INCREF(__pyx_t_4); __pyx_t_14++; if (unlikely(0 < 0)) __PYX_ERR(0, 1366, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_11, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1366, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_15(__pyx_t_11);
      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, 1366, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":1367
 *             return NotImplemented
 *         for t in types:
 *             if t not in _HANDLED_TYPES:             # <<<<<<<<<<<<<<
 *                 return NotImplemented
 *         return cupy_func(*args, **kwargs)
 */
    __pyx_t_13 = (__Pyx_PySequence_ContainsTF(__pyx_v_t, __pyx_v_4cupy_4core_4core__HANDLED_TYPES, Py_NE)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 1367, __pyx_L1_error)
    __pyx_t_12 = (__pyx_t_13 != 0);
    if (__pyx_t_12) {

      /* "cupy/core/core.pyx":1368
 *         for t in types:
 *             if t not in _HANDLED_TYPES:
 *                 return NotImplemented             # <<<<<<<<<<<<<<
 *         return cupy_func(*args, **kwargs)
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_builtin_NotImplemented);
      __pyx_r = __pyx_builtin_NotImplemented;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":1367
 *             return NotImplemented
 *         for t in types:
 *             if t not in _HANDLED_TYPES:             # <<<<<<<<<<<<<<
 *                 return NotImplemented
 *         return cupy_func(*args, **kwargs)
 */
    }

    /* "cupy/core/core.pyx":1366
 *             # avoid NumPy func
 *             return NotImplemented
 *         for t in types:             # <<<<<<<<<<<<<<
 *             if t not in _HANDLED_TYPES:
 *                 return NotImplemented
 */
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/core.pyx":1369
 *             if t not in _HANDLED_TYPES:
 *                 return NotImplemented
 *         return cupy_func(*args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     # Conversion:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_11 = __Pyx_PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1369, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  if (unlikely(__pyx_v_kwargs == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
    __PYX_ERR(0, 1369, __pyx_L1_error)
  }
  if (likely(PyDict_CheckExact(__pyx_v_kwargs))) {
    __pyx_t_4 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1369, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_4 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_kwargs, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1369, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_v_cupy_func, __pyx_t_11, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1369, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 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":1356
 *             return NotImplemented
 * 
 *     def __array_function__(self, func, types, args, kwargs):             # <<<<<<<<<<<<<<
 *         try:
 *             module = functools.reduce(
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__array_function__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_module);
  __Pyx_XDECREF(__pyx_v_cupy_func);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1373
 *     # Conversion:
 * 
 *     def __int__(self):             # <<<<<<<<<<<<<<
 *         return int(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_189__int__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_189__int__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__int__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_188__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_188__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":1374
 * 
 *     def __int__(self):
 *         return int(self.get())             # <<<<<<<<<<<<<<
 * 
 *     def __float__(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, 1374, __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, 1374, __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":1373
 *     # 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":1376
 *         return int(self.get())
 * 
 *     def __float__(self):             # <<<<<<<<<<<<<<
 *         return float(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_191__float__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_191__float__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__float__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_190__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_190__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":1377
 * 
 *     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, 1377, __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, 1377, __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":1376
 *         return int(self.get())
 * 
 *     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":1379
 *         return float(self.get())
 * 
 *     def __complex__(self):             # <<<<<<<<<<<<<<
 *         return complex(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_193__complex__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_192__complex__[] = "ndarray.__complex__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_193__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_192__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_192__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":1380
 * 
 *     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, 1380, __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, 1380, __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":1379
 *         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":1382
 *         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_195__oct__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_195__oct__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__oct__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_194__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_194__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":1383
 * 
 *     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, 1383, __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, 1383, __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":1382
 *         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":1385
 *         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_197__hex__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_197__hex__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__hex__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_196__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_196__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":1386
 * 
 *     def __hex__(self):
 *         return hex(self.get())             # <<<<<<<<<<<<<<
 * 
 *     def __bytes__(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, 1386, __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, 1386, __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":1385
 *         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":1388
 *         return hex(self.get())
 * 
 *     def __bytes__(self):             # <<<<<<<<<<<<<<
 *         return bytes(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_199__bytes__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_198__bytes__[] = "ndarray.__bytes__(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_199__bytes__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bytes__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_198__bytes__(((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_198__bytes__(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("__bytes__", 0);

  /* "cupy/core/core.pyx":1389
 * 
 *     def __bytes__(self):
 *         return bytes(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, 1389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1389, __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":1388
 *         return hex(self.get())
 * 
 *     def __bytes__(self):             # <<<<<<<<<<<<<<
 *         return bytes(self.get())
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.core.core.ndarray.__bytes__", __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
 *     # String representations:
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return repr(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_201__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_201__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_200__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_200__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":1394
 * 
 *     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, 1394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1394, __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":1393
 *     # 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":1396
 *         return repr(self.get())
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return str(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_203__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_203__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_202__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_202__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":1397
 * 
 *     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, 1397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1397, __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":1396
 *         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":1402
 *     # 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_205dot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_204dot[] = "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_205dot(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, 1402, __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, 1402, __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, 1402, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 1402, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_204dot(((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_204dot(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":1410
 * 
 *         """
 *         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, 1410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1402
 *     # 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":1416
 *     # -------------------------------------------------------------------------
 *     @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
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cupy/core/core.pyx":1418
 *     def device(self):
 *         """CUDA device on which this array resides."""
 *         return self.data.device             # <<<<<<<<<<<<<<
 * 
 *     cpdef get(self, stream=None, order='C', out=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->data), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1416
 *     # -------------------------------------------------------------------------
 *     @property
 *     def device(self):             # <<<<<<<<<<<<<<
 *         """CUDA device on which this array resides."""
 *         return self.data.device
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core.ndarray.device.__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":1420
 *         return self.data.device
 * 
 *     cpdef get(self, stream=None, order='C', out=None):             # <<<<<<<<<<<<<<
 *         """Returns a copy of the array on host memory.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_207get(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);
  PyObject *__pyx_v_order = ((PyObject *)__pyx_n_u_C);
  PyObject *__pyx_v_out = ((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;
  intptr_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;
  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;
  size_t __pyx_t_15;
  struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_to_host_async __pyx_t_16;
  __Pyx_RefNannySetupContext("get", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_stream = __pyx_optional_args->stream;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_order = __pyx_optional_args->order;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_out = __pyx_optional_args->out;
        }
      }
    }
  }
  __Pyx_INCREF(__pyx_v_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_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1420, __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_207get)) {
      __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_stream, __pyx_v_order, __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, 1420, __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_stream, __pyx_v_order, __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, 1420, __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, 1420, __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_stream);
        __Pyx_GIVEREF(__pyx_v_stream);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_stream);
        __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_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, 1420, __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":1438
 * 
 *         """
 *         if out is not None:             # <<<<<<<<<<<<<<
 *             if not isinstance(out, numpy.ndarray):
 *                 raise TypeError('Only numpy.ndarray can be obtained from'
 */
  __pyx_t_7 = (__pyx_v_out != Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1439
 *         """
 *         if out is not None:
 *             if not isinstance(out, numpy.ndarray):             # <<<<<<<<<<<<<<
 *                 raise TypeError('Only numpy.ndarray can be obtained from'
 *                                 'cupy.ndarray')
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1439, __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, 1439, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_8 = PyObject_IsInstance(__pyx_v_out, __pyx_t_2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1439, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = ((!(__pyx_t_8 != 0)) != 0);
    if (unlikely(__pyx_t_7)) {

      /* "cupy/core/core.pyx":1440
 *         if out is not None:
 *             if not isinstance(out, numpy.ndarray):
 *                 raise TypeError('Only numpy.ndarray can be obtained from'             # <<<<<<<<<<<<<<
 *                                 'cupy.ndarray')
 *             if self.dtype != out.dtype:
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1440, __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, 1440, __pyx_L1_error)

      /* "cupy/core/core.pyx":1439
 *         """
 *         if out is not None:
 *             if not isinstance(out, numpy.ndarray):             # <<<<<<<<<<<<<<
 *                 raise TypeError('Only numpy.ndarray can be obtained from'
 *                                 'cupy.ndarray')
 */
    }

    /* "cupy/core/core.pyx":1442
 *                 raise TypeError('Only numpy.ndarray can be obtained from'
 *                                 'cupy.ndarray')
 *             if self.dtype != out.dtype:             # <<<<<<<<<<<<<<
 *                 raise TypeError(
 *                     '{} array cannot be obtained from {} array'.format(
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1442, __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, 1442, __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, 1442, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(__pyx_t_7)) {

      /* "cupy/core/core.pyx":1444
 *             if self.dtype != out.dtype:
 *                 raise TypeError(
 *                     '{} array cannot be obtained from {} array'.format(             # <<<<<<<<<<<<<<
 *                         out.dtype, self.dtype))
 *             if self.shape != out.shape:
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_array_cannot_be_obtained_from_a, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1444, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);

      /* "cupy/core/core.pyx":1445
 *                 raise TypeError(
 *                     '{} array cannot be obtained from {} array'.format(
 *                         out.dtype, self.dtype))             # <<<<<<<<<<<<<<
 *             if self.shape != out.shape:
 *                 raise ValueError(
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1445, __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, 1444, __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, 1444, __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, 1444, __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, 1444, __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":1443
 *                                 'cupy.ndarray')
 *             if self.dtype != out.dtype:
 *                 raise TypeError(             # <<<<<<<<<<<<<<
 *                     '{} array cannot be obtained from {} array'.format(
 *                         out.dtype, self.dtype))
 */
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1443, __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, 1443, __pyx_L1_error)

      /* "cupy/core/core.pyx":1442
 *                 raise TypeError('Only numpy.ndarray can be obtained from'
 *                                 'cupy.ndarray')
 *             if self.dtype != out.dtype:             # <<<<<<<<<<<<<<
 *                 raise TypeError(
 *                     '{} array cannot be obtained from {} array'.format(
 */
    }

    /* "cupy/core/core.pyx":1446
 *                     '{} array cannot be obtained from {} array'.format(
 *                         out.dtype, self.dtype))
 *             if self.shape != out.shape:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'Shape mismatch. Expected shape: {}, '
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1446, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1446, __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, 1446, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1446, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__pyx_t_7)) {

      /* "cupy/core/core.pyx":1449
 *                 raise ValueError(
 *                     'Shape mismatch. Expected shape: {}, '
 *                     'actual shape: {}'.format(self.shape, out.shape))             # <<<<<<<<<<<<<<
 *             if not (out.flags.c_contiguous and self._c_contiguous or
 *                     out.flags.f_contiguous and self._f_contiguous):
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Shape_mismatch_Expected_shape_ac, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1449, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1449, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1449, __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, 1449, __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, 1449, __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, 1449, __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, 1449, __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":1447
 *                         out.dtype, self.dtype))
 *             if self.shape != out.shape:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'Shape mismatch. Expected shape: {}, '
 *                     'actual shape: {}'.format(self.shape, out.shape))
 */
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1447, __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, 1447, __pyx_L1_error)

      /* "cupy/core/core.pyx":1446
 *                     '{} array cannot be obtained from {} array'.format(
 *                         out.dtype, self.dtype))
 *             if self.shape != out.shape:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'Shape mismatch. Expected shape: {}, '
 */
    }

    /* "cupy/core/core.pyx":1450
 *                     'Shape mismatch. Expected shape: {}, '
 *                     'actual shape: {}'.format(self.shape, out.shape))
 *             if not (out.flags.c_contiguous and self._c_contiguous or             # <<<<<<<<<<<<<<
 *                     out.flags.f_contiguous and self._f_contiguous):
 *                 with self.device:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1450, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_c_contiguous); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1450, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __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, 1450, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!__pyx_t_8) {
      goto __pyx_L9_next_or;
    } else {
    }
    __pyx_t_8 = (__pyx_v_self->_c_contiguous != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_L9_next_or:;

    /* "cupy/core/core.pyx":1451
 *                     'actual shape: {}'.format(self.shape, out.shape))
 *             if not (out.flags.c_contiguous and self._c_contiguous or
 *                     out.flags.f_contiguous and self._f_contiguous):             # <<<<<<<<<<<<<<
 *                 with self.device:
 *                     if out.flags.c_contiguous:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_flags); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1451, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_f_contiguous); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1451, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1451, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_v_self->_f_contiguous != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L8_bool_binop_done:;

    /* "cupy/core/core.pyx":1450
 *                     'Shape mismatch. Expected shape: {}, '
 *                     'actual shape: {}'.format(self.shape, out.shape))
 *             if not (out.flags.c_contiguous and self._c_contiguous or             # <<<<<<<<<<<<<<
 *                     out.flags.f_contiguous and self._f_contiguous):
 *                 with self.device:
 */
    __pyx_t_8 = ((!__pyx_t_7) != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1452
 *             if not (out.flags.c_contiguous and self._c_contiguous or
 *                     out.flags.f_contiguous and self._f_contiguous):
 *                 with self.device:             # <<<<<<<<<<<<<<
 *                     if out.flags.c_contiguous:
 *                         a_gpu = _internal_ascontiguousarray(self)
 */
      /*with:*/ {
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1452, __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, 1452, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1452, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(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_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1452, __pyx_L12_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else {
          __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1452, __pyx_L12_error)
        }
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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":1453
 *                     out.flags.f_contiguous and self._f_contiguous):
 *                 with self.device:
 *                     if out.flags.c_contiguous:             # <<<<<<<<<<<<<<
 *                         a_gpu = _internal_ascontiguousarray(self)
 *                     elif out.flags.f_contiguous:
 */
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1453, __pyx_L16_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_c_contiguous); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1453, __pyx_L16_error)
              __Pyx_GOTREF(__pyx_t_4);
              __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, 1453, __pyx_L16_error)
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (__pyx_t_8) {

                /* "cupy/core/core.pyx":1454
 *                 with self.device:
 *                     if out.flags.c_contiguous:
 *                         a_gpu = _internal_ascontiguousarray(self)             # <<<<<<<<<<<<<<
 *                     elif out.flags.f_contiguous:
 *                         a_gpu = _internal_asfortranarray(self)
 */
                __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_self, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1454, __pyx_L16_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_v_a_gpu = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
                __pyx_t_4 = 0;

                /* "cupy/core/core.pyx":1453
 *                     out.flags.f_contiguous and self._f_contiguous):
 *                 with self.device:
 *                     if out.flags.c_contiguous:             # <<<<<<<<<<<<<<
 *                         a_gpu = _internal_ascontiguousarray(self)
 *                     elif out.flags.f_contiguous:
 */
                goto __pyx_L22;
              }

              /* "cupy/core/core.pyx":1455
 *                     if out.flags.c_contiguous:
 *                         a_gpu = _internal_ascontiguousarray(self)
 *                     elif out.flags.f_contiguous:             # <<<<<<<<<<<<<<
 *                         a_gpu = _internal_asfortranarray(self)
 *                     else:
 */
              __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_flags); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1455, __pyx_L16_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_f_contiguous); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1455, __pyx_L16_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1455, __pyx_L16_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (likely(__pyx_t_8)) {

                /* "cupy/core/core.pyx":1456
 *                         a_gpu = _internal_ascontiguousarray(self)
 *                     elif out.flags.f_contiguous:
 *                         a_gpu = _internal_asfortranarray(self)             # <<<<<<<<<<<<<<
 *                     else:
 *                         raise RuntimeError(
 */
                __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_asfortranarray(__pyx_v_self, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1456, __pyx_L16_error)
                __Pyx_GOTREF(__pyx_t_1);
                __pyx_v_a_gpu = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
                __pyx_t_1 = 0;

                /* "cupy/core/core.pyx":1455
 *                     if out.flags.c_contiguous:
 *                         a_gpu = _internal_ascontiguousarray(self)
 *                     elif out.flags.f_contiguous:             # <<<<<<<<<<<<<<
 *                         a_gpu = _internal_asfortranarray(self)
 *                     else:
 */
                goto __pyx_L22;
              }

              /* "cupy/core/core.pyx":1458
 *                         a_gpu = _internal_asfortranarray(self)
 *                     else:
 *                         raise RuntimeError(             # <<<<<<<<<<<<<<
 *                             '`out` cannot be specified when copying to '
 *                             'non-contiguous ndarray')
 */
              /*else*/ {
                __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1458, __pyx_L16_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, 1458, __pyx_L16_error)
              }
              __pyx_L22:;

              /* "cupy/core/core.pyx":1452
 *             if not (out.flags.c_contiguous and self._c_contiguous or
 *                     out.flags.f_contiguous and self._f_contiguous):
 *                 with self.device:             # <<<<<<<<<<<<<<
 *                     if out.flags.c_contiguous:
 *                         a_gpu = _internal_ascontiguousarray(self)
 */
            }
            __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_L21_try_end;
            __pyx_L16_error:;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("cupy.core.core.ndarray.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_9) < 0) __PYX_ERR(0, 1452, __pyx_L18_except_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_GOTREF(__pyx_t_9);
              __pyx_t_3 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1452, __pyx_L18_except_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_3, NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1452, __pyx_L18_except_error)
              __Pyx_GOTREF(__pyx_t_14);
              __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_14);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              if (__pyx_t_8 < 0) __PYX_ERR(0, 1452, __pyx_L18_except_error)
              __pyx_t_7 = ((!(__pyx_t_8 != 0)) != 0);
              if (__pyx_t_7) {
                __Pyx_GIVEREF(__pyx_t_1);
                __Pyx_GIVEREF(__pyx_t_4);
                __Pyx_XGIVEREF(__pyx_t_9);
                __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_4, __pyx_t_9);
                __pyx_t_1 = 0; __pyx_t_4 = 0; __pyx_t_9 = 0; 
                __PYX_ERR(0, 1452, __pyx_L18_except_error)
              }
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              goto __pyx_L17_exception_handled;
            }
            __pyx_L18_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_L17_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_L21_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_10) {
              __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__26, NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1452, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            }
            goto __pyx_L15;
          }
          __pyx_L15:;
        }
        goto __pyx_L26;
        __pyx_L12_error:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L1_error;
        __pyx_L26:;
      }

      /* "cupy/core/core.pyx":1450
 *                     'Shape mismatch. Expected shape: {}, '
 *                     'actual shape: {}'.format(self.shape, out.shape))
 *             if not (out.flags.c_contiguous and self._c_contiguous or             # <<<<<<<<<<<<<<
 *                     out.flags.f_contiguous and self._f_contiguous):
 *                 with self.device:
 */
      goto __pyx_L7;
    }

    /* "cupy/core/core.pyx":1462
 *                             'non-contiguous ndarray')
 *             else:
 *                 a_gpu = self             # <<<<<<<<<<<<<<
 *             a_cpu = out
 *         else:
 */
    /*else*/ {
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __pyx_v_a_gpu = __pyx_v_self;
    }
    __pyx_L7:;

    /* "cupy/core/core.pyx":1463
 *             else:
 *                 a_gpu = self
 *             a_cpu = out             # <<<<<<<<<<<<<<
 *         else:
 *             if self.size == 0:
 */
    __Pyx_INCREF(__pyx_v_out);
    __pyx_v_a_cpu = __pyx_v_out;

    /* "cupy/core/core.pyx":1438
 * 
 *         """
 *         if out is not None:             # <<<<<<<<<<<<<<
 *             if not isinstance(out, numpy.ndarray):
 *                 raise TypeError('Only numpy.ndarray can be obtained from'
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1465
 *             a_cpu = out
 *         else:
 *             if self.size == 0:             # <<<<<<<<<<<<<<
 *                 return numpy.ndarray(self._shape, dtype=self.dtype)
 * 
 */
  /*else*/ {
    __pyx_t_7 = ((__pyx_v_self->size == 0) != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":1466
 *         else:
 *             if self.size == 0:
 *                 return numpy.ndarray(self._shape, dtype=self.dtype)             # <<<<<<<<<<<<<<
 * 
 *             order = order.upper()
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_shape); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_dtype, __pyx_v_self->dtype) < 0) __PYX_ERR(0, 1466, __pyx_L1_error)
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1466, __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;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":1465
 *             a_cpu = out
 *         else:
 *             if self.size == 0:             # <<<<<<<<<<<<<<
 *                 return numpy.ndarray(self._shape, dtype=self.dtype)
 * 
 */
    }

    /* "cupy/core/core.pyx":1468
 *                 return numpy.ndarray(self._shape, dtype=self.dtype)
 * 
 *             order = order.upper()             # <<<<<<<<<<<<<<
 *             if order == 'A':
 *                 if self._f_contiguous:
 */
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_order, __pyx_n_s_upper); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1468, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1468, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1468, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF_SET(__pyx_v_order, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1469
 * 
 *             order = order.upper()
 *             if order == 'A':             # <<<<<<<<<<<<<<
 *                 if self._f_contiguous:
 *                     order = 'F'
 */
    __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_A, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1469, __pyx_L1_error)
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":1470
 *             order = order.upper()
 *             if order == 'A':
 *                 if self._f_contiguous:             # <<<<<<<<<<<<<<
 *                     order = 'F'
 *                 else:
 */
      __pyx_t_7 = (__pyx_v_self->_f_contiguous != 0);
      if (__pyx_t_7) {

        /* "cupy/core/core.pyx":1471
 *             if order == 'A':
 *                 if self._f_contiguous:
 *                     order = 'F'             # <<<<<<<<<<<<<<
 *                 else:
 *                     order = 'C'
 */
        __Pyx_INCREF(__pyx_n_u_F);
        __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_u_F);

        /* "cupy/core/core.pyx":1470
 *             order = order.upper()
 *             if order == 'A':
 *                 if self._f_contiguous:             # <<<<<<<<<<<<<<
 *                     order = 'F'
 *                 else:
 */
        goto __pyx_L29;
      }

      /* "cupy/core/core.pyx":1473
 *                     order = 'F'
 *                 else:
 *                     order = 'C'             # <<<<<<<<<<<<<<
 *             if not (order == 'C' and self._c_contiguous or
 *                     order == 'F' and self._f_contiguous):
 */
      /*else*/ {
        __Pyx_INCREF(__pyx_n_u_C);
        __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_u_C);
      }
      __pyx_L29:;

      /* "cupy/core/core.pyx":1469
 * 
 *             order = order.upper()
 *             if order == 'A':             # <<<<<<<<<<<<<<
 *                 if self._f_contiguous:
 *                     order = 'F'
 */
    }

    /* "cupy/core/core.pyx":1474
 *                 else:
 *                     order = 'C'
 *             if not (order == 'C' and self._c_contiguous or             # <<<<<<<<<<<<<<
 *                     order == 'F' and self._f_contiguous):
 *                 with self.device:
 */
    __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_C, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1474, __pyx_L1_error)
    if (!__pyx_t_8) {
      goto __pyx_L32_next_or;
    } else {
    }
    __pyx_t_8 = (__pyx_v_self->_c_contiguous != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L31_bool_binop_done;
    }
    __pyx_L32_next_or:;

    /* "cupy/core/core.pyx":1475
 *                     order = 'C'
 *             if not (order == 'C' and self._c_contiguous or
 *                     order == 'F' and self._f_contiguous):             # <<<<<<<<<<<<<<
 *                 with self.device:
 *                     if order == 'C':
 */
    __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_F, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1475, __pyx_L1_error)
    if (__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L31_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_v_self->_f_contiguous != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L31_bool_binop_done:;

    /* "cupy/core/core.pyx":1474
 *                 else:
 *                     order = 'C'
 *             if not (order == 'C' and self._c_contiguous or             # <<<<<<<<<<<<<<
 *                     order == 'F' and self._f_contiguous):
 *                 with self.device:
 */
    __pyx_t_8 = ((!__pyx_t_7) != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1476
 *             if not (order == 'C' and self._c_contiguous or
 *                     order == 'F' and self._f_contiguous):
 *                 with self.device:             # <<<<<<<<<<<<<<
 *                     if order == 'C':
 *                         a_gpu = _internal_ascontiguousarray(self)
 */
      /*with:*/ {
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_device); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1476, __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(0, 1476, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_1 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_enter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1476, __pyx_L35_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_9 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1476, __pyx_L35_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else {
          __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1476, __pyx_L35_error)
        }
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        /*try:*/ {
          {
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_11);
            /*try:*/ {

              /* "cupy/core/core.pyx":1477
 *                     order == 'F' and self._f_contiguous):
 *                 with self.device:
 *                     if order == 'C':             # <<<<<<<<<<<<<<
 *                         a_gpu = _internal_ascontiguousarray(self)
 *                     elif order == 'F':
 */
              __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_C, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1477, __pyx_L39_error)
              if (__pyx_t_8) {

                /* "cupy/core/core.pyx":1478
 *                 with self.device:
 *                     if order == 'C':
 *                         a_gpu = _internal_ascontiguousarray(self)             # <<<<<<<<<<<<<<
 *                     elif order == 'F':
 *                         a_gpu = _internal_asfortranarray(self)
 */
                __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_self, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1478, __pyx_L39_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_v_a_gpu = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
                __pyx_t_3 = 0;

                /* "cupy/core/core.pyx":1477
 *                     order == 'F' and self._f_contiguous):
 *                 with self.device:
 *                     if order == 'C':             # <<<<<<<<<<<<<<
 *                         a_gpu = _internal_ascontiguousarray(self)
 *                     elif order == 'F':
 */
                goto __pyx_L45;
              }

              /* "cupy/core/core.pyx":1479
 *                     if order == 'C':
 *                         a_gpu = _internal_ascontiguousarray(self)
 *                     elif order == 'F':             # <<<<<<<<<<<<<<
 *                         a_gpu = _internal_asfortranarray(self)
 *                     else:
 */
              __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_F, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1479, __pyx_L39_error)
              if (likely(__pyx_t_8)) {

                /* "cupy/core/core.pyx":1480
 *                         a_gpu = _internal_ascontiguousarray(self)
 *                     elif order == 'F':
 *                         a_gpu = _internal_asfortranarray(self)             # <<<<<<<<<<<<<<
 *                     else:
 *                         raise ValueError('unsupported order: {}'.format(order))
 */
                __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_asfortranarray(__pyx_v_self, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1480, __pyx_L39_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_v_a_gpu = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
                __pyx_t_3 = 0;

                /* "cupy/core/core.pyx":1479
 *                     if order == 'C':
 *                         a_gpu = _internal_ascontiguousarray(self)
 *                     elif order == 'F':             # <<<<<<<<<<<<<<
 *                         a_gpu = _internal_asfortranarray(self)
 *                     else:
 */
                goto __pyx_L45;
              }

              /* "cupy/core/core.pyx":1482
 *                         a_gpu = _internal_asfortranarray(self)
 *                     else:
 *                         raise ValueError('unsupported order: {}'.format(order))             # <<<<<<<<<<<<<<
 *             else:
 *                 a_gpu = self
 */
              /*else*/ {
                __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unsupported_order, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1482, __pyx_L39_error)
                __Pyx_GOTREF(__pyx_t_9);
                __pyx_t_1 = NULL;
                if (CYTHON_UNPACK_METHODS && likely(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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_order); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1482, __pyx_L39_error)
                  __Pyx_GOTREF(__pyx_t_3);
                } else {
                  #if CYTHON_FAST_PYCALL
                  if (PyFunction_Check(__pyx_t_9)) {
                    PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_order};
                    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1482, __pyx_L39_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_9)) {
                    PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_order};
                    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1482, __pyx_L39_error)
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_GOTREF(__pyx_t_3);
                  } else
                  #endif
                  {
                    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1482, __pyx_L39_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_INCREF(__pyx_v_order);
                    __Pyx_GIVEREF(__pyx_v_order);
                    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_order);
                    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1482, __pyx_L39_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  }
                }
                __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1482, __pyx_L39_error)
                __Pyx_GOTREF(__pyx_t_9);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_Raise(__pyx_t_9, 0, 0, 0);
                __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                __PYX_ERR(0, 1482, __pyx_L39_error)
              }
              __pyx_L45:;

              /* "cupy/core/core.pyx":1476
 *             if not (order == 'C' and self._c_contiguous or
 *                     order == 'F' and self._f_contiguous):
 *                 with self.device:             # <<<<<<<<<<<<<<
 *                     if order == 'C':
 *                         a_gpu = _internal_ascontiguousarray(self)
 */
            }
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            goto __pyx_L44_try_end;
            __pyx_L39_error:;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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.ndarray.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_3, &__pyx_t_4) < 0) __PYX_ERR(0, 1476, __pyx_L41_except_error)
              __Pyx_GOTREF(__pyx_t_9);
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_1 = PyTuple_Pack(3, __pyx_t_9, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1476, __pyx_L41_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, 1476, __pyx_L41_except_error)
              __Pyx_GOTREF(__pyx_t_14);
              __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_14);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              if (__pyx_t_8 < 0) __PYX_ERR(0, 1476, __pyx_L41_except_error)
              __pyx_t_7 = ((!(__pyx_t_8 != 0)) != 0);
              if (__pyx_t_7) {
                __Pyx_GIVEREF(__pyx_t_9);
                __Pyx_GIVEREF(__pyx_t_3);
                __Pyx_XGIVEREF(__pyx_t_4);
                __Pyx_ErrRestoreWithState(__pyx_t_9, __pyx_t_3, __pyx_t_4);
                __pyx_t_9 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0; 
                __PYX_ERR(0, 1476, __pyx_L41_except_error)
              }
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              goto __pyx_L40_exception_handled;
            }
            __pyx_L41_except_error:;
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
            goto __pyx_L1_error;
            __pyx_L40_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
            __pyx_L44_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_10) {
              __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__27, NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1476, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_11);
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            }
            goto __pyx_L38;
          }
          __pyx_L38:;
        }
        goto __pyx_L49;
        __pyx_L35_error:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L1_error;
        __pyx_L49:;
      }

      /* "cupy/core/core.pyx":1474
 *                 else:
 *                     order = 'C'
 *             if not (order == 'C' and self._c_contiguous or             # <<<<<<<<<<<<<<
 *                     order == 'F' and self._f_contiguous):
 *                 with self.device:
 */
      goto __pyx_L30;
    }

    /* "cupy/core/core.pyx":1484
 *                         raise ValueError('unsupported order: {}'.format(order))
 *             else:
 *                 a_gpu = self             # <<<<<<<<<<<<<<
 *             a_cpu = numpy.empty(self._shape, dtype=self.dtype, order=order)
 * 
 */
    /*else*/ {
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __pyx_v_a_gpu = __pyx_v_self;
    }
    __pyx_L30:;

    /* "cupy/core/core.pyx":1485
 *             else:
 *                 a_gpu = self
 *             a_cpu = numpy.empty(self._shape, dtype=self.dtype, order=order)             # <<<<<<<<<<<<<<
 * 
 *         syncdetect._declare_synchronize()
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1485, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1485, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_self->_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1485, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1485, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1485, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_v_self->dtype) < 0) __PYX_ERR(0, 1485, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 1485, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1485, __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(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_a_cpu = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1487
 *             a_cpu = numpy.empty(self._shape, dtype=self.dtype, order=order)
 * 
 *         syncdetect._declare_synchronize()             # <<<<<<<<<<<<<<
 *         ptr = ctypes.c_void_p(a_cpu.__array_interface__['data'][0])
 *         with self.device:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_syncdetect); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1487, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_declare_synchronize); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1487, __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_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1487, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1487, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1488
 * 
 *         syncdetect._declare_synchronize()
 *         ptr = ctypes.c_void_p(a_cpu.__array_interface__['data'][0])             # <<<<<<<<<<<<<<
 *         with self.device:
 *             if stream is not None:
 */
  __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_c_void_p); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_array_interface); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_9, __pyx_n_u_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  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);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1488, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_9};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1488, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __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[2] = {__pyx_t_3, __pyx_t_9};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1488, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1488, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1488, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_ptr = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1489
 *         syncdetect._declare_synchronize()
 *         ptr = ctypes.c_void_p(a_cpu.__array_interface__['data'][0])
 *         with self.device:             # <<<<<<<<<<<<<<
 *             if stream is not None:
 *                 a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes, stream)
 */
  /*with:*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1489, __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, 1489, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1489, __pyx_L50_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_9) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1489, __pyx_L50_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1489, __pyx_L50_error)
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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":1490
 *         ptr = ctypes.c_void_p(a_cpu.__array_interface__['data'][0])
 *         with self.device:
 *             if stream is not None:             # <<<<<<<<<<<<<<
 *                 a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes, stream)
 *             else:
 */
          __pyx_t_7 = (__pyx_v_stream != Py_None);
          __pyx_t_8 = (__pyx_t_7 != 0);
          if (__pyx_t_8) {

            /* "cupy/core/core.pyx":1491
 *         with self.device:
 *             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, 1491, __pyx_L54_error) }
            if (unlikely(!__pyx_v_a_gpu)) { __Pyx_RaiseUnboundLocalError("a_gpu"); __PYX_ERR(0, 1491, __pyx_L54_error) }
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a_gpu), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1491, __pyx_L54_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_15 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_15 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1491, __pyx_L54_error)
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_16.__pyx_n = 1;
            __pyx_t_16.stream = __pyx_v_stream;
            __pyx_t_1 = ((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_15, 0, &__pyx_t_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1491, __pyx_L54_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "cupy/core/core.pyx":1490
 *         ptr = ctypes.c_void_p(a_cpu.__array_interface__['data'][0])
 *         with self.device:
 *             if stream is not None:             # <<<<<<<<<<<<<<
 *                 a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes, stream)
 *             else:
 */
            goto __pyx_L60;
          }

          /* "cupy/core/core.pyx":1493
 *                 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":1494
 *             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_8 = ((__pyx_v_stream_ptr == 0) != 0);
            if (__pyx_t_8) {

              /* "cupy/core/core.pyx":1495
 *                 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, 1495, __pyx_L54_error) }
              if (unlikely(!__pyx_v_a_gpu)) { __Pyx_RaiseUnboundLocalError("a_gpu"); __PYX_ERR(0, 1495, __pyx_L54_error) }
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a_gpu), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1495, __pyx_L54_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_15 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_15 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1495, __pyx_L54_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __pyx_t_1 = ((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_15, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1495, __pyx_L54_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "cupy/core/core.pyx":1494
 *             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_L61;
            }

            /* "cupy/core/core.pyx":1497
 *                     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, 1497, __pyx_L54_error) }
              if (unlikely(!__pyx_v_a_gpu)) { __Pyx_RaiseUnboundLocalError("a_gpu"); __PYX_ERR(0, 1497, __pyx_L54_error) }
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a_gpu), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1497, __pyx_L54_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_15 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_15 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1497, __pyx_L54_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __pyx_t_1 = ((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_15, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1497, __pyx_L54_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            }
            __pyx_L61:;
          }
          __pyx_L60:;

          /* "cupy/core/core.pyx":1489
 *         syncdetect._declare_synchronize()
 *         ptr = ctypes.c_void_p(a_cpu.__array_interface__['data'][0])
 *         with self.device:             # <<<<<<<<<<<<<<
 *             if stream is not None:
 *                 a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes, stream)
 */
        }
        __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_L59_try_end;
        __pyx_L54_error:;
        __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;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("cupy.core.core.ndarray.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_2) < 0) __PYX_ERR(0, 1489, __pyx_L56_except_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_9 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1489, __pyx_L56_except_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_9, NULL);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1489, __pyx_L56_except_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (__pyx_t_8 < 0) __PYX_ERR(0, 1489, __pyx_L56_except_error)
          __pyx_t_7 = ((!(__pyx_t_8 != 0)) != 0);
          if (__pyx_t_7) {
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_4);
            __Pyx_XGIVEREF(__pyx_t_2);
            __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_4, __pyx_t_2);
            __pyx_t_1 = 0; __pyx_t_4 = 0; __pyx_t_2 = 0; 
            __PYX_ERR(0, 1489, __pyx_L56_except_error)
          }
          __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;
          goto __pyx_L55_exception_handled;
        }
        __pyx_L56_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_L55_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_L59_try_end:;
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_10) {
          __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__28, NULL);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1489, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
        goto __pyx_L53;
      }
      __pyx_L53:;
    }
    goto __pyx_L65;
    __pyx_L50_error:;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    goto __pyx_L1_error;
    __pyx_L65:;
  }

  /* "cupy/core/core.pyx":1498
 *                 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":1420
 *         return self.data.device
 * 
 *     cpdef get(self, stream=None, order='C', out=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_6);
  __Pyx_XDECREF(__pyx_t_9);
  __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_XDECREF(__pyx_v_order);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_207get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_206get[] = "ndarray.get(self, stream=None, order=u'C', out=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            order ({'C', 'F', 'A'}): The desired memory layout of the host\n                array. When ``order`` is 'A', it uses 'F' if the array is\n                fortran-contiguous and 'C' otherwise. The ``order`` will be\n                ignored if ``out`` is specified.\n            out (numpy.ndarray): Output array. In order to enable asynchronous\n                copy, the underlying memory should be a pinned memory.\n\n        Returns:\n            numpy.ndarray: Copy of the array on host memory.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_207get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_stream = 0;
  PyObject *__pyx_v_order = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_stream,&__pyx_n_s_order,&__pyx_n_s_out,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)__pyx_n_u_C);
    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_stream);
          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_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_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, "get") < 0)) __PYX_ERR(0, 1420, __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_stream = values[0];
    __pyx_v_order = values[1];
    __pyx_v_out = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1420, __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_206get(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_stream, __pyx_v_order, __pyx_v_out);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_206get(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_stream, PyObject *__pyx_v_order, PyObject *__pyx_v_out) {
  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 = 3;
  __pyx_t_2.stream = __pyx_v_stream;
  __pyx_t_2.order = __pyx_v_order;
  __pyx_t_2.out = __pyx_v_out;
  __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, 1420, __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":1500
 *         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_209set(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;
  intptr_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;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  size_t __pyx_t_14;
  struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_host_async __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  __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, 1500, __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_209set)) {
      __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, 1500, __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, 1500, __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, 1500, __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, 1500, __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":1510
 * 
 *         """
 *         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, 1510, __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, 1510, __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, 1510, __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":1511
 *         """
 *         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__29, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1511, __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, 1511, __pyx_L1_error)

    /* "cupy/core/core.pyx":1510
 * 
 *         """
 *         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":1512
 *         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, 1512, __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, 1512, __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, 1512, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_t_8)) {

    /* "cupy/core/core.pyx":1513
 *             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_u_array_cannot_be_set_to_array, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "cupy/core/core.pyx":1514
 *         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, 1514, __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, 1513, __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, 1513, __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, 1513, __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, 1513, __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":1513
 *             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, 1513, __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, 1513, __pyx_L1_error)

    /* "cupy/core/core.pyx":1512
 *         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":1515
 *             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, 1515, __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, 1515, __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, 1515, __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, 1515, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(__pyx_t_8)) {

    /* "cupy/core/core.pyx":1517
 *         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_u_Shape_mismatch_Old_shape_new_sha, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "cupy/core/core.pyx":1518
 *             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, 1518, __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, 1518, __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, 1517, __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, 1517, __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, 1517, __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, 1517, __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":1516
 *                 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, 1516, __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, 1516, __pyx_L1_error)

    /* "cupy/core/core.pyx":1515
 *             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":1519
 *                 '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":1520
 *                     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, 1520, __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, 1520, __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, 1520, __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, 1520, __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, 1520, __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, 1520, __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, 1520, __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":1519
 *                 '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":1521
 *         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":1522
 *             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, 1522, __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, 1522, __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, 1522, __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, 1522, __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, 1522, __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, 1522, __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, 1522, __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":1521
 *         if self._c_contiguous:
 *             arr = numpy.ascontiguousarray(arr)
 *         elif self._f_contiguous:             # <<<<<<<<<<<<<<
 *             arr = numpy.asfortranarray(arr)
 *         else:
 */
    goto __pyx_L6;
  }

  /* "cupy/core/core.pyx":1524
 *             arr = numpy.asfortranarray(arr)
 *         else:
 *             raise RuntimeError('Cannot set to non-contiguous array')             # <<<<<<<<<<<<<<
 * 
 *         ptr = ctypes.c_void_p(arr.__array_interface__['data'][0])
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1524, __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, 1524, __pyx_L1_error)
  }
  __pyx_L6:;

  /* "cupy/core/core.pyx":1526
 *             raise RuntimeError('Cannot set to non-contiguous array')
 * 
 *         ptr = ctypes.c_void_p(arr.__array_interface__['data'][0])             # <<<<<<<<<<<<<<
 *         with self.device:
 *             if stream is not None:
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_c_void_p); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1526, __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_arr, __pyx_n_s_array_interface); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_9 = __Pyx_PyObject_Dict_GetItem(__pyx_t_3, __pyx_n_u_data); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_9, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1526, __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_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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1526, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1526, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 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[2] = {__pyx_t_9, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1526, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1526, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_9); __pyx_t_9 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1526, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_ptr = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1527
 * 
 *         ptr = ctypes.c_void_p(arr.__array_interface__['data'][0])
 *         with self.device:             # <<<<<<<<<<<<<<
 *             if stream is not None:
 *                 self.data.copy_from_host_async(ptr, self.nbytes, stream)
 */
  /*with:*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1527, __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, 1527, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1527, __pyx_L7_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_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1527, __pyx_L7_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1527, __pyx_L7_error)
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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":1528
 *         ptr = ctypes.c_void_p(arr.__array_interface__['data'][0])
 *         with self.device:
 *             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":1529
 *         with self.device:
 *             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, 1529, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_14 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_14 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1529, __pyx_L11_error)
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_15.__pyx_n = 1;
            __pyx_t_15.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_14, 0, &__pyx_t_15); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1529, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "cupy/core/core.pyx":1528
 *         ptr = ctypes.c_void_p(arr.__array_interface__['data'][0])
 *         with self.device:
 *             if stream is not None:             # <<<<<<<<<<<<<<
 *                 self.data.copy_from_host_async(ptr, self.nbytes, stream)
 *             else:
 */
            goto __pyx_L17;
          }

          /* "cupy/core/core.pyx":1531
 *                 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":1532
 *             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":1533
 *                 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, 1533, __pyx_L11_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_14 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_14 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1533, __pyx_L11_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_14, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1533, __pyx_L11_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "cupy/core/core.pyx":1532
 *             else:
 *                 stream_ptr = stream_module.get_current_stream_ptr()
 *                 if stream_ptr == 0:             # <<<<<<<<<<<<<<
 *                     self.data.copy_from_host(ptr, self.nbytes)
 *                 else:
 */
              goto __pyx_L18;
            }

            /* "cupy/core/core.pyx":1535
 *                     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, 1535, __pyx_L11_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_14 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_14 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1535, __pyx_L11_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_14, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1535, __pyx_L11_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            }
            __pyx_L18:;
          }
          __pyx_L17:;

          /* "cupy/core/core.pyx":1527
 * 
 *         ptr = ctypes.c_void_p(arr.__array_interface__['data'][0])
 *         with self.device:             # <<<<<<<<<<<<<<
 *             if stream is not None:
 *                 self.data.copy_from_host_async(ptr, self.nbytes, stream)
 */
        }
        __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_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("cupy.core.core.ndarray.set", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_2) < 0) __PYX_ERR(0, 1527, __pyx_L13_except_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1527, __pyx_L13_except_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_3, NULL);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1527, __pyx_L13_except_error)
          __Pyx_GOTREF(__pyx_t_16);
          __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          if (__pyx_t_7 < 0) __PYX_ERR(0, 1527, __pyx_L13_except_error)
          __pyx_t_8 = ((!(__pyx_t_7 != 0)) != 0);
          if (__pyx_t_8) {
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_4);
            __Pyx_XGIVEREF(__pyx_t_2);
            __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_4, __pyx_t_2);
            __pyx_t_1 = 0; __pyx_t_4 = 0; __pyx_t_2 = 0; 
            __PYX_ERR(0, 1527, __pyx_L13_except_error)
          }
          __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;
          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__31, NULL);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1527, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
        goto __pyx_L10;
      }
      __pyx_L10:;
    }
    goto __pyx_L22;
    __pyx_L7_error:;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    goto __pyx_L1_error;
    __pyx_L22:;
  }

  /* "cupy/core/core.pyx":1500
 *         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_209set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_208set[] = "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_209set(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, 1500, __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, 1500, __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_208set(((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_208set(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, 1500, __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":1537
 *                     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_211reduced_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 = 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;
  int __pyx_t_6;
  int __pyx_t_7;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  __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, 1537, __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_211reduced_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, 1537, __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, 1537, __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, 1537, __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, 1537, __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, 1537, __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, 1537, __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":1552
 *         cdef Py_ssize_t ndim
 *         cdef ndarray view
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             warnings.warn(
 *                 'calling reduced_view with dtype is deprecated',
 */
  __pyx_t_6 = (__pyx_v_dtype != Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":1553
 *         cdef ndarray view
 *         if dtype is not None:
 *             warnings.warn(             # <<<<<<<<<<<<<<
 *                 'calling reduced_view with dtype is deprecated',
 *                 DeprecationWarning)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1553, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1553, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1555
 *             warnings.warn(
 *                 'calling reduced_view with dtype is deprecated',
 *                 DeprecationWarning)             # <<<<<<<<<<<<<<
 *             return self.reduced_view().view(dtype)
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1553, __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":1556
 *                 'calling reduced_view with dtype is deprecated',
 *                 DeprecationWarning)
 *             return self.reduced_view().view(dtype)             # <<<<<<<<<<<<<<
 * 
 *         ndim = self._shape.size()
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->reduced_view(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.dtype = __pyx_v_dtype;
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1)->__pyx_vtab)->view(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1), 0, &__pyx_t_8)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1552
 *         cdef Py_ssize_t ndim
 *         cdef ndarray view
 *         if dtype is not None:             # <<<<<<<<<<<<<<
 *             warnings.warn(
 *                 'calling reduced_view with dtype is deprecated',
 */
  }

  /* "cupy/core/core.pyx":1558
 *             return self.reduced_view().view(dtype)
 * 
 *         ndim = self._shape.size()             # <<<<<<<<<<<<<<
 *         if ndim <= 1:
 *             return self
 */
  __pyx_v_ndim = __pyx_v_self->_shape.size();

  /* "cupy/core/core.pyx":1559
 * 
 *         ndim = self._shape.size()
 *         if ndim <= 1:             # <<<<<<<<<<<<<<
 *             return self
 *         if self._c_contiguous:
 */
  __pyx_t_7 = ((__pyx_v_ndim <= 1) != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":1560
 *         ndim = self._shape.size()
 *         if ndim <= 1:
 *             return self             # <<<<<<<<<<<<<<
 *         if self._c_contiguous:
 *             view = self.view()
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1559
 * 
 *         ndim = self._shape.size()
 *         if ndim <= 1:             # <<<<<<<<<<<<<<
 *             return self
 *         if self._c_contiguous:
 */
  }

  /* "cupy/core/core.pyx":1561
 *         if ndim <= 1:
 *             return self
 *         if self._c_contiguous:             # <<<<<<<<<<<<<<
 *             view = self.view()
 *             view._shape.assign(1, self.size)
 */
  __pyx_t_7 = (__pyx_v_self->_c_contiguous != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":1562
 *             return self
 *         if self._c_contiguous:
 *             view = self.view()             # <<<<<<<<<<<<<<
 *             view._shape.assign(1, self.size)
 *             view._strides.assign(1, self.dtype.itemsize)
 */
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":1563
 *         if self._c_contiguous:
 *             view = self.view()
 *             view._shape.assign(1, self.size)             # <<<<<<<<<<<<<<
 *             view._strides.assign(1, self.dtype.itemsize)
 *             view._update_f_contiguity()
 */
    __pyx_v_view->_shape.assign(1, __pyx_v_self->size);

    /* "cupy/core/core.pyx":1564
 *             view = self.view()
 *             view._shape.assign(1, self.size)
 *             view._strides.assign(1, self.dtype.itemsize)             # <<<<<<<<<<<<<<
 *             view._update_f_contiguity()
 *             return view
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1564, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_view->_strides.assign(1, __pyx_t_9);

    /* "cupy/core/core.pyx":1565
 *             view._shape.assign(1, self.size)
 *             view._strides.assign(1, self.dtype.itemsize)
 *             view._update_f_contiguity()             # <<<<<<<<<<<<<<
 *             return view
 * 
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_view->__pyx_vtab)->_update_f_contiguity(__pyx_v_view, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":1566
 *             view._strides.assign(1, self.dtype.itemsize)
 *             view._update_f_contiguity()
 *             return view             # <<<<<<<<<<<<<<
 * 
 *         internal.get_reduced_dims(
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_view));
    __pyx_r = __pyx_v_view;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1561
 *         if ndim <= 1:
 *             return self
 *         if self._c_contiguous:             # <<<<<<<<<<<<<<
 *             view = self.view()
 *             view._shape.assign(1, self.size)
 */
  }

  /* "cupy/core/core.pyx":1569
 * 
 *         internal.get_reduced_dims(
 *             self._shape, self._strides, self.dtype.itemsize, shape, strides)             # <<<<<<<<<<<<<<
 *         if ndim == <Py_ssize_t>shape.size():
 *             return self
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":1568
 *             return view
 * 
 *         internal.get_reduced_dims(             # <<<<<<<<<<<<<<
 *             self._shape, self._strides, self.dtype.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_9, __pyx_v_shape, __pyx_v_strides);

  /* "cupy/core/core.pyx":1570
 *         internal.get_reduced_dims(
 *             self._shape, self._strides, self.dtype.itemsize, shape, strides)
 *         if ndim == <Py_ssize_t>shape.size():             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  __pyx_t_7 = ((__pyx_v_ndim == ((Py_ssize_t)__pyx_v_shape.size())) != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":1571
 *             self._shape, self._strides, self.dtype.itemsize, shape, strides)
 *         if ndim == <Py_ssize_t>shape.size():
 *             return self             # <<<<<<<<<<<<<<
 * 
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1570
 *         internal.get_reduced_dims(
 *             self._shape, self._strides, self.dtype.itemsize, shape, strides)
 *         if ndim == <Py_ssize_t>shape.size():             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  }

  /* "cupy/core/core.pyx":1574
 * 
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 *         return self._view(shape, strides, False, True)             # <<<<<<<<<<<<<<
 * 
 *     cpdef _update_c_contiguity(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->_view(__pyx_v_self, __pyx_v_shape, __pyx_v_strides, 0, 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1574, __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":1537
 *                     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_211reduced_view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_210reduced_view[] = "ndarray.reduced_view(self, dtype=None) -> ndarray\nReturns a view of the array with minimum number of dimensions.\n\n        Args:\n            dtype: (Deprecated) Data type specifier.\n                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_211reduced_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, 1537, __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, 1537, __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_210reduced_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_210reduced_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, 1537, __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":1576
 *         return self._view(shape, strides, False, True)
 * 
 *     cpdef _update_c_contiguity(self):             # <<<<<<<<<<<<<<
 *         if self.size == 0:
 *             self._c_contiguous = True
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_213_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, 1576, __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_213_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, 1576, __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, 1576, __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":1577
 * 
 *     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":1578
 *     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":1579
 *         if self.size == 0:
 *             self._c_contiguous = True
 *             return             # <<<<<<<<<<<<<<
 *         self._c_contiguous = internal.get_c_contiguity(
 *             self._shape, self._strides, self.dtype.itemsize)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1577
 * 
 *     cpdef _update_c_contiguity(self):
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             self._c_contiguous = True
 *             return
 */
  }

  /* "cupy/core/core.pyx":1581
 *             return
 *         self._c_contiguous = internal.get_c_contiguity(
 *             self._shape, self._strides, self.dtype.itemsize)             # <<<<<<<<<<<<<<
 * 
 *     cpdef _update_f_contiguity(self):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1581, __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, 1581, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1580
 *             self._c_contiguous = True
 *             return
 *         self._c_contiguous = internal.get_c_contiguity(             # <<<<<<<<<<<<<<
 *             self._shape, self._strides, self.dtype.itemsize)
 * 
 */
  __pyx_v_self->_c_contiguous = __pyx_f_4cupy_4core_8internal_get_c_contiguity(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_t_6, 0);

  /* "cupy/core/core.pyx":1576
 *         return self._view(shape, strides, False, True)
 * 
 *     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_213_update_c_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_212_update_c_contiguity[] = "ndarray._update_c_contiguity(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_213_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_212_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_212_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, 1576, __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":1583
 *             self._shape, self._strides, self.dtype.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_215_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, 1583, __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_215_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, 1583, __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, 1583, __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":1586
 *         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":1587
 *         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":1588
 *         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":1586
 *         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":1589
 *             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":1590
 *             return
 *         if self._c_contiguous:
 *             count = 0             # <<<<<<<<<<<<<<
 *             for i in self._shape:
 *                 if i == 1:
 */
    __pyx_v_count = 0;

    /* "cupy/core/core.pyx":1591
 *         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":1592
 *             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":1593
 *             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":1592
 *             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":1591
 *         if self._c_contiguous:
 *             count = 0
 *             for i in self._shape:             # <<<<<<<<<<<<<<
 *                 if i == 1:
 *                     count += 1
 */
    }

    /* "cupy/core/core.pyx":1594
 *                 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":1595
 *                     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":1589
 *             self._f_contiguous = True
 *             return
 *         if self._c_contiguous:             # <<<<<<<<<<<<<<
 *             count = 0
 *             for i in self._shape:
 */
  }

  /* "cupy/core/core.pyx":1596
 *             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, 1596, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":1597
 *             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.dtype.itemsize)
 */
  try {
    __pyx_v_rev_strides.assign(__pyx_v_self->_strides.rbegin(), __pyx_v_self->_strides.rend());
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 1597, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":1599
 *         rev_strides.assign(self._strides.rbegin(), self._strides.rend())
 *         self._f_contiguous = internal.get_c_contiguity(
 *             rev_shape, rev_strides, self.dtype.itemsize)             # <<<<<<<<<<<<<<
 * 
 *     cpdef _update_contiguity(self):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1599, __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, 1599, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1598
 *         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.dtype.itemsize)
 * 
 */
  __pyx_v_self->_f_contiguous = __pyx_f_4cupy_4core_8internal_get_c_contiguity(__pyx_v_rev_shape, __pyx_v_rev_strides, __pyx_t_8, 0);

  /* "cupy/core/core.pyx":1583
 *             self._shape, self._strides, self.dtype.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_215_update_f_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_214_update_f_contiguity[] = "ndarray._update_f_contiguity(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_215_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_214_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_214_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, 1583, __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":1601
 *             rev_shape, rev_strides, self.dtype.itemsize)
 * 
 *     cpdef _update_contiguity(self):             # <<<<<<<<<<<<<<
 *         self._update_c_contiguity()
 *         self._update_f_contiguity()
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_217_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, 1601, __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_217_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, 1601, __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, 1601, __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":1602
 * 
 *     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, 1602, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1603
 *     cpdef _update_contiguity(self):
 *         self._update_c_contiguity()
 *         self._update_f_contiguity()             # <<<<<<<<<<<<<<
 * 
 *     cpdef _set_shape_and_strides(self, const 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, 1603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1601
 *             rev_shape, rev_strides, self.dtype.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_217_update_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_216_update_contiguity[] = "ndarray._update_contiguity(self)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_217_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_216_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_216_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, 1601, __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":1605
 *         self._update_f_contiguity()
 * 
 *     cpdef _set_shape_and_strides(self, const vector.vector[Py_ssize_t]& shape,             # <<<<<<<<<<<<<<
 *                                  const vector.vector[Py_ssize_t]& strides,
 *                                  bint update_c_contiguity,
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_219_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>  const &__pyx_v_shape, std::vector<Py_ssize_t>  const &__pyx_v_strides, int __pyx_v_update_c_contiguity, int __pyx_v_update_f_contiguity, 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;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  __Pyx_RefNannySetupContext("_set_shape_and_strides", 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_set_shape_and_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1605, __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_219_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, 1605, __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, 1605, __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, 1605, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_v_update_f_contiguity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1605, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_7 = __pyx_t_1; __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[5] = {__pyx_t_8, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1605, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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;
        __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[5] = {__pyx_t_8, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1605, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1605, __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_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_9, __pyx_t_6);
        __pyx_t_3 = 0;
        __pyx_t_4 = 0;
        __pyx_t_5 = 0;
        __pyx_t_6 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1605, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 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":1609
 *                                  bint update_c_contiguity,
 *                                  bint update_f_contiguity):
 *         if shape.size() != strides.size():             # <<<<<<<<<<<<<<
 *             raise ValueError('len(shape) != len(strides)')
 *         self._shape = shape
 */
  __pyx_t_11 = ((__pyx_v_shape.size() != __pyx_v_strides.size()) != 0);
  if (unlikely(__pyx_t_11)) {

    /* "cupy/core/core.pyx":1610
 *                                  bint update_f_contiguity):
 *         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__33, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1610, __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, 1610, __pyx_L1_error)

    /* "cupy/core/core.pyx":1609
 *                                  bint update_c_contiguity,
 *                                  bint update_f_contiguity):
 *         if shape.size() != strides.size():             # <<<<<<<<<<<<<<
 *             raise ValueError('len(shape) != len(strides)')
 *         self._shape = shape
 */
  }

  /* "cupy/core/core.pyx":1611
 *         if shape.size() != strides.size():
 *             raise ValueError('len(shape) != len(strides)')
 *         self._shape = shape             # <<<<<<<<<<<<<<
 *         self._strides = strides
 *         self.size = internal.prod(shape)
 */
  __pyx_v_self->_shape = __pyx_v_shape;

  /* "cupy/core/core.pyx":1612
 *             raise ValueError('len(shape) != len(strides)')
 *         self._shape = shape
 *         self._strides = strides             # <<<<<<<<<<<<<<
 *         self.size = internal.prod(shape)
 *         if update_c_contiguity:
 */
  __pyx_v_self->_strides = __pyx_v_strides;

  /* "cupy/core/core.pyx":1613
 *         self._shape = shape
 *         self._strides = strides
 *         self.size = internal.prod(shape)             # <<<<<<<<<<<<<<
 *         if update_c_contiguity:
 *             self._update_c_contiguity()
 */
  __pyx_v_self->size = __pyx_f_4cupy_4core_8internal_prod(__pyx_v_shape, 0);

  /* "cupy/core/core.pyx":1614
 *         self._strides = strides
 *         self.size = internal.prod(shape)
 *         if update_c_contiguity:             # <<<<<<<<<<<<<<
 *             self._update_c_contiguity()
 *         if update_f_contiguity:
 */
  __pyx_t_11 = (__pyx_v_update_c_contiguity != 0);
  if (__pyx_t_11) {

    /* "cupy/core/core.pyx":1615
 *         self.size = internal.prod(shape)
 *         if update_c_contiguity:
 *             self._update_c_contiguity()             # <<<<<<<<<<<<<<
 *         if update_f_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, 1615, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1614
 *         self._strides = strides
 *         self.size = internal.prod(shape)
 *         if update_c_contiguity:             # <<<<<<<<<<<<<<
 *             self._update_c_contiguity()
 *         if update_f_contiguity:
 */
  }

  /* "cupy/core/core.pyx":1616
 *         if update_c_contiguity:
 *             self._update_c_contiguity()
 *         if update_f_contiguity:             # <<<<<<<<<<<<<<
 *             self._update_f_contiguity()
 * 
 */
  __pyx_t_11 = (__pyx_v_update_f_contiguity != 0);
  if (__pyx_t_11) {

    /* "cupy/core/core.pyx":1617
 *             self._update_c_contiguity()
 *         if update_f_contiguity:
 *             self._update_f_contiguity()             # <<<<<<<<<<<<<<
 * 
 *     cdef ndarray _view(self, const 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, 1617, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1616
 *         if update_c_contiguity:
 *             self._update_c_contiguity()
 *         if update_f_contiguity:             # <<<<<<<<<<<<<<
 *             self._update_f_contiguity()
 * 
 */
  }

  /* "cupy/core/core.pyx":1605
 *         self._update_f_contiguity()
 * 
 *     cpdef _set_shape_and_strides(self, const vector.vector[Py_ssize_t]& shape,             # <<<<<<<<<<<<<<
 *                                  const vector.vector[Py_ssize_t]& strides,
 *                                  bint update_c_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_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __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_219_set_shape_and_strides(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_218_set_shape_and_strides[] = "ndarray._set_shape_and_strides(self, vector[Py_ssize_t] shape, vector[Py_ssize_t] strides, bool update_c_contiguity, bool update_f_contiguity)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_219_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;
  int __pyx_v_update_f_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,&__pyx_n_s_update_f_contiguity_2,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_strides)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_set_shape_and_strides", 1, 4, 4, 1); __PYX_ERR(0, 1605, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_update_c_contiguity_2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_set_shape_and_strides", 1, 4, 4, 2); __PYX_ERR(0, 1605, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_update_f_contiguity_2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_set_shape_and_strides", 1, 4, 4, 3); __PYX_ERR(0, 1605, __pyx_L3_error)
        }
      }
      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, 1605, __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 = __pyx_convert_vector_from_py_Py_ssize_t(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1605, __pyx_L3_error)
    __pyx_v_strides = __pyx_convert_vector_from_py_Py_ssize_t(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1606, __pyx_L3_error)
    __pyx_v_update_c_contiguity = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_update_c_contiguity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1607, __pyx_L3_error)
    __pyx_v_update_f_contiguity = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_update_f_contiguity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1608, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_set_shape_and_strides", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1605, __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_218_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, __pyx_v_update_f_contiguity);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_218_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, int __pyx_v_update_f_contiguity) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_set_shape_and_strides", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray__set_shape_and_strides(__pyx_v_self, __pyx_v_shape, __pyx_v_strides, __pyx_v_update_c_contiguity, __pyx_v_update_f_contiguity, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1605, __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":1619
 *             self._update_f_contiguity()
 * 
 *     cdef ndarray _view(self, const vector.vector[Py_ssize_t]& shape,             # <<<<<<<<<<<<<<
 *                        const vector.vector[Py_ssize_t]& strides,
 *                        bint update_c_contiguity,
 */

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, std::vector<Py_ssize_t>  const &__pyx_v_shape, std::vector<Py_ssize_t>  const &__pyx_v_strides, int __pyx_v_update_c_contiguity, int __pyx_v_update_f_contiguity) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_v = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("_view", 0);

  /* "cupy/core/core.pyx":1624
 *                        bint update_f_contiguity):
 *         cdef ndarray v
 *         v = ndarray.__new__(ndarray)             # <<<<<<<<<<<<<<
 *         v.data = self.data
 *         v.base = self.base if self.base is not None else self
 */
  __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, 1624, __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":1625
 *         cdef ndarray v
 *         v = ndarray.__new__(ndarray)
 *         v.data = self.data             # <<<<<<<<<<<<<<
 *         v.base = self.base if self.base is not None else self
 *         v.dtype = self.dtype
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->data);
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __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_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1626
 *         v = ndarray.__new__(ndarray)
 *         v.data = self.data
 *         v.base = self.base if self.base is not None else self             # <<<<<<<<<<<<<<
 *         v.dtype = self.dtype
 *         v._c_contiguous = self._c_contiguous
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_self->base) != Py_None);
  if ((__pyx_t_2 != 0)) {
    __Pyx_INCREF(((PyObject *)__pyx_v_self->base));
    __pyx_t_1 = ((PyObject *)__pyx_v_self->base);
  } else {
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_t_1 = ((PyObject *)__pyx_v_self);
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __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_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1627
 *         v.data = self.data
 *         v.base = self.base if self.base is not None else self
 *         v.dtype = self.dtype             # <<<<<<<<<<<<<<
 *         v._c_contiguous = self._c_contiguous
 *         v._f_contiguous = self._f_contiguous
 */
  __pyx_t_1 = __pyx_v_self->dtype;
  __Pyx_INCREF(__pyx_t_1);
  __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":1628
 *         v.base = self.base if self.base is not None else self
 *         v.dtype = self.dtype
 *         v._c_contiguous = self._c_contiguous             # <<<<<<<<<<<<<<
 *         v._f_contiguous = self._f_contiguous
 *         v._set_shape_and_strides(
 */
  __pyx_t_2 = __pyx_v_self->_c_contiguous;
  __pyx_v_v->_c_contiguous = __pyx_t_2;

  /* "cupy/core/core.pyx":1629
 *         v.dtype = self.dtype
 *         v._c_contiguous = self._c_contiguous
 *         v._f_contiguous = self._f_contiguous             # <<<<<<<<<<<<<<
 *         v._set_shape_and_strides(
 *             shape, strides, update_c_contiguity, update_f_contiguity)
 */
  __pyx_t_2 = __pyx_v_self->_f_contiguous;
  __pyx_v_v->_f_contiguous = __pyx_t_2;

  /* "cupy/core/core.pyx":1630
 *         v._c_contiguous = self._c_contiguous
 *         v._f_contiguous = self._f_contiguous
 *         v._set_shape_and_strides(             # <<<<<<<<<<<<<<
 *             shape, strides, update_c_contiguity, update_f_contiguity)
 *         return v
 */
  __pyx_t_1 = ((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, __pyx_v_update_c_contiguity, __pyx_v_update_f_contiguity, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1632
 *         v._set_shape_and_strides(
 *             shape, strides, update_c_contiguity, update_f_contiguity)
 *         return v             # <<<<<<<<<<<<<<
 * 
 *     cpdef _set_contiguous_strides(
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_v));
  __pyx_r = __pyx_v_v;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1619
 *             self._update_f_contiguity()
 * 
 *     cdef ndarray _view(self, const vector.vector[Py_ssize_t]& shape,             # <<<<<<<<<<<<<<
 *                        const vector.vector[Py_ssize_t]& strides,
 *                        bint update_c_contiguity,
 */

  /* 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 = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_v);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1634
 *         return v
 * 
 *     cpdef _set_contiguous_strides(             # <<<<<<<<<<<<<<
 *             self, Py_ssize_t itemsize, bint is_c_contiguous):
 *         self.size = internal.get_contiguous_strides_inplace(
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_221_set_contiguous_strides(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray__set_contiguous_strides(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, Py_ssize_t __pyx_v_itemsize, int __pyx_v_is_c_contiguous, 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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("_set_contiguous_strides", 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_set_contiguous_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1634, __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_221_set_contiguous_strides)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_is_c_contiguous); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1634, __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, 1634, __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, 1634, __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, 1634, __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, 1634, __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;
      __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":1636
 *     cpdef _set_contiguous_strides(
 *             self, Py_ssize_t itemsize, bint is_c_contiguous):
 *         self.size = internal.get_contiguous_strides_inplace(             # <<<<<<<<<<<<<<
 *             self._shape, self._strides, itemsize, is_c_contiguous)
 *         if is_c_contiguous:
 */
  __pyx_v_self->size = __pyx_f_4cupy_4core_8internal_get_contiguous_strides_inplace(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_itemsize, __pyx_v_is_c_contiguous);

  /* "cupy/core/core.pyx":1638
 *         self.size = internal.get_contiguous_strides_inplace(
 *             self._shape, self._strides, itemsize, is_c_contiguous)
 *         if is_c_contiguous:             # <<<<<<<<<<<<<<
 *             self._c_contiguous = True
 *             self._update_f_contiguity()
 */
  __pyx_t_9 = (__pyx_v_is_c_contiguous != 0);
  if (__pyx_t_9) {

    /* "cupy/core/core.pyx":1639
 *             self._shape, self._strides, itemsize, is_c_contiguous)
 *         if is_c_contiguous:
 *             self._c_contiguous = True             # <<<<<<<<<<<<<<
 *             self._update_f_contiguity()
 *         else:
 */
    __pyx_v_self->_c_contiguous = 1;

    /* "cupy/core/core.pyx":1640
 *         if is_c_contiguous:
 *             self._c_contiguous = True
 *             self._update_f_contiguity()             # <<<<<<<<<<<<<<
 *         else:
 *             self._f_contiguous = True
 */
    __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, 1640, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1638
 *         self.size = internal.get_contiguous_strides_inplace(
 *             self._shape, self._strides, itemsize, is_c_contiguous)
 *         if is_c_contiguous:             # <<<<<<<<<<<<<<
 *             self._c_contiguous = True
 *             self._update_f_contiguity()
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1642
 *             self._update_f_contiguity()
 *         else:
 *             self._f_contiguous = True             # <<<<<<<<<<<<<<
 *             self._update_c_contiguity()
 * 
 */
  /*else*/ {
    __pyx_v_self->_f_contiguous = 1;

    /* "cupy/core/core.pyx":1643
 *         else:
 *             self._f_contiguous = True
 *             self._update_c_contiguity()             # <<<<<<<<<<<<<<
 * 
 *     cdef function.CPointer get_pointer(self):
 */
    __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, 1643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1634
 *         return v
 * 
 *     cpdef _set_contiguous_strides(             # <<<<<<<<<<<<<<
 *             self, Py_ssize_t itemsize, bint is_c_contiguous):
 *         self.size = internal.get_contiguous_strides_inplace(
 */

  /* 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_8);
  __Pyx_AddTraceback("cupy.core.core.ndarray._set_contiguous_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_221_set_contiguous_strides(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_220_set_contiguous_strides[] = "ndarray._set_contiguous_strides(self, Py_ssize_t itemsize, bool is_c_contiguous)";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_221_set_contiguous_strides(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  Py_ssize_t __pyx_v_itemsize;
  int __pyx_v_is_c_contiguous;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_set_contiguous_strides (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_itemsize,&__pyx_n_s_is_c_contiguous,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_itemsize)) != 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_c_contiguous)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_set_contiguous_strides", 1, 2, 2, 1); __PYX_ERR(0, 1634, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_set_contiguous_strides") < 0)) __PYX_ERR(0, 1634, __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_itemsize = __Pyx_PyIndex_AsSsize_t(values[0]); if (unlikely((__pyx_v_itemsize == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1635, __pyx_L3_error)
    __pyx_v_is_c_contiguous = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_is_c_contiguous == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1635, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_set_contiguous_strides", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1634, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core.ndarray._set_contiguous_strides", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_220_set_contiguous_strides(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), __pyx_v_itemsize, __pyx_v_is_c_contiguous);

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_220_set_contiguous_strides(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, Py_ssize_t __pyx_v_itemsize, int __pyx_v_is_c_contiguous) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_set_contiguous_strides", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray__set_contiguous_strides(__pyx_v_self, __pyx_v_itemsize, __pyx_v_is_c_contiguous, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1634, __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_contiguous_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":1645
 *             self._update_c_contiguity()
 * 
 *     cdef function.CPointer get_pointer(self):             # <<<<<<<<<<<<<<
 *         return _CArray_from_ndarray(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":1646
 * 
 *     cdef function.CPointer get_pointer(self):
 *         return _CArray_from_ndarray(self)             # <<<<<<<<<<<<<<
 * 
 *     cpdef object toDlpack(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__CArray_from_ndarray(__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1646, __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":1645
 *             self._update_c_contiguity()
 * 
 *     cdef function.CPointer get_pointer(self):             # <<<<<<<<<<<<<<
 *         return _CArray_from_ndarray(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.pyx":1648
 *         return _CArray_from_ndarray(self)
 * 
 *     cpdef object toDlpack(self):             # <<<<<<<<<<<<<<
 *         """Zero-copy conversion to a DLPack tensor.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_223toDlpack(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4core_4core_7ndarray_toDlpack(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("toDlpack", 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_toDlpack); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1648, __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_223toDlpack)) {
      __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, 1648, __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, 1648, __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":1679
 * 
 *         """
 *         return dlpack.toDlpack(self)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  try {
    __pyx_t_1 = __pyx_f_4cupy_4core_6dlpack_toDlpack(__pyx_v_self, 0);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 1679, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1648
 *         return _CArray_from_ndarray(self)
 * 
 *     cpdef object toDlpack(self):             # <<<<<<<<<<<<<<
 *         """Zero-copy conversion to a DLPack tensor.
 * 
 */

  /* 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.toDlpack", __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_223toDlpack(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_222toDlpack[] = "ndarray.toDlpack(self)\nZero-copy conversion to a DLPack tensor.\n\n        DLPack is a open in memory tensor structure proposed in this\n        repository: `dmlc/dlpack <https://github.com/dmlc/dlpack>`_.\n\n        This function returns a :class:`PyCapsule` object which contains a\n        pointer to a DLPack tensor converted from the own ndarray. This\n        function does not copy the own data to the output DLpack tensor\n        but it shares the pointer which is pointing to the same memory region\n        for the data.\n\n        Returns:\n            dltensor (:class:`PyCapsule`): Output DLPack tensor which is\n                encapsulated in a :class:`PyCapsule` object.\n\n        .. seealso::\n\n            :meth:`~cupy.fromDlpack` is a method for zero-copy conversion from\n            a DLPack tensor (which is encapsulated in a :class:`PyCapsule`\n            object) to a :class:`ndarray`\n\n        .. admonition:: Example\n\n            >>> import cupy\n            >>> array1 = cupy.array([0, 1, 2], dtype=cupy.float32)\n            >>> dltensor = array1.toDlpack()\n            >>> array2 = cupy.fromDlpack(dltensor)\n            >>> cupy.testing.assert_array_equal(array1, array2)\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_223toDlpack(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("toDlpack (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_222toDlpack(((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_222toDlpack(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("toDlpack", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4core_4core_7ndarray_toDlpack(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1648, __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.toDlpack", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__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(1, 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(1, 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(1, 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(1, 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(1, 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(1, 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(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.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
 *         # TODO(niboshi): Return arbitrary owner object as `base` if the
 */

/* 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             # <<<<<<<<<<<<<<
 *         # TODO(niboshi): Return arbitrary owner object as `base` if the
 *         # underlying memory is UnownedMemory.
 */

/* 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":19
 *         # TODO(niboshi): Return arbitrary owner object as `base` if the
 *         # underlying memory is UnownedMemory.
 *         readonly ndarray base             # <<<<<<<<<<<<<<
 * 
 *     cdef _init_fast(self, const vector.vector[Py_ssize_t]& shape, dtype,
 */

/* 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":1682
 * 
 * 
 * cdef inline _carray.CArray _CArray_from_ndarray(ndarray arr):             # <<<<<<<<<<<<<<
 *     # Creates CArray from ndarray.
 *     # Note that this function cannot be defined in _carray.pxd because that
 */

static CYTHON_INLINE struct __pyx_obj_4cupy_4core_7_carray_CArray *__pyx_f_4cupy_4core_4core__CArray_from_ndarray(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr) {
  struct __pyx_obj_4cupy_4core_7_carray_CArray *__pyx_v_carr = 0;
  struct __pyx_obj_4cupy_4core_7_carray_CArray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_CArray_from_ndarray", 0);

  /* "cupy/core/core.pyx":1686
 *     # Note that this function cannot be defined in _carray.pxd because that
 *     # would cause cyclic cimport dependencies.
 *     cdef _carray.CArray carr = _carray.CArray.__new__(_carray.CArray)             # <<<<<<<<<<<<<<
 *     carr.init(<void*>arr.data.ptr, arr.size, arr._shape, arr._strides)
 *     return carr
 */
  __pyx_t_1 = __Pyx_tp_new(((PyObject *)__pyx_ptype_4cupy_4core_7_carray_CArray), __pyx_empty_tuple); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_7_carray_CArray)))) __PYX_ERR(0, 1686, __pyx_L1_error)
  __pyx_v_carr = ((struct __pyx_obj_4cupy_4core_7_carray_CArray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1687
 *     # would cause cyclic cimport dependencies.
 *     cdef _carray.CArray carr = _carray.CArray.__new__(_carray.CArray)
 *     carr.init(<void*>arr.data.ptr, arr.size, arr._shape, arr._strides)             # <<<<<<<<<<<<<<
 *     return carr
 * 
 */
  ((struct __pyx_vtabstruct_4cupy_4core_7_carray_CArray *)__pyx_v_carr->__pyx_vtab)->init(__pyx_v_carr, ((void *)__pyx_v_arr->data->ptr), __pyx_v_arr->size, __pyx_v_arr->_shape, __pyx_v_arr->_strides);

  /* "cupy/core/core.pyx":1688
 *     cdef _carray.CArray carr = _carray.CArray.__new__(_carray.CArray)
 *     carr.init(<void*>arr.data.ptr, arr.size, arr._shape, arr._strides)
 *     return carr             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_carr));
  __pyx_r = __pyx_v_carr;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1682
 * 
 * 
 * cdef inline _carray.CArray _CArray_from_ndarray(ndarray arr):             # <<<<<<<<<<<<<<
 *     # Creates CArray from ndarray.
 *     # Note that this function cannot be defined in _carray.pxd because that
 */

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

/* "cupy/core/core.pyx":1691
 * 
 * 
 * cpdef int _update_order_char(ndarray x, int order_char):             # <<<<<<<<<<<<<<
 *     # update order_char based on array contiguity
 *     if order_char == b'A':
 */

static PyObject *__pyx_pw_4cupy_4core_4core_1_update_order_char(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_4cupy_4core_4core__update_order_char(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, int __pyx_v_order_char, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_update_order_char", 0);

  /* "cupy/core/core.pyx":1693
 * cpdef int _update_order_char(ndarray x, int order_char):
 *     # update order_char based on array contiguity
 *     if order_char == b'A':             # <<<<<<<<<<<<<<
 *         if x._f_contiguous:
 *             order_char = b'F'
 */
  switch (__pyx_v_order_char) {
    case 'A':

    /* "cupy/core/core.pyx":1694
 *     # update order_char based on array contiguity
 *     if order_char == b'A':
 *         if x._f_contiguous:             # <<<<<<<<<<<<<<
 *             order_char = b'F'
 *         else:
 */
    __pyx_t_1 = (__pyx_v_x->_f_contiguous != 0);
    if (__pyx_t_1) {

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

      /* "cupy/core/core.pyx":1694
 *     # update order_char based on array contiguity
 *     if order_char == b'A':
 *         if x._f_contiguous:             # <<<<<<<<<<<<<<
 *             order_char = b'F'
 *         else:
 */
      goto __pyx_L3;
    }

    /* "cupy/core/core.pyx":1697
 *             order_char = b'F'
 *         else:
 *             order_char = b'C'             # <<<<<<<<<<<<<<
 *     elif order_char == b'K':
 *         if x._f_contiguous:
 */
    /*else*/ {
      __pyx_v_order_char = 'C';
    }
    __pyx_L3:;

    /* "cupy/core/core.pyx":1693
 * cpdef int _update_order_char(ndarray x, int order_char):
 *     # update order_char based on array contiguity
 *     if order_char == b'A':             # <<<<<<<<<<<<<<
 *         if x._f_contiguous:
 *             order_char = b'F'
 */
    break;

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

    /* "cupy/core/core.pyx":1699
 *             order_char = b'C'
 *     elif order_char == b'K':
 *         if x._f_contiguous:             # <<<<<<<<<<<<<<
 *             order_char = b'F'
 *         elif x._c_contiguous:
 */
    __pyx_t_1 = (__pyx_v_x->_f_contiguous != 0);
    if (__pyx_t_1) {

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

      /* "cupy/core/core.pyx":1699
 *             order_char = b'C'
 *     elif order_char == b'K':
 *         if x._f_contiguous:             # <<<<<<<<<<<<<<
 *             order_char = b'F'
 *         elif x._c_contiguous:
 */
      goto __pyx_L4;
    }

    /* "cupy/core/core.pyx":1701
 *         if x._f_contiguous:
 *             order_char = b'F'
 *         elif x._c_contiguous:             # <<<<<<<<<<<<<<
 *             order_char = b'C'
 *     return order_char
 */
    __pyx_t_1 = (__pyx_v_x->_c_contiguous != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1702
 *             order_char = b'F'
 *         elif x._c_contiguous:
 *             order_char = b'C'             # <<<<<<<<<<<<<<
 *     return order_char
 * 
 */
      __pyx_v_order_char = 'C';

      /* "cupy/core/core.pyx":1701
 *         if x._f_contiguous:
 *             order_char = b'F'
 *         elif x._c_contiguous:             # <<<<<<<<<<<<<<
 *             order_char = b'C'
 *     return order_char
 */
    }
    __pyx_L4:;

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

  /* "cupy/core/core.pyx":1703
 *         elif x._c_contiguous:
 *             order_char = b'C'
 *     return order_char             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_order_char;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1691
 * 
 * 
 * cpdef int _update_order_char(ndarray x, int order_char):             # <<<<<<<<<<<<<<
 *     # update order_char based on array contiguity
 *     if order_char == b'A':
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_1_update_order_char(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core__update_order_char[] = "_update_order_char(ndarray x, int order_char) -> int";
static PyObject *__pyx_pw_4cupy_4core_4core_1_update_order_char(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  int __pyx_v_order_char;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_update_order_char (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_order_char,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_x)) != 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_order_char)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_update_order_char", 1, 2, 2, 1); __PYX_ERR(0, 1691, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_update_order_char") < 0)) __PYX_ERR(0, 1691, __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_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_order_char = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_order_char == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1691, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_update_order_char", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1691, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._update_order_char", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1691, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core__update_order_char(__pyx_self, __pyx_v_x, __pyx_v_order_char);

  /* 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__update_order_char(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, int __pyx_v_order_char) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_update_order_char", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_4cupy_4core_4core__update_order_char(__pyx_v_x, __pyx_v_order_char, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1691, __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._update_order_char", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1706
 * 
 * 
 * cpdef vector.vector[Py_ssize_t] _get_strides_for_order_K(ndarray x, dtype,             # <<<<<<<<<<<<<<
 *                                                          shape=None):
 *     cdef vector.vector[Py_ssize_t] strides
 */

static PyObject *__pyx_pw_4cupy_4core_4core_3_get_strides_for_order_K(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static std::vector<Py_ssize_t>  __pyx_f_4cupy_4core_4core__get_strides_for_order_K(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, PyObject *__pyx_v_dtype, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core__get_strides_for_order_K *__pyx_optional_args) {

  /* "cupy/core/core.pyx":1707
 * 
 * cpdef vector.vector[Py_ssize_t] _get_strides_for_order_K(ndarray x, dtype,
 *                                                          shape=None):             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] strides
 *     # strides used when order='K' for astype, empty_like, etc.
 */
  PyObject *__pyx_v_shape = ((PyObject *)Py_None);
  std::vector<Py_ssize_t>  __pyx_v_strides;
  PyObject *__pyx_v_stride_and_index = NULL;
  PyObject *__pyx_v_stride = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_8genexpr2__pyx_v_i = NULL;
  PyObject *__pyx_8genexpr2__pyx_v_s = 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;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  std::vector<Py_ssize_t> ::size_type __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  Py_ssize_t __pyx_t_12;
  std::vector<Py_ssize_t> ::size_type __pyx_t_13;
  int __pyx_t_14;
  __Pyx_RefNannySetupContext("_get_strides_for_order_K", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_shape = __pyx_optional_args->shape;
    }
  }

  /* "cupy/core/core.pyx":1710
 *     cdef vector.vector[Py_ssize_t] strides
 *     # strides used when order='K' for astype, empty_like, etc.
 *     stride_and_index = [             # <<<<<<<<<<<<<<
 *         (abs(s), -i) for i, s in enumerate(x.strides)]
 *     stride_and_index.sort()
 */
  { /* enter inner scope */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1710, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_2 = __pyx_int_0;

    /* "cupy/core/core.pyx":1711
 *     # strides used when order='K' for astype, empty_like, etc.
 *     stride_and_index = [
 *         (abs(s), -i) for i, s in enumerate(x.strides)]             # <<<<<<<<<<<<<<
 *     stride_and_index.sort()
 *     strides.resize(x.ndim)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_strides); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1711, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_3);
    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_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1711, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1711, __pyx_L5_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_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(0, 1711, __pyx_L5_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1711, __pyx_L5_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(0, 1711, __pyx_L5_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1711, __pyx_L5_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, 1711, __pyx_L5_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_s, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_i, __pyx_t_2);
      __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1711, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2);
      __pyx_t_2 = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":1710
 *     cdef vector.vector[Py_ssize_t] strides
 *     # strides used when order='K' for astype, empty_like, etc.
 *     stride_and_index = [             # <<<<<<<<<<<<<<
 *         (abs(s), -i) for i, s in enumerate(x.strides)]
 *     stride_and_index.sort()
 */
      __pyx_t_3 = __Pyx_PyNumber_Absolute(__pyx_8genexpr2__pyx_v_s); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1711, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "cupy/core/core.pyx":1711
 *     # strides used when order='K' for astype, empty_like, etc.
 *     stride_and_index = [
 *         (abs(s), -i) for i, s in enumerate(x.strides)]             # <<<<<<<<<<<<<<
 *     stride_and_index.sort()
 *     strides.resize(x.ndim)
 */
      __pyx_t_7 = PyNumber_Negative(__pyx_8genexpr2__pyx_v_i); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1711, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1711, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
      __pyx_t_3 = 0;
      __pyx_t_7 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 1710, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_i); __pyx_8genexpr2__pyx_v_i = 0;
    __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_s); __pyx_8genexpr2__pyx_v_s = 0;
    goto __pyx_L8_exit_scope;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_i); __pyx_8genexpr2__pyx_v_i = 0;
    __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_s); __pyx_8genexpr2__pyx_v_s = 0;
    goto __pyx_L1_error;
    __pyx_L8_exit_scope:;
  } /* exit inner scope */
  __pyx_v_stride_and_index = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

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

  /* "cupy/core/core.pyx":1713
 *         (abs(s), -i) for i, s in enumerate(x.strides)]
 *     stride_and_index.sort()
 *     strides.resize(x.ndim)             # <<<<<<<<<<<<<<
 *     stride = dtype.itemsize
 *     for s, i in stride_and_index:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1713, __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, 1713, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  try {
    __pyx_v_strides.resize(__pyx_t_10);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 1713, __pyx_L1_error)
  }

  /* "cupy/core/core.pyx":1714
 *     stride_and_index.sort()
 *     strides.resize(x.ndim)
 *     stride = dtype.itemsize             # <<<<<<<<<<<<<<
 *     for s, i in stride_and_index:
 *         strides[-i] = stride
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1714, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_stride = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1715
 *     strides.resize(x.ndim)
 *     stride = dtype.itemsize
 *     for s, i in stride_and_index:             # <<<<<<<<<<<<<<
 *         strides[-i] = stride
 *         stride *= shape[-i] if shape else x.shape[-i]
 */
  __pyx_t_1 = __pyx_v_stride_and_index; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
  for (;;) {
    if (__pyx_t_5 >= 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_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1715, __pyx_L1_error)
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1715, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    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(0, 1715, __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(0, 1715, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1715, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      #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(0, 1715, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_11 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_4 = __pyx_t_11(__pyx_t_7); if (unlikely(!__pyx_t_4)) goto __pyx_L11_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      index = 1; __pyx_t_8 = __pyx_t_11(__pyx_t_7); if (unlikely(!__pyx_t_8)) goto __pyx_L11_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_8);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_7), 2) < 0) __PYX_ERR(0, 1715, __pyx_L1_error)
      __pyx_t_11 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L12_unpacking_done;
      __pyx_L11_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_11 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 1715, __pyx_L1_error)
      __pyx_L12_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":1716
 *     stride = dtype.itemsize
 *     for s, i in stride_and_index:
 *         strides[-i] = stride             # <<<<<<<<<<<<<<
 *         stride *= shape[-i] if shape else x.shape[-i]
 *     return strides
 */
    __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_v_stride); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1716, __pyx_L1_error)
    __pyx_t_2 = PyNumber_Negative(__pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1716, __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, 1716, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    (__pyx_v_strides[__pyx_t_13]) = __pyx_t_12;

    /* "cupy/core/core.pyx":1717
 *     for s, i in stride_and_index:
 *         strides[-i] = stride
 *         stride *= shape[-i] if shape else x.shape[-i]             # <<<<<<<<<<<<<<
 *     return strides
 * 
 */
    __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_v_shape); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 1717, __pyx_L1_error)
    if (__pyx_t_14) {
      __pyx_t_8 = PyNumber_Negative(__pyx_v_i); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_shape, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_2 = __pyx_t_4;
      __pyx_t_4 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = PyNumber_Negative(__pyx_v_i); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_2 = __pyx_t_7;
      __pyx_t_7 = 0;
    }
    __pyx_t_7 = PyNumber_InPlaceMultiply(__pyx_v_stride, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1717, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_stride, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":1715
 *     strides.resize(x.ndim)
 *     stride = dtype.itemsize
 *     for s, i in stride_and_index:             # <<<<<<<<<<<<<<
 *         strides[-i] = stride
 *         stride *= shape[-i] if shape else x.shape[-i]
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1718
 *         strides[-i] = stride
 *         stride *= shape[-i] if shape else x.shape[-i]
 *     return strides             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_strides;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1706
 * 
 * 
 * cpdef vector.vector[Py_ssize_t] _get_strides_for_order_K(ndarray x, dtype,             # <<<<<<<<<<<<<<
 *                                                          shape=None):
 *     cdef vector.vector[Py_ssize_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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_WriteUnraisable("cupy.core.core._get_strides_for_order_K", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_stride_and_index);
  __Pyx_XDECREF(__pyx_v_stride);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_i);
  __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_s);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_3_get_strides_for_order_K(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_2_get_strides_for_order_K[] = "_get_strides_for_order_K(ndarray x, dtype, shape=None) -> vector[Py_ssize_t]";
static PyObject *__pyx_pw_4cupy_4core_4core_3_get_strides_for_order_K(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_strides_for_order_K (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_dtype,&__pyx_n_s_shape,0};
    PyObject* values[3] = {0,0,0};

    /* "cupy/core/core.pyx":1707
 * 
 * cpdef vector.vector[Py_ssize_t] _get_strides_for_order_K(ndarray x, dtype,
 *                                                          shape=None):             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] strides
 *     # strides used when order='K' for astype, empty_like, etc.
 */
    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_x)) != 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_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_strides_for_order_K", 0, 2, 3, 1); __PYX_ERR(0, 1706, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_strides_for_order_K") < 0)) __PYX_ERR(0, 1706, __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_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_dtype = values[1];
    __pyx_v_shape = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_strides_for_order_K", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1706, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.core.core._get_strides_for_order_K", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1706, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_2_get_strides_for_order_K(__pyx_self, __pyx_v_x, __pyx_v_dtype, __pyx_v_shape);

  /* "cupy/core/core.pyx":1706
 * 
 * 
 * cpdef vector.vector[Py_ssize_t] _get_strides_for_order_K(ndarray x, dtype,             # <<<<<<<<<<<<<<
 *                                                          shape=None):
 *     cdef vector.vector[Py_ssize_t] strides
 */

  /* 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_2_get_strides_for_order_K(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, PyObject *__pyx_v_dtype, PyObject *__pyx_v_shape) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  std::vector<Py_ssize_t>  __pyx_t_1;
  struct __pyx_opt_args_4cupy_4core_4core__get_strides_for_order_K __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_get_strides_for_order_K", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.shape = __pyx_v_shape;
  __pyx_t_1 = __pyx_f_4cupy_4core_4core__get_strides_for_order_K(__pyx_v_x, __pyx_v_dtype, 0, &__pyx_t_2); 
  __pyx_t_3 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1706, __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._get_strides_for_order_K", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1766
 * 
 * 
 * cpdef str _get_header_dir_path():             # <<<<<<<<<<<<<<
 *     global _header_path_cache
 *     if _header_path_cache is None:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_5_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/core.pyx":1768
 * 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/core.pyx":1770
 *     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(0, 1770, __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(0, 1770, __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(0, 1770, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1771
 *         # 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(0, 1771, __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(0, 1771, __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(0, 1771, __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(0, 1771, __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(0, 1771, __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(0, 1771, __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(0, 1771, __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(0, 1771, __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(0, 1771, __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(0, 1771, __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(0, 1771, __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(0, 1771, __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_u_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(0, 1771, __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_u_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(0, 1771, __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(0, 1771, __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_u_include);
      __Pyx_GIVEREF(__pyx_n_u_include);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_12, __pyx_n_u_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(0, 1771, __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(0, 1770, __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, 1770, __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, 1770, __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(0, 1770, __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(0, 1770, __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/core.pyx":1770
 *     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(PyUnicode_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 1770, __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/core.pyx":1768
 * 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/core.pyx":1772
 *         _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/core.pyx":1766
 * 
 * 
 * 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_5_get_header_dir_path(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_4_get_header_dir_path[] = "_get_header_dir_path() -> unicode";
static PyObject *__pyx_pw_4cupy_4core_4core_5_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_4_get_header_dir_path(__pyx_self);

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

static PyObject *__pyx_pf_4cupy_4core_4core_4_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(0, 1766, __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/core.pyx":1775
 * 
 * 
 * cpdef str _get_header_source():             # <<<<<<<<<<<<<<
 *     global _header_source
 *     if _header_source is None:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7_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/core.pyx":1777
 * 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/core.pyx":1778
 *     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(0, 1778, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_source = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1779
 *     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(0, 1779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_base_path = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1780
 *         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(0, 1780, __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(0, 1780, __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(0, 1780, __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/core.pyx":1781
 *         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(0, 1781, __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(0, 1781, __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(0, 1781, __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(0, 1781, __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(0, 1781, __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(0, 1781, __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(0, 1781, __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/core.pyx":1782
 *         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(0, 1782, __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(0, 1782, __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(0, 1782, __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(0, 1782, __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(0, 1782, __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/core.pyx":1783
 *             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(0, 1783, __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(0, 1783, __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(0, 1783, __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(0, 1783, __pyx_L12_error)
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

              /* "cupy/core/core.pyx":1782
 *         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(0, 1782, __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(0, 1782, __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(0, 1782, __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(0, 1782, __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(0, 1782, __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__34, NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1782, __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/core.pyx":1780
 *         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/core.pyx":1784
 *             with open(header_path) as header_file:
 *                 source.append(header_file.read())
 *         _header_source = '\n'.join(source)             # <<<<<<<<<<<<<<
 *     return _header_source
 * 
 */
    __pyx_t_4 = PyUnicode_Join(__pyx_kp_u__35, __pyx_v_source); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1784, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __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/core.pyx":1777
 * cpdef str _get_header_source():
 *     global _header_source
 *     if _header_source is None:             # <<<<<<<<<<<<<<
 *         source = []
 *         base_path = _get_header_dir_path()
 */
  }

  /* "cupy/core/core.pyx":1785
 *                 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/core.pyx":1775
 * 
 * 
 * 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_7_get_header_source(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_6_get_header_source[] = "_get_header_source() -> unicode";
static PyObject *__pyx_pw_4cupy_4core_4core_7_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_6_get_header_source(__pyx_self);

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

static PyObject *__pyx_pf_4cupy_4core_4core_6_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(0, 1775, __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/core.pyx":1793
 * 
 * 
 * cdef inline str _translate_cucomplex_to_thrust(str source):             # <<<<<<<<<<<<<<
 *     lines = []
 *     for line in source.splitlines(keepends=True):
 */

static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__translate_cucomplex_to_thrust(PyObject *__pyx_v_source) {
  PyObject *__pyx_v_lines = NULL;
  PyObject *__pyx_v_line = 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;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("_translate_cucomplex_to_thrust", 0);

  /* "cupy/core/core.pyx":1794
 * 
 * cdef inline str _translate_cucomplex_to_thrust(str source):
 *     lines = []             # <<<<<<<<<<<<<<
 *     for line in source.splitlines(keepends=True):
 *         if _cucomplex_include_pattern.match(line):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1794, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_lines = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1795
 * cdef inline str _translate_cucomplex_to_thrust(str source):
 *     lines = []
 *     for line in source.splitlines(keepends=True):             # <<<<<<<<<<<<<<
 *         if _cucomplex_include_pattern.match(line):
 *             lines += '#include <cupy/cuComplex_bridge.h>  '\
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_source, __pyx_n_s_splitlines); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1795, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1795, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepends, Py_True) < 0) __PYX_ERR(0, 1795, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1795, __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(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(0, 1795, __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(0, 1795, __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(0, 1795, __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(0, 1795, __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(0, 1795, __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(0, 1795, __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(0, 1795, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_line, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1796
 *     lines = []
 *     for line in source.splitlines(keepends=True):
 *         if _cucomplex_include_pattern.match(line):             # <<<<<<<<<<<<<<
 *             lines += '#include <cupy/cuComplex_bridge.h>  '\
 *                      '// translate_cucomplex\n'
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cucomplex_include_pattern); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1796, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_match); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1796, __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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_line); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1796, __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_1, __pyx_v_line};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1796, __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_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_line};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1796, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1796, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __pyx_t_1 = NULL;
        __Pyx_INCREF(__pyx_v_line);
        __Pyx_GIVEREF(__pyx_v_line);
        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_line);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1796, __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;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1796, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1797
 *     for line in source.splitlines(keepends=True):
 *         if _cucomplex_include_pattern.match(line):
 *             lines += '#include <cupy/cuComplex_bridge.h>  '\             # <<<<<<<<<<<<<<
 *                      '// translate_cucomplex\n'
 *         else:
 */
      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_lines, __pyx_kp_u_include_cupy_cuComplex_bridge_h); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1797, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_lines, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":1796
 *     lines = []
 *     for line in source.splitlines(keepends=True):
 *         if _cucomplex_include_pattern.match(line):             # <<<<<<<<<<<<<<
 *             lines += '#include <cupy/cuComplex_bridge.h>  '\
 *                      '// translate_cucomplex\n'
 */
      goto __pyx_L5;
    }

    /* "cupy/core/core.pyx":1800
 *                      '// translate_cucomplex\n'
 *         else:
 *             lines += line             # <<<<<<<<<<<<<<
 *     return ''.join(lines)
 * 
 */
    /*else*/ {
      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_lines, __pyx_v_line); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1800, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_lines, __pyx_t_3);
      __pyx_t_3 = 0;
    }
    __pyx_L5:;

    /* "cupy/core/core.pyx":1795
 * cdef inline str _translate_cucomplex_to_thrust(str source):
 *     lines = []
 *     for line in source.splitlines(keepends=True):             # <<<<<<<<<<<<<<
 *         if _cucomplex_include_pattern.match(line):
 *             lines += '#include <cupy/cuComplex_bridge.h>  '\
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":1801
 *         else:
 *             lines += line
 *     return ''.join(lines)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyUnicode_Join(__pyx_kp_u__6, __pyx_v_lines); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1793
 * 
 * 
 * cdef inline str _translate_cucomplex_to_thrust(str source):             # <<<<<<<<<<<<<<
 *     lines = []
 *     for line in source.splitlines(keepends=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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.core.core._translate_cucomplex_to_thrust", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_lines);
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":1804
 * 
 * 
 * cpdef function.Module compile_with_cache(             # <<<<<<<<<<<<<<
 *         str source, tuple options=(), arch=None, cachd_dir=None,
 *         prepend_cupy_headers=True, backend='nvrtc', translate_cucomplex=False,
 */

static PyObject *__pyx_pw_4cupy_4core_4core_9compile_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/core.pyx":1805
 * 
 * cpdef function.Module compile_with_cache(
 *         str source, tuple options=(), arch=None, cachd_dir=None,             # <<<<<<<<<<<<<<
 *         prepend_cupy_headers=True, backend='nvrtc', translate_cucomplex=False,
 *         enable_cooperative_groups=False):
 */
  PyObject *__pyx_v_options = ((PyObject*)__pyx_empty_tuple);
  PyObject *__pyx_v_arch = ((PyObject *)Py_None);
  PyObject *__pyx_v_cachd_dir = ((PyObject *)Py_None);

  /* "cupy/core/core.pyx":1806
 * cpdef function.Module compile_with_cache(
 *         str source, tuple options=(), arch=None, cachd_dir=None,
 *         prepend_cupy_headers=True, backend='nvrtc', translate_cucomplex=False,             # <<<<<<<<<<<<<<
 *         enable_cooperative_groups=False):
 *     if translate_cucomplex:
 */
  PyObject *__pyx_v_prepend_cupy_headers = ((PyObject *)Py_True);
  PyObject *__pyx_v_backend = ((PyObject *)__pyx_n_u_nvrtc);
  PyObject *__pyx_v_translate_cucomplex = ((PyObject *)Py_False);

  /* "cupy/core/core.pyx":1807
 *         str source, tuple options=(), arch=None, cachd_dir=None,
 *         prepend_cupy_headers=True, backend='nvrtc', translate_cucomplex=False,
 *         enable_cooperative_groups=False):             # <<<<<<<<<<<<<<
 *     if translate_cucomplex:
 *         source = _translate_cucomplex_to_thrust(source)
 */
  PyObject *__pyx_v_enable_cooperative_groups = ((PyObject *)Py_False);
  PyObject *__pyx_v_extra_source = NULL;
  PyObject *__pyx_v_bundled_include = NULL;
  PyObject *__pyx_v_cuda_path = NULL;
  struct __pyx_obj_4cupy_4cuda_8function_Module *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = 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;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_prepend_cupy_headers = __pyx_optional_args->prepend_cupy_headers;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_backend = __pyx_optional_args->backend;
              if (__pyx_optional_args->__pyx_n > 5) {
                __pyx_v_translate_cucomplex = __pyx_optional_args->translate_cucomplex;
                if (__pyx_optional_args->__pyx_n > 6) {
                  __pyx_v_enable_cooperative_groups = __pyx_optional_args->enable_cooperative_groups;
                }
              }
            }
          }
        }
      }
    }
  }
  __Pyx_INCREF(__pyx_v_source);
  __Pyx_INCREF(__pyx_v_options);
  __Pyx_INCREF(__pyx_v_prepend_cupy_headers);

  /* "cupy/core/core.pyx":1808
 *         prepend_cupy_headers=True, backend='nvrtc', translate_cucomplex=False,
 *         enable_cooperative_groups=False):
 *     if translate_cucomplex:             # <<<<<<<<<<<<<<
 *         source = _translate_cucomplex_to_thrust(source)
 *         _cupy_header_list.append('cupy/cuComplex_bridge.h')
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_translate_cucomplex); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1808, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1809
 *         enable_cooperative_groups=False):
 *     if translate_cucomplex:
 *         source = _translate_cucomplex_to_thrust(source)             # <<<<<<<<<<<<<<
 *         _cupy_header_list.append('cupy/cuComplex_bridge.h')
 *         prepend_cupy_headers = True
 */
    __pyx_t_2 = __pyx_f_4cupy_4core_4core__translate_cucomplex_to_thrust(__pyx_v_source); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1809, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_source, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":1810
 *     if translate_cucomplex:
 *         source = _translate_cucomplex_to_thrust(source)
 *         _cupy_header_list.append('cupy/cuComplex_bridge.h')             # <<<<<<<<<<<<<<
 *         prepend_cupy_headers = True
 * 
 */
    if (unlikely(__pyx_v_4cupy_4core_4core__cupy_header_list == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append");
      __PYX_ERR(0, 1810, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyList_Append(__pyx_v_4cupy_4core_4core__cupy_header_list, __pyx_kp_u_cupy_cuComplex_bridge_h); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1810, __pyx_L1_error)

    /* "cupy/core/core.pyx":1811
 *         source = _translate_cucomplex_to_thrust(source)
 *         _cupy_header_list.append('cupy/cuComplex_bridge.h')
 *         prepend_cupy_headers = True             # <<<<<<<<<<<<<<
 * 
 *     if prepend_cupy_headers:
 */
    __Pyx_INCREF(Py_True);
    __Pyx_DECREF_SET(__pyx_v_prepend_cupy_headers, Py_True);

    /* "cupy/core/core.pyx":1808
 *         prepend_cupy_headers=True, backend='nvrtc', translate_cucomplex=False,
 *         enable_cooperative_groups=False):
 *     if translate_cucomplex:             # <<<<<<<<<<<<<<
 *         source = _translate_cucomplex_to_thrust(source)
 *         _cupy_header_list.append('cupy/cuComplex_bridge.h')
 */
  }

  /* "cupy/core/core.pyx":1813
 *         prepend_cupy_headers = True
 * 
 *     if prepend_cupy_headers:             # <<<<<<<<<<<<<<
 *         source = _cupy_header + source
 *     extra_source = _get_header_source()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_prepend_cupy_headers); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1813, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1814
 * 
 *     if prepend_cupy_headers:
 *         source = _cupy_header + source             # <<<<<<<<<<<<<<
 *     extra_source = _get_header_source()
 *     options += ('-I%s' % _get_header_dir_path(),)
 */
    __pyx_t_2 = __Pyx_PyUnicode_ConcatSafe(__pyx_v_4cupy_4core_4core__cupy_header, __pyx_v_source); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1814, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_source, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":1813
 *         prepend_cupy_headers = True
 * 
 *     if prepend_cupy_headers:             # <<<<<<<<<<<<<<
 *         source = _cupy_header + source
 *     extra_source = _get_header_source()
 */
  }

  /* "cupy/core/core.pyx":1815
 *     if prepend_cupy_headers:
 *         source = _cupy_header + source
 *     extra_source = _get_header_source()             # <<<<<<<<<<<<<<
 *     options += ('-I%s' % _get_header_dir_path(),)
 * 
 */
  __pyx_t_2 = __pyx_f_4cupy_4core_4core__get_header_source(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1815, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_extra_source = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":1816
 *         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_2 = __pyx_f_4cupy_4core_4core__get_header_dir_path(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1816, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_I_s, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1816, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1816, __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 = PyNumber_InPlaceAdd(__pyx_v_options, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1816, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_options, ((PyObject*)__pyx_t_4));
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":1821
 *     # but it might not have been set appropriately before coming here.
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version < 0:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  __pyx_t_1 = ((__pyx_v_4cupy_4core_4core__cuda_runtime_version < 0) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1822
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version < 0:
 *         _cuda_runtime_version = runtime.runtimeGetVersion()             # <<<<<<<<<<<<<<
 * 
 *     if _cuda_runtime_version >= 9000:
 */
    __pyx_t_5 = __pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion(0); if (unlikely(__pyx_t_5 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1822, __pyx_L1_error)
    __pyx_v_4cupy_4core_4core__cuda_runtime_version = __pyx_t_5;

    /* "cupy/core/core.pyx":1821
 *     # but it might not have been set appropriately before coming here.
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version < 0:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  }

  /* "cupy/core/core.pyx":1824
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 *     if _cuda_runtime_version >= 9000:             # <<<<<<<<<<<<<<
 *         if 9020 <= _cuda_runtime_version < 9030:
 *             bundled_include = 'cuda-9.2'
 */
  __pyx_t_1 = ((__pyx_v_4cupy_4core_4core__cuda_runtime_version >= 0x2328) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1825
 * 
 *     if _cuda_runtime_version >= 9000:
 *         if 9020 <= _cuda_runtime_version < 9030:             # <<<<<<<<<<<<<<
 *             bundled_include = 'cuda-9.2'
 *         elif 10000 <= _cuda_runtime_version < 10010:
 */
    __pyx_t_1 = (0x233C <= __pyx_v_4cupy_4core_4core__cuda_runtime_version);
    if (__pyx_t_1) {
      __pyx_t_1 = (__pyx_v_4cupy_4core_4core__cuda_runtime_version < 0x2346);
    }
    __pyx_t_6 = (__pyx_t_1 != 0);
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":1826
 *     if _cuda_runtime_version >= 9000:
 *         if 9020 <= _cuda_runtime_version < 9030:
 *             bundled_include = 'cuda-9.2'             # <<<<<<<<<<<<<<
 *         elif 10000 <= _cuda_runtime_version < 10010:
 *             bundled_include = 'cuda-10.0'
 */
      __Pyx_INCREF(__pyx_kp_u_cuda_9_2);
      __pyx_v_bundled_include = __pyx_kp_u_cuda_9_2;

      /* "cupy/core/core.pyx":1825
 * 
 *     if _cuda_runtime_version >= 9000:
 *         if 9020 <= _cuda_runtime_version < 9030:             # <<<<<<<<<<<<<<
 *             bundled_include = 'cuda-9.2'
 *         elif 10000 <= _cuda_runtime_version < 10010:
 */
      goto __pyx_L7;
    }

    /* "cupy/core/core.pyx":1827
 *         if 9020 <= _cuda_runtime_version < 9030:
 *             bundled_include = 'cuda-9.2'
 *         elif 10000 <= _cuda_runtime_version < 10010:             # <<<<<<<<<<<<<<
 *             bundled_include = 'cuda-10.0'
 *         elif 10010 <= _cuda_runtime_version < 10020:
 */
    __pyx_t_6 = (0x2710 <= __pyx_v_4cupy_4core_4core__cuda_runtime_version);
    if (__pyx_t_6) {
      __pyx_t_6 = (__pyx_v_4cupy_4core_4core__cuda_runtime_version < 0x271A);
    }
    __pyx_t_1 = (__pyx_t_6 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1828
 *             bundled_include = 'cuda-9.2'
 *         elif 10000 <= _cuda_runtime_version < 10010:
 *             bundled_include = 'cuda-10.0'             # <<<<<<<<<<<<<<
 *         elif 10010 <= _cuda_runtime_version < 10020:
 *             bundled_include = 'cuda-10.1'
 */
      __Pyx_INCREF(__pyx_kp_u_cuda_10_0);
      __pyx_v_bundled_include = __pyx_kp_u_cuda_10_0;

      /* "cupy/core/core.pyx":1827
 *         if 9020 <= _cuda_runtime_version < 9030:
 *             bundled_include = 'cuda-9.2'
 *         elif 10000 <= _cuda_runtime_version < 10010:             # <<<<<<<<<<<<<<
 *             bundled_include = 'cuda-10.0'
 *         elif 10010 <= _cuda_runtime_version < 10020:
 */
      goto __pyx_L7;
    }

    /* "cupy/core/core.pyx":1829
 *         elif 10000 <= _cuda_runtime_version < 10010:
 *             bundled_include = 'cuda-10.0'
 *         elif 10010 <= _cuda_runtime_version < 10020:             # <<<<<<<<<<<<<<
 *             bundled_include = 'cuda-10.1'
 *         elif 10020 <= _cuda_runtime_version < 10030:
 */
    __pyx_t_1 = (0x271A <= __pyx_v_4cupy_4core_4core__cuda_runtime_version);
    if (__pyx_t_1) {
      __pyx_t_1 = (__pyx_v_4cupy_4core_4core__cuda_runtime_version < 0x2724);
    }
    __pyx_t_6 = (__pyx_t_1 != 0);
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":1830
 *             bundled_include = 'cuda-10.0'
 *         elif 10010 <= _cuda_runtime_version < 10020:
 *             bundled_include = 'cuda-10.1'             # <<<<<<<<<<<<<<
 *         elif 10020 <= _cuda_runtime_version < 10030:
 *             bundled_include = 'cuda-10.2'
 */
      __Pyx_INCREF(__pyx_kp_u_cuda_10_1);
      __pyx_v_bundled_include = __pyx_kp_u_cuda_10_1;

      /* "cupy/core/core.pyx":1829
 *         elif 10000 <= _cuda_runtime_version < 10010:
 *             bundled_include = 'cuda-10.0'
 *         elif 10010 <= _cuda_runtime_version < 10020:             # <<<<<<<<<<<<<<
 *             bundled_include = 'cuda-10.1'
 *         elif 10020 <= _cuda_runtime_version < 10030:
 */
      goto __pyx_L7;
    }

    /* "cupy/core/core.pyx":1831
 *         elif 10010 <= _cuda_runtime_version < 10020:
 *             bundled_include = 'cuda-10.1'
 *         elif 10020 <= _cuda_runtime_version < 10030:             # <<<<<<<<<<<<<<
 *             bundled_include = 'cuda-10.2'
 *         else:
 */
    __pyx_t_6 = (0x2724 <= __pyx_v_4cupy_4core_4core__cuda_runtime_version);
    if (__pyx_t_6) {
      __pyx_t_6 = (__pyx_v_4cupy_4core_4core__cuda_runtime_version < 0x272E);
    }
    __pyx_t_1 = (__pyx_t_6 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1832
 *             bundled_include = 'cuda-10.1'
 *         elif 10020 <= _cuda_runtime_version < 10030:
 *             bundled_include = 'cuda-10.2'             # <<<<<<<<<<<<<<
 *         else:
 *             # CUDA v9.0, v9.1 or versions not yet supported.
 */
      __Pyx_INCREF(__pyx_kp_u_cuda_10_2);
      __pyx_v_bundled_include = __pyx_kp_u_cuda_10_2;

      /* "cupy/core/core.pyx":1831
 *         elif 10010 <= _cuda_runtime_version < 10020:
 *             bundled_include = 'cuda-10.1'
 *         elif 10020 <= _cuda_runtime_version < 10030:             # <<<<<<<<<<<<<<
 *             bundled_include = 'cuda-10.2'
 *         else:
 */
      goto __pyx_L7;
    }

    /* "cupy/core/core.pyx":1835
 *         else:
 *             # CUDA v9.0, v9.1 or versions not yet supported.
 *             bundled_include = None             # <<<<<<<<<<<<<<
 * 
 *         cuda_path = cuda.get_cuda_path()
 */
    /*else*/ {
      __Pyx_INCREF(Py_None);
      __pyx_v_bundled_include = ((PyObject*)Py_None);
    }
    __pyx_L7:;

    /* "cupy/core/core.pyx":1837
 *             bundled_include = None
 * 
 *         cuda_path = cuda.get_cuda_path()             # <<<<<<<<<<<<<<
 * 
 *         if bundled_include is None and cuda_path is None:
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1837, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_cuda_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1837, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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_4 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1837, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1837, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_cuda_path = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":1839
 *         cuda_path = cuda.get_cuda_path()
 * 
 *         if bundled_include is None and cuda_path is None:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 'Failed to auto-detect CUDA root directory. '
 */
    __pyx_t_6 = (__pyx_v_bundled_include == ((PyObject*)Py_None));
    __pyx_t_8 = (__pyx_t_6 != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_1 = __pyx_t_8;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_v_cuda_path == Py_None);
    __pyx_t_6 = (__pyx_t_8 != 0);
    __pyx_t_1 = __pyx_t_6;
    __pyx_L9_bool_binop_done:;
    if (unlikely(__pyx_t_1)) {

      /* "cupy/core/core.pyx":1840
 * 
 *         if bundled_include is None and cuda_path is None:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 'Failed to auto-detect CUDA root directory. '
 *                 'Please specify `CUDA_PATH` environment variable if you '
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1840, __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, 1840, __pyx_L1_error)

      /* "cupy/core/core.pyx":1839
 *         cuda_path = cuda.get_cuda_path()
 * 
 *         if bundled_include is None and cuda_path is None:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 'Failed to auto-detect CUDA root directory. '
 */
    }

    /* "cupy/core/core.pyx":1846
 *                 'CuPy.')
 * 
 *         if bundled_include is not None:             # <<<<<<<<<<<<<<
 *             options += ('-I ' + os.path.join(
 *                 _get_header_dir_path(), 'cupy', '_cuda', bundled_include),)
 */
    __pyx_t_1 = (__pyx_v_bundled_include != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_1 != 0);
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":1847
 * 
 *         if bundled_include is not None:
 *             options += ('-I ' + os.path.join(             # <<<<<<<<<<<<<<
 *                 _get_header_dir_path(), 'cupy', '_cuda', bundled_include),)
 * 
 */
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_join); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":1848
 *         if bundled_include is not None:
 *             options += ('-I ' + os.path.join(
 *                 _get_header_dir_path(), 'cupy', '_cuda', bundled_include),)             # <<<<<<<<<<<<<<
 * 
 *         if cuda_path is not None:
 */
      __pyx_t_2 = __pyx_f_4cupy_4core_4core__get_header_dir_path(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1848, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_t_2, __pyx_n_u_cupy, __pyx_n_u_cuda_2, __pyx_v_bundled_include};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1847, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 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_7)) {
        PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_t_2, __pyx_n_u_cupy, __pyx_n_u_cuda_2, __pyx_v_bundled_include};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1847, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1847, __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_2);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_5, __pyx_t_2);
        __Pyx_INCREF(__pyx_n_u_cupy);
        __Pyx_GIVEREF(__pyx_n_u_cupy);
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_5, __pyx_n_u_cupy);
        __Pyx_INCREF(__pyx_n_u_cuda_2);
        __Pyx_GIVEREF(__pyx_n_u_cuda_2);
        PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_5, __pyx_n_u_cuda_2);
        __Pyx_INCREF(__pyx_v_bundled_include);
        __Pyx_GIVEREF(__pyx_v_bundled_include);
        PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_5, __pyx_v_bundled_include);
        __pyx_t_2 = 0;
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1847, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "cupy/core/core.pyx":1847
 * 
 *         if bundled_include is not None:
 *             options += ('-I ' + os.path.join(             # <<<<<<<<<<<<<<
 *                 _get_header_dir_path(), 'cupy', '_cuda', bundled_include),)
 * 
 */
      __pyx_t_7 = PyNumber_Add(__pyx_kp_u_I, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_options, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_options, ((PyObject*)__pyx_t_7));
      __pyx_t_7 = 0;

      /* "cupy/core/core.pyx":1846
 *                 'CuPy.')
 * 
 *         if bundled_include is not None:             # <<<<<<<<<<<<<<
 *             options += ('-I ' + os.path.join(
 *                 _get_header_dir_path(), 'cupy', '_cuda', bundled_include),)
 */
    }

    /* "cupy/core/core.pyx":1850
 *                 _get_header_dir_path(), 'cupy', '_cuda', bundled_include),)
 * 
 *         if cuda_path is not None:             # <<<<<<<<<<<<<<
 *             options += ('-I ' + os.path.join(cuda_path, 'include'),)
 * 
 */
    __pyx_t_6 = (__pyx_v_cuda_path != Py_None);
    __pyx_t_1 = (__pyx_t_6 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1851
 * 
 *         if cuda_path is not None:
 *             options += ('-I ' + os.path.join(cuda_path, 'include'),)             # <<<<<<<<<<<<<<
 * 
 *     return cuda.compile_with_cache(
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1851, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_path); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1851, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_join); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1851, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = NULL;
      __pyx_t_5 = 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_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_cuda_path, __pyx_n_u_include};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1851, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_7);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_cuda_path, __pyx_n_u_include};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1851, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_7);
      } else
      #endif
      {
        __pyx_t_2 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1851, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_INCREF(__pyx_v_cuda_path);
        __Pyx_GIVEREF(__pyx_v_cuda_path);
        PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_5, __pyx_v_cuda_path);
        __Pyx_INCREF(__pyx_n_u_include);
        __Pyx_GIVEREF(__pyx_n_u_include);
        PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_5, __pyx_n_u_include);
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1851, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyNumber_Add(__pyx_kp_u_I, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1851, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1851, __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 = 0;
      __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_options, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1851, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF_SET(__pyx_v_options, ((PyObject*)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1850
 *                 _get_header_dir_path(), 'cupy', '_cuda', bundled_include),)
 * 
 *         if cuda_path is not None:             # <<<<<<<<<<<<<<
 *             options += ('-I ' + os.path.join(cuda_path, 'include'),)
 * 
 */
    }

    /* "cupy/core/core.pyx":1824
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 *     if _cuda_runtime_version >= 9000:             # <<<<<<<<<<<<<<
 *         if 9020 <= _cuda_runtime_version < 9030:
 *             bundled_include = 'cuda-9.2'
 */
  }

  /* "cupy/core/core.pyx":1853
 *             options += ('-I ' + os.path.join(cuda_path, 'include'),)
 * 
 *     return cuda.compile_with_cache(             # <<<<<<<<<<<<<<
 *         source, options, arch, cachd_dir, extra_source, backend,
 *         enable_cooperative_groups=enable_cooperative_groups)
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuda); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1853, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_compile_with_cache); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1853, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":1854
 * 
 *     return cuda.compile_with_cache(
 *         source, options, arch, cachd_dir, extra_source, backend,             # <<<<<<<<<<<<<<
 *         enable_cooperative_groups=enable_cooperative_groups)
 * 
 */
  __pyx_t_4 = PyTuple_New(6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1853, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_source);
  __Pyx_GIVEREF(__pyx_v_source);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_source);
  __Pyx_INCREF(__pyx_v_options);
  __Pyx_GIVEREF(__pyx_v_options);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_options);
  __Pyx_INCREF(__pyx_v_arch);
  __Pyx_GIVEREF(__pyx_v_arch);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_arch);
  __Pyx_INCREF(__pyx_v_cachd_dir);
  __Pyx_GIVEREF(__pyx_v_cachd_dir);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_cachd_dir);
  __Pyx_INCREF(__pyx_v_extra_source);
  __Pyx_GIVEREF(__pyx_v_extra_source);
  PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_v_extra_source);
  __Pyx_INCREF(__pyx_v_backend);
  __Pyx_GIVEREF(__pyx_v_backend);
  PyTuple_SET_ITEM(__pyx_t_4, 5, __pyx_v_backend);

  /* "cupy/core/core.pyx":1855
 *     return cuda.compile_with_cache(
 *         source, options, arch, cachd_dir, extra_source, backend,
 *         enable_cooperative_groups=enable_cooperative_groups)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_enable_cooperative_groups, __pyx_v_enable_cooperative_groups) < 0) __PYX_ERR(0, 1855, __pyx_L1_error)

  /* "cupy/core/core.pyx":1853
 *             options += ('-I ' + os.path.join(cuda_path, 'include'),)
 * 
 *     return cuda.compile_with_cache(             # <<<<<<<<<<<<<<
 *         source, options, arch, cachd_dir, extra_source, backend,
 *         enable_cooperative_groups=enable_cooperative_groups)
 */
  __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1853, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_4cupy_4cuda_8function_Module))))) __PYX_ERR(0, 1853, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_4cupy_4cuda_8function_Module *)__pyx_t_10);
  __pyx_t_10 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1804
 * 
 * 
 * cpdef function.Module compile_with_cache(             # <<<<<<<<<<<<<<
 *         str source, tuple options=(), arch=None, cachd_dir=None,
 *         prepend_cupy_headers=True, backend='nvrtc', translate_cucomplex=False,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __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_bundled_include);
  __Pyx_XDECREF(__pyx_v_cuda_path);
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF(__pyx_v_options);
  __Pyx_XDECREF(__pyx_v_prepend_cupy_headers);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_9compile_with_cache(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_8compile_with_cache[] = "compile_with_cache(unicode source, tuple options=(), arch=None, cachd_dir=None, prepend_cupy_headers=True, backend=u'nvrtc', translate_cucomplex=False, enable_cooperative_groups=False) -> Module";
static PyObject *__pyx_pw_4cupy_4core_4core_9compile_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_v_prepend_cupy_headers = 0;
  PyObject *__pyx_v_backend = 0;
  PyObject *__pyx_v_translate_cucomplex = 0;
  PyObject *__pyx_v_enable_cooperative_groups = 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,&__pyx_n_s_prepend_cupy_headers,&__pyx_n_s_backend,&__pyx_n_s_translate_cucomplex,&__pyx_n_s_enable_cooperative_groups,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};

    /* "cupy/core/core.pyx":1805
 * 
 * cpdef function.Module compile_with_cache(
 *         str source, tuple options=(), arch=None, cachd_dir=None,             # <<<<<<<<<<<<<<
 *         prepend_cupy_headers=True, backend='nvrtc', translate_cucomplex=False,
 *         enable_cooperative_groups=False):
 */
    values[1] = ((PyObject*)__pyx_empty_tuple);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);

    /* "cupy/core/core.pyx":1806
 * cpdef function.Module compile_with_cache(
 *         str source, tuple options=(), arch=None, cachd_dir=None,
 *         prepend_cupy_headers=True, backend='nvrtc', translate_cucomplex=False,             # <<<<<<<<<<<<<<
 *         enable_cooperative_groups=False):
 *     if translate_cucomplex:
 */
    values[4] = ((PyObject *)Py_True);
    values[5] = ((PyObject *)__pyx_n_u_nvrtc);
    values[6] = ((PyObject *)Py_False);

    /* "cupy/core/core.pyx":1807
 *         str source, tuple options=(), arch=None, cachd_dir=None,
 *         prepend_cupy_headers=True, backend='nvrtc', translate_cucomplex=False,
 *         enable_cooperative_groups=False):             # <<<<<<<<<<<<<<
 *     if translate_cucomplex:
 *         source = _translate_cucomplex_to_thrust(source)
 */
    values[7] = ((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  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_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--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_prepend_cupy_headers);
          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_backend);
          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_translate_cucomplex);
          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_enable_cooperative_groups);
          if (value) { values[7] = 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(0, 1804, __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);
        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_source = ((PyObject*)values[0]);
    __pyx_v_options = ((PyObject*)values[1]);
    __pyx_v_arch = values[2];
    __pyx_v_cachd_dir = values[3];
    __pyx_v_prepend_cupy_headers = values[4];
    __pyx_v_backend = values[5];
    __pyx_v_translate_cucomplex = values[6];
    __pyx_v_enable_cooperative_groups = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("compile_with_cache", 0, 1, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1804, __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), (&PyUnicode_Type), 1, "source", 1))) __PYX_ERR(0, 1805, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_options), (&PyTuple_Type), 1, "options", 1))) __PYX_ERR(0, 1805, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_8compile_with_cache(__pyx_self, __pyx_v_source, __pyx_v_options, __pyx_v_arch, __pyx_v_cachd_dir, __pyx_v_prepend_cupy_headers, __pyx_v_backend, __pyx_v_translate_cucomplex, __pyx_v_enable_cooperative_groups);

  /* "cupy/core/core.pyx":1804
 * 
 * 
 * cpdef function.Module compile_with_cache(             # <<<<<<<<<<<<<<
 *         str source, tuple options=(), arch=None, cachd_dir=None,
 *         prepend_cupy_headers=True, backend='nvrtc', translate_cucomplex=False,
 */

  /* 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_8compile_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_v_prepend_cupy_headers, PyObject *__pyx_v_backend, PyObject *__pyx_v_translate_cucomplex, PyObject *__pyx_v_enable_cooperative_groups) {
  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 = 7;
  __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_2.prepend_cupy_headers = __pyx_v_prepend_cupy_headers;
  __pyx_t_2.backend = __pyx_v_backend;
  __pyx_t_2.translate_cucomplex = __pyx_v_translate_cucomplex;
  __pyx_t_2.enable_cooperative_groups = __pyx_v_enable_cooperative_groups;
  __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(0, 1804, __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/core.pyx":1954
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, order='K',             # <<<<<<<<<<<<<<
 *                     bint subok=False, Py_ssize_t ndmin=0):
 *     # TODO(beam2d): Support subok options
 */

static PyObject *__pyx_pw_4cupy_4core_4core_11array(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_u_K);

  /* "cupy/core/core.pyx":1955
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, order='K',
 *                     bint subok=False, Py_ssize_t ndmin=0):             # <<<<<<<<<<<<<<
 *     # TODO(beam2d): Support subok options
 *     cdef Py_ssize_t ndim
 */
  int __pyx_v_subok = ((int)0);
  Py_ssize_t __pyx_v_ndmin = ((Py_ssize_t)0);
  Py_ssize_t __pyx_v_ndim;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_src = 0;
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_elem_type = NULL;
  PyObject *__pyx_v_elem_dtype = NULL;
  PyObject *__pyx_v_lst = NULL;
  PyObject *__pyx_8genexpr4__pyx_v_x = 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;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy __pyx_t_7;
  struct __pyx_opt_args_4cupy_4core_4core_array __pyx_t_8;
  int __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  std::vector<Py_ssize_t>  __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  __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":1961
 *     cdef size_t nbytes
 * 
 *     if subok:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 *     if order is None:
 */
  __pyx_t_1 = (__pyx_v_subok != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cupy/core/core.pyx":1962
 * 
 *     if subok:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 *     if order is None:
 *         order = 'K'
 */
    __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
    __PYX_ERR(0, 1962, __pyx_L1_error)

    /* "cupy/core/core.pyx":1961
 *     cdef size_t nbytes
 * 
 *     if subok:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 *     if order is None:
 */
  }

  /* "cupy/core/core.pyx":1963
 *     if subok:
 *         raise NotImplementedError
 *     if order is None:             # <<<<<<<<<<<<<<
 *         order = 'K'
 * 
 */
  __pyx_t_1 = (__pyx_v_order == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1964
 *         raise NotImplementedError
 *     if order is None:
 *         order = 'K'             # <<<<<<<<<<<<<<
 * 
 *     if isinstance(obj, ndarray):
 */
    __Pyx_INCREF(__pyx_n_u_K);
    __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_u_K);

    /* "cupy/core/core.pyx":1963
 *     if subok:
 *         raise NotImplementedError
 *     if order is None:             # <<<<<<<<<<<<<<
 *         order = 'K'
 * 
 */
  }

  /* "cupy/core/core.pyx":1966
 *         order = 'K'
 * 
 *     if isinstance(obj, ndarray):             # <<<<<<<<<<<<<<
 *         src = obj
 *         if dtype is None:
 */
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_4cupy_4core_4core_ndarray); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1967
 * 
 *     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, 1967, __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":1968
 *     if isinstance(obj, ndarray):
 *         src = obj
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             dtype = src.dtype
 *         if src.data.device_id == device.get_device_id():
 */
    __pyx_t_1 = (__pyx_v_dtype == Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1969
 *         src = obj
 *         if dtype is None:
 *             dtype = src.dtype             # <<<<<<<<<<<<<<
 *         if src.data.device_id == device.get_device_id():
 *             a = src.astype(dtype, order=order, copy=copy)
 */
      __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":1968
 *     if isinstance(obj, ndarray):
 *         src = obj
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             dtype = src.dtype
 *         if src.data.device_id == device.get_device_id():
 */
    }

    /* "cupy/core/core.pyx":1970
 *         if dtype is None:
 *             dtype = src.dtype
 *         if src.data.device_id == device.get_device_id():             # <<<<<<<<<<<<<<
 *             a = src.astype(dtype, order=order, copy=copy)
 *         else:
 */
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_src->data->device_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1970, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_device); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1970, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get_device_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1970, __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_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1970, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1970, __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_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1970, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1970, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1971
 *             dtype = src.dtype
 *         if src.data.device_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_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_src), __pyx_n_s_astype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1971, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1971, __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_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1971, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 1971, __pyx_L1_error)
      __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_copy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1971, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_copy, __pyx_t_5) < 0) __PYX_ERR(0, 1971, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1971, __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_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, 1971, __pyx_L1_error)
      __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
      __pyx_t_5 = 0;

      /* "cupy/core/core.pyx":1970
 *         if dtype is None:
 *             dtype = src.dtype
 *         if src.data.device_id == device.get_device_id():             # <<<<<<<<<<<<<<
 *             a = src.astype(dtype, order=order, copy=copy)
 *         else:
 */
      goto __pyx_L7;
    }

    /* "cupy/core/core.pyx":1973
 *             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_7.__pyx_n = 1;
      __pyx_t_7.order = __pyx_v_order;
      __pyx_t_5 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_src->__pyx_vtab)->copy(__pyx_v_src, 0, &__pyx_t_7)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1973, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_astype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1973, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1973, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_dtype);
      __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1973, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 1973, __pyx_L1_error)
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1973, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 1973, __pyx_L1_error)
      __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
      __pyx_t_6 = 0;
    }
    __pyx_L7:;

    /* "cupy/core/core.pyx":1975
 *             a = src.copy(order=order).astype(dtype, copy=False)
 * 
 *         ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *         if ndmin > ndim:
 *             if a is obj:
 */
    __pyx_v_ndim = __pyx_v_a->_shape.size();

    /* "cupy/core/core.pyx":1976
 * 
 *         ndim = a._shape.size()
 *         if ndmin > ndim:             # <<<<<<<<<<<<<<
 *             if a is obj:
 *                 # When `copy` is False, `a` is same as `obj`.
 */
    __pyx_t_2 = ((__pyx_v_ndmin > __pyx_v_ndim) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1977
 *         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_2 = (((PyObject *)__pyx_v_a) == __pyx_v_obj);
      __pyx_t_1 = (__pyx_t_2 != 0);
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":1979
 *             if a is obj:
 *                 # When `copy` is False, `a` is same as `obj`.
 *                 a = a.view()             # <<<<<<<<<<<<<<
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *     elif hasattr(obj, '__cuda_array_interface__'):
 */
        __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, 1979, __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":1977
 *         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":1980
 *                 # When `copy` is False, `a` is same as `obj`.
 *                 a = a.view()
 *             a.shape = (1,) * (ndmin - ndim) + a.shape             # <<<<<<<<<<<<<<
 *     elif hasattr(obj, '__cuda_array_interface__'):
 *         return array(_convert_object_with_cuda_array_interface(obj),
 */
      __pyx_t_6 = PyInt_FromSsize_t((__pyx_v_ndmin - __pyx_v_ndim)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1980, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = PyNumber_Multiply(__pyx_tuple__37, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1980, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __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, 1980, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1980, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape, __pyx_t_5) < 0) __PYX_ERR(0, 1980, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/core/core.pyx":1976
 * 
 *         ndim = a._shape.size()
 *         if ndmin > ndim:             # <<<<<<<<<<<<<<
 *             if a is obj:
 *                 # When `copy` is False, `a` is same as `obj`.
 */
    }

    /* "cupy/core/core.pyx":1966
 *         order = 'K'
 * 
 *     if isinstance(obj, ndarray):             # <<<<<<<<<<<<<<
 *         src = obj
 *         if dtype is None:
 */
    goto __pyx_L5;
  }

  /* "cupy/core/core.pyx":1981
 *                 a = a.view()
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *     elif hasattr(obj, '__cuda_array_interface__'):             # <<<<<<<<<<<<<<
 *         return array(_convert_object_with_cuda_array_interface(obj),
 *                      dtype, copy, order, subok, ndmin)
 */
  __pyx_t_1 = __Pyx_HasAttr(__pyx_v_obj, __pyx_n_u_cuda_array_interface); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1981, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1982
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *     elif hasattr(obj, '__cuda_array_interface__'):
 *         return array(_convert_object_with_cuda_array_interface(obj),             # <<<<<<<<<<<<<<
 *                      dtype, copy, order, subok, ndmin)
 *     else:  # obj is sequence, numpy array, scalar or the other type of object
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4core_4core__convert_object_with_cuda_array_interface(__pyx_v_obj, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1982, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);

    /* "cupy/core/core.pyx":1983
 *     elif hasattr(obj, '__cuda_array_interface__'):
 *         return array(_convert_object_with_cuda_array_interface(obj),
 *                      dtype, copy, order, subok, ndmin)             # <<<<<<<<<<<<<<
 *     else:  # obj is sequence, numpy array, scalar or the other type of object
 *         shape, elem_type, elem_dtype = _get_concat_shape(obj)
 */
    __pyx_t_8.__pyx_n = 5;
    __pyx_t_8.dtype = __pyx_v_dtype;
    __pyx_t_8.copy = __pyx_v_copy;
    __pyx_t_8.order = __pyx_v_order;
    __pyx_t_8.subok = __pyx_v_subok;
    __pyx_t_8.ndmin = __pyx_v_ndmin;
    __pyx_t_6 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_t_5, 0, &__pyx_t_8)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1982, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1981
 *                 a = a.view()
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *     elif hasattr(obj, '__cuda_array_interface__'):             # <<<<<<<<<<<<<<
 *         return array(_convert_object_with_cuda_array_interface(obj),
 *                      dtype, copy, order, subok, ndmin)
 */
  }

  /* "cupy/core/core.pyx":1985
 *                      dtype, copy, order, subok, ndmin)
 *     else:  # obj is sequence, numpy array, scalar or the other type of object
 *         shape, elem_type, elem_dtype = _get_concat_shape(obj)             # <<<<<<<<<<<<<<
 *         if shape is not None and shape[-1] != 0:
 *             # obj is a non-empty sequence of ndarrays which share same shape
 */
  /*else*/ {
    __pyx_t_6 = __pyx_f_4cupy_4core_4core__get_concat_shape(__pyx_v_obj); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1985, __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 != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 1985, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1985, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1985, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1985, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 1985, __pyx_L1_error)
    }
    __pyx_v_shape = __pyx_t_5;
    __pyx_t_5 = 0;
    __pyx_v_elem_type = __pyx_t_4;
    __pyx_t_4 = 0;
    __pyx_v_elem_dtype = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1986
 *     else:  # obj is sequence, numpy array, scalar or the other type of object
 *         shape, elem_type, elem_dtype = _get_concat_shape(obj)
 *         if shape is not None and shape[-1] != 0:             # <<<<<<<<<<<<<<
 *             # obj is a non-empty sequence of ndarrays which share same shape
 *             # and dtype
 */
    __pyx_t_1 = (__pyx_v_shape != Py_None);
    __pyx_t_9 = (__pyx_t_1 != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_2 = __pyx_t_9;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_shape, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1986, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_6, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1986, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1986, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __pyx_t_9;
    __pyx_L11_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1994
 *             order = (
 *                 'F'
 *                 if order is not None and len(order) >= 1 and order[0] in 'Ff'             # <<<<<<<<<<<<<<
 *                 else 'C')
 *             ndim = len(shape)
 */
      __pyx_t_9 = (__pyx_v_order != Py_None);
      __pyx_t_1 = (__pyx_t_9 != 0);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_10 = PyObject_Length(__pyx_v_order); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1994, __pyx_L1_error)
      __pyx_t_1 = ((__pyx_t_10 >= 1) != 0);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_order, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1994, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = (__Pyx_PyUnicode_ContainsTF(__pyx_t_6, __pyx_n_u_Ff, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1994, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_9 = (__pyx_t_1 != 0);
      __pyx_t_2 = __pyx_t_9;
      __pyx_L13_bool_binop_done:;
      if (__pyx_t_2) {
        __Pyx_INCREF(__pyx_n_u_F);
        __pyx_t_3 = __pyx_n_u_F;
      } else {
        __Pyx_INCREF(__pyx_n_u_C);
        __pyx_t_3 = __pyx_n_u_C;
      }
      __Pyx_DECREF_SET(__pyx_v_order, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/core.pyx":1996
 *                 if order is not None and len(order) >= 1 and order[0] in 'Ff'
 *                 else 'C')
 *             ndim = len(shape)             # <<<<<<<<<<<<<<
 *             if ndmin > ndim:
 *                 shape = (1,) * (ndmin - ndim) + shape
 */
      __pyx_t_10 = PyObject_Length(__pyx_v_shape); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1996, __pyx_L1_error)
      __pyx_v_ndim = __pyx_t_10;

      /* "cupy/core/core.pyx":1997
 *                 else 'C')
 *             ndim = len(shape)
 *             if ndmin > ndim:             # <<<<<<<<<<<<<<
 *                 shape = (1,) * (ndmin - ndim) + shape
 * 
 */
      __pyx_t_2 = ((__pyx_v_ndmin > __pyx_v_ndim) != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1998
 *             ndim = len(shape)
 *             if ndmin > ndim:
 *                 shape = (1,) * (ndmin - ndim) + shape             # <<<<<<<<<<<<<<
 * 
 *             if dtype is None:
 */
        __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_ndmin - __pyx_v_ndim)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1998, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = PyNumber_Multiply(__pyx_tuple__38, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1998, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = PyNumber_Add(__pyx_t_6, __pyx_v_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1998, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF_SET(__pyx_v_shape, __pyx_t_3);
        __pyx_t_3 = 0;

        /* "cupy/core/core.pyx":1997
 *                 else 'C')
 *             ndim = len(shape)
 *             if ndmin > ndim:             # <<<<<<<<<<<<<<
 *                 shape = (1,) * (ndmin - ndim) + shape
 * 
 */
      }

      /* "cupy/core/core.pyx":2000
 *                 shape = (1,) * (ndmin - ndim) + shape
 * 
 *             if dtype is None:             # <<<<<<<<<<<<<<
 *                 dtype = elem_dtype
 *             # Note: dtype might not be numpy.dtype in this place
 */
      __pyx_t_2 = (__pyx_v_dtype == Py_None);
      __pyx_t_9 = (__pyx_t_2 != 0);
      if (__pyx_t_9) {

        /* "cupy/core/core.pyx":2001
 * 
 *             if dtype is None:
 *                 dtype = elem_dtype             # <<<<<<<<<<<<<<
 *             # Note: dtype might not be numpy.dtype in this place
 * 
 */
        __Pyx_INCREF(__pyx_v_elem_dtype);
        __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_v_elem_dtype);

        /* "cupy/core/core.pyx":2000
 *                 shape = (1,) * (ndmin - ndim) + shape
 * 
 *             if dtype is None:             # <<<<<<<<<<<<<<
 *                 dtype = elem_dtype
 *             # Note: dtype might not be numpy.dtype in this place
 */
      }

      /* "cupy/core/core.pyx":2004
 *             # Note: dtype might not be numpy.dtype in this place
 * 
 *             if issubclass(elem_type, numpy.ndarray):             # <<<<<<<<<<<<<<
 *                 # obj is Seq[numpy.ndarray]
 *                 a = _send_numpy_array_list_to_gpu(
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2004, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2004, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_9 = PyObject_IsSubclass(__pyx_v_elem_type, __pyx_t_6); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 2004, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_2 = (__pyx_t_9 != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":2007
 *                 # obj is Seq[numpy.ndarray]
 *                 a = _send_numpy_array_list_to_gpu(
 *                     obj, elem_dtype, dtype, shape, order, ndmin)             # <<<<<<<<<<<<<<
 *             elif issubclass(elem_type, ndarray):
 *                 # obj is Seq[cupy.ndarray]
 */
        if (!(likely(PyList_CheckExact(__pyx_v_obj))||((__pyx_v_obj) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_obj)->tp_name), 0))) __PYX_ERR(0, 2007, __pyx_L1_error)
        __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2007, __pyx_L1_error)

        /* "cupy/core/core.pyx":2006
 *             if issubclass(elem_type, numpy.ndarray):
 *                 # obj is Seq[numpy.ndarray]
 *                 a = _send_numpy_array_list_to_gpu(             # <<<<<<<<<<<<<<
 *                     obj, elem_dtype, dtype, shape, order, ndmin)
 *             elif issubclass(elem_type, ndarray):
 */
        __pyx_t_6 = ((PyObject *)__pyx_f_4cupy_4core_4core__send_numpy_array_list_to_gpu(((PyObject*)__pyx_v_obj), __pyx_v_elem_dtype, __pyx_v_dtype, __pyx_t_11, __pyx_v_order, __pyx_v_ndmin)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2006, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
        __pyx_t_6 = 0;

        /* "cupy/core/core.pyx":2004
 *             # Note: dtype might not be numpy.dtype in this place
 * 
 *             if issubclass(elem_type, numpy.ndarray):             # <<<<<<<<<<<<<<
 *                 # obj is Seq[numpy.ndarray]
 *                 a = _send_numpy_array_list_to_gpu(
 */
        goto __pyx_L18;
      }

      /* "cupy/core/core.pyx":2008
 *                 a = _send_numpy_array_list_to_gpu(
 *                     obj, elem_dtype, dtype, shape, order, ndmin)
 *             elif issubclass(elem_type, ndarray):             # <<<<<<<<<<<<<<
 *                 # obj is Seq[cupy.ndarray]
 *                 lst = _flatten_list(obj)
 */
      __pyx_t_2 = PyObject_IsSubclass(__pyx_v_elem_type, ((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 2008, __pyx_L1_error)
      __pyx_t_9 = (__pyx_t_2 != 0);
      if (__pyx_t_9) {

        /* "cupy/core/core.pyx":2010
 *             elif issubclass(elem_type, ndarray):
 *                 # obj is Seq[cupy.ndarray]
 *                 lst = _flatten_list(obj)             # <<<<<<<<<<<<<<
 *                 if len(shape) == 1:
 *                     # convert each scalar (0-dim) ndarray to 1-dim
 */
        __pyx_t_6 = __pyx_f_4cupy_4core_4core__flatten_list(__pyx_v_obj); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2010, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_v_lst = ((PyObject*)__pyx_t_6);
        __pyx_t_6 = 0;

        /* "cupy/core/core.pyx":2011
 *                 # obj is Seq[cupy.ndarray]
 *                 lst = _flatten_list(obj)
 *                 if len(shape) == 1:             # <<<<<<<<<<<<<<
 *                     # convert each scalar (0-dim) ndarray to 1-dim
 *                     lst = [cupy.expand_dims(x, 0) for x in lst]
 */
        __pyx_t_10 = PyObject_Length(__pyx_v_shape); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2011, __pyx_L1_error)
        __pyx_t_9 = ((__pyx_t_10 == 1) != 0);
        if (__pyx_t_9) {

          /* "cupy/core/core.pyx":2013
 *                 if len(shape) == 1:
 *                     # convert each scalar (0-dim) ndarray to 1-dim
 *                     lst = [cupy.expand_dims(x, 0) for x in lst]             # <<<<<<<<<<<<<<
 * 
 *                 a = (_manipulation.concatenate_method(lst, 0)
 */
          { /* enter inner scope */
            __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2013, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_6);
            if (unlikely(__pyx_v_lst == Py_None)) {
              PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
              __PYX_ERR(0, 2013, __pyx_L22_error)
            }
            __pyx_t_3 = __pyx_v_lst; __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_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 2013, __pyx_L22_error)
              #else
              __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2013, __pyx_L22_error)
              __Pyx_GOTREF(__pyx_t_4);
              #endif
              __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_x, __pyx_t_4);
              __pyx_t_4 = 0;
              __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2013, __pyx_L22_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_expand_dims); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2013, __pyx_L22_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __pyx_t_5 = NULL;
              __pyx_t_13 = 0;
              if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_12);
                if (likely(__pyx_t_5)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_12, function);
                  __pyx_t_13 = 1;
                }
              }
              #if CYTHON_FAST_PYCALL
              if (PyFunction_Check(__pyx_t_12)) {
                PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_8genexpr4__pyx_v_x, __pyx_int_0};
                __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2013, __pyx_L22_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_12)) {
                PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_8genexpr4__pyx_v_x, __pyx_int_0};
                __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2013, __pyx_L22_error)
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_GOTREF(__pyx_t_4);
              } else
              #endif
              {
                __pyx_t_14 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2013, __pyx_L22_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_INCREF(__pyx_8genexpr4__pyx_v_x);
                __Pyx_GIVEREF(__pyx_8genexpr4__pyx_v_x);
                PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_13, __pyx_8genexpr4__pyx_v_x);
                __Pyx_INCREF(__pyx_int_0);
                __Pyx_GIVEREF(__pyx_int_0);
                PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_13, __pyx_int_0);
                __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2013, __pyx_L22_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              }
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 2013, __pyx_L22_error)
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            }
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_x); __pyx_8genexpr4__pyx_v_x = 0;
            goto __pyx_L25_exit_scope;
            __pyx_L22_error:;
            __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_x); __pyx_8genexpr4__pyx_v_x = 0;
            goto __pyx_L1_error;
            __pyx_L25_exit_scope:;
          } /* exit inner scope */
          __Pyx_DECREF_SET(__pyx_v_lst, ((PyObject*)__pyx_t_6));
          __pyx_t_6 = 0;

          /* "cupy/core/core.pyx":2011
 *                 # obj is Seq[cupy.ndarray]
 *                 lst = _flatten_list(obj)
 *                 if len(shape) == 1:             # <<<<<<<<<<<<<<
 *                     # convert each scalar (0-dim) ndarray to 1-dim
 *                     lst = [cupy.expand_dims(x, 0) for x in lst]
 */
        }

        /* "cupy/core/core.pyx":2015
 *                     lst = [cupy.expand_dims(x, 0) for x in lst]
 * 
 *                 a = (_manipulation.concatenate_method(lst, 0)             # <<<<<<<<<<<<<<
 *                                   .reshape(shape)
 *                                   .astype(dtype, order=order, copy=False))
 */
        __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation_concatenate_method(__pyx_v_lst, 0, 0, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2015, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);

        /* "cupy/core/core.pyx":2016
 * 
 *                 a = (_manipulation.concatenate_method(lst, 0)
 *                                   .reshape(shape)             # <<<<<<<<<<<<<<
 *                                   .astype(dtype, order=order, copy=False))
 *             else:
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2016, __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_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2016, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_4)) {
            PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_shape};
            __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2016, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_6);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
            PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_shape};
            __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2016, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_6);
          } else
          #endif
          {
            __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2016, __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_INCREF(__pyx_v_shape);
            __Pyx_GIVEREF(__pyx_v_shape);
            PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_shape);
            __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2016, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/core/core.pyx":2017
 *                 a = (_manipulation.concatenate_method(lst, 0)
 *                                   .reshape(shape)
 *                                   .astype(dtype, order=order, copy=False))             # <<<<<<<<<<<<<<
 *             else:
 *                 # should not be reached here
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2017, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2017, __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_12 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2017, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 2017, __pyx_L1_error)
        if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 2017, __pyx_L1_error)
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2017, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2017, __pyx_L1_error)
        __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
        __pyx_t_3 = 0;

        /* "cupy/core/core.pyx":2008
 *                 a = _send_numpy_array_list_to_gpu(
 *                     obj, elem_dtype, dtype, shape, order, ndmin)
 *             elif issubclass(elem_type, ndarray):             # <<<<<<<<<<<<<<
 *                 # obj is Seq[cupy.ndarray]
 *                 lst = _flatten_list(obj)
 */
        goto __pyx_L18;
      }

      /* "cupy/core/core.pyx":2020
 *             else:
 *                 # should not be reached here
 *                 assert issubclass(elem_type, (numpy.ndarray, ndarray))             # <<<<<<<<<<<<<<
 *         else:
 *             # obj is:
 */
      /*else*/ {
        #ifndef CYTHON_WITHOUT_ASSERTIONS
        if (unlikely(!Py_OptimizeFlag)) {
          __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2020, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2020, __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(0, 2020, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_12);
          PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_12);
          __Pyx_INCREF(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
          __Pyx_GIVEREF(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
          PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
          __pyx_t_12 = 0;
          __pyx_t_9 = PyObject_IsSubclass(__pyx_v_elem_type, __pyx_t_3); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 2020, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!(__pyx_t_9 != 0))) {
            PyErr_SetNone(PyExc_AssertionError);
            __PYX_ERR(0, 2020, __pyx_L1_error)
          }
        }
        #endif
      }
      __pyx_L18:;

      /* "cupy/core/core.pyx":1986
 *     else:  # obj is sequence, numpy array, scalar or the other type of object
 *         shape, elem_type, elem_dtype = _get_concat_shape(obj)
 *         if shape is not None and shape[-1] != 0:             # <<<<<<<<<<<<<<
 *             # obj is a non-empty sequence of ndarrays which share same shape
 *             # and dtype
 */
      goto __pyx_L10;
    }

    /* "cupy/core/core.pyx":2031
 *             # fallback to numpy array and send it to GPU
 *             # Note: dtype might not be numpy.dtype in this place
 *             a = _send_object_to_gpu(obj, dtype, order, ndmin)             # <<<<<<<<<<<<<<
 * 
 *     return a
 */
    /*else*/ {
      __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core__send_object_to_gpu(__pyx_v_obj, __pyx_v_dtype, __pyx_v_order, __pyx_v_ndmin)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2031, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
      __pyx_t_3 = 0;
    }
    __pyx_L10:;
  }
  __pyx_L5:;

  /* "cupy/core/core.pyx":2033
 *             a = _send_object_to_gpu(obj, dtype, order, ndmin)
 * 
 *     return a             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  if (unlikely(!__pyx_v_a)) { __Pyx_RaiseUnboundLocalError("a"); __PYX_ERR(0, 2033, __pyx_L1_error) }
  __Pyx_INCREF(((PyObject *)__pyx_v_a));
  __pyx_r = __pyx_v_a;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1954
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, 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_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_14);
  __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(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_elem_type);
  __Pyx_XDECREF(__pyx_v_elem_dtype);
  __Pyx_XDECREF(__pyx_v_lst);
  __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_x);
  __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_11array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_10array[] = "array(obj, dtype=None, bool copy=True, order=u'K', bool subok=False, Py_ssize_t ndmin=0) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_11array(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_u_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, 1954, __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, 1954, __pyx_L3_error)
    } else {
      __pyx_v_copy = ((int)1);
    }
    __pyx_v_order = 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, 1955, __pyx_L3_error)
    } else {

      /* "cupy/core/core.pyx":1955
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, order='K',
 *                     bint subok=False, Py_ssize_t ndmin=0):             # <<<<<<<<<<<<<<
 *     # TODO(beam2d): Support subok options
 *     cdef Py_ssize_t ndim
 */
      __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, 1955, __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, 1954, __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:;
  __pyx_r = __pyx_pf_4cupy_4core_4core_10array(__pyx_self, __pyx_v_obj, __pyx_v_dtype, __pyx_v_copy, __pyx_v_order, __pyx_v_subok, __pyx_v_ndmin);

  /* "cupy/core/core.pyx":1954
 * # -----------------------------------------------------------------------------
 * 
 * cpdef ndarray array(obj, dtype=None, bint copy=True, order='K',             # <<<<<<<<<<<<<<
 *                     bint subok=False, Py_ssize_t ndmin=0):
 *     # TODO(beam2d): Support subok options
 */

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

static PyObject *__pyx_pf_4cupy_4core_4core_10array(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, 1954, __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":2036
 * 
 * 
 * cdef tuple _get_concat_shape(object obj):             # <<<<<<<<<<<<<<
 *     # Returns a tuple of the following:
 *     # 1. concatenated shape if it can be converted to a single CuPy array by
 */

static PyObject *__pyx_f_4cupy_4core_4core__get_concat_shape(PyObject *__pyx_v_obj) {
  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("_get_concat_shape", 0);

  /* "cupy/core/core.pyx":2044
 *     # 2. type of the first item in the object
 *     # 3. dtype if the object is an array
 *     if isinstance(obj, (list, tuple)):             # <<<<<<<<<<<<<<
 *         return _get_concat_shape_impl(obj)
 *     return (None, None, None)
 */
  __pyx_t_2 = PyList_Check(__pyx_v_obj); 
  __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 = PyTuple_Check(__pyx_v_obj); 
  __pyx_t_2 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2045
 *     # 3. dtype if the object is an array
 *     if isinstance(obj, (list, tuple)):
 *         return _get_concat_shape_impl(obj)             # <<<<<<<<<<<<<<
 *     return (None, None, None)
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__get_concat_shape_impl(__pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2045, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2044
 *     # 2. type of the first item in the object
 *     # 3. dtype if the object is an array
 *     if isinstance(obj, (list, tuple)):             # <<<<<<<<<<<<<<
 *         return _get_concat_shape_impl(obj)
 *     return (None, None, None)
 */
  }

  /* "cupy/core/core.pyx":2046
 *     if isinstance(obj, (list, tuple)):
 *         return _get_concat_shape_impl(obj)
 *     return (None, None, None)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_tuple__39);
  __pyx_r = __pyx_tuple__39;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2036
 * 
 * 
 * cdef tuple _get_concat_shape(object obj):             # <<<<<<<<<<<<<<
 *     # Returns a tuple of the following:
 *     # 1. concatenated shape if it can be converted to a single CuPy array by
 */

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

/* "cupy/core/core.pyx":2049
 * 
 * 
 * cdef tuple _get_concat_shape_impl(object obj):             # <<<<<<<<<<<<<<
 *     cdef obj_type = type(obj)
 *     if issubclass(obj_type, (numpy.ndarray, ndarray)):
 */

static PyObject *__pyx_f_4cupy_4core_4core__get_concat_shape_impl(PyObject *__pyx_v_obj) {
  PyObject *__pyx_v_obj_type = 0;
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_typ = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_elem = NULL;
  PyObject *__pyx_v_elem_shape = NULL;
  PyObject *__pyx_v_elem_type = NULL;
  PyObject *__pyx_v_elem_dtype = 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;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("_get_concat_shape_impl", 0);

  /* "cupy/core/core.pyx":2050
 * 
 * cdef tuple _get_concat_shape_impl(object obj):
 *     cdef obj_type = type(obj)             # <<<<<<<<<<<<<<
 *     if issubclass(obj_type, (numpy.ndarray, ndarray)):
 *         # obj.shape is () when obj.ndim == 0
 */
  __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_obj)));
  __pyx_v_obj_type = ((PyObject *)Py_TYPE(__pyx_v_obj));

  /* "cupy/core/core.pyx":2051
 * cdef tuple _get_concat_shape_impl(object obj):
 *     cdef obj_type = type(obj)
 *     if issubclass(obj_type, (numpy.ndarray, ndarray)):             # <<<<<<<<<<<<<<
 *         # obj.shape is () when obj.ndim == 0
 *         return (obj.shape, obj_type, obj.dtype)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2051, __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, 2051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
  __pyx_t_2 = 0;
  __pyx_t_3 = PyObject_IsSubclass(__pyx_v_obj_type, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 2051, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/core.pyx":2053
 *     if issubclass(obj_type, (numpy.ndarray, ndarray)):
 *         # obj.shape is () when obj.ndim == 0
 *         return (obj.shape, obj_type, obj.dtype)             # <<<<<<<<<<<<<<
 *     if isinstance(obj, (list, tuple)):
 *         shape = None
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2053, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2053, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2053, __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(__pyx_v_obj_type);
    __Pyx_GIVEREF(__pyx_v_obj_type);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_obj_type);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_2);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2051
 * cdef tuple _get_concat_shape_impl(object obj):
 *     cdef obj_type = type(obj)
 *     if issubclass(obj_type, (numpy.ndarray, ndarray)):             # <<<<<<<<<<<<<<
 *         # obj.shape is () when obj.ndim == 0
 *         return (obj.shape, obj_type, obj.dtype)
 */
  }

  /* "cupy/core/core.pyx":2054
 *         # obj.shape is () when obj.ndim == 0
 *         return (obj.shape, obj_type, obj.dtype)
 *     if isinstance(obj, (list, tuple)):             # <<<<<<<<<<<<<<
 *         shape = None
 *         typ = None
 */
  __pyx_t_3 = PyList_Check(__pyx_v_obj); 
  __pyx_t_6 = (__pyx_t_3 != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_4 = __pyx_t_6;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_6 = PyTuple_Check(__pyx_v_obj); 
  __pyx_t_3 = (__pyx_t_6 != 0);
  __pyx_t_4 = __pyx_t_3;
  __pyx_L5_bool_binop_done:;
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2055
 *         return (obj.shape, obj_type, obj.dtype)
 *     if isinstance(obj, (list, tuple)):
 *         shape = None             # <<<<<<<<<<<<<<
 *         typ = None
 *         dtype = None
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_shape = Py_None;

    /* "cupy/core/core.pyx":2056
 *     if isinstance(obj, (list, tuple)):
 *         shape = None
 *         typ = None             # <<<<<<<<<<<<<<
 *         dtype = None
 *         for elem in obj:
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_typ = Py_None;

    /* "cupy/core/core.pyx":2057
 *         shape = None
 *         typ = None
 *         dtype = None             # <<<<<<<<<<<<<<
 *         for elem in obj:
 *             # Find the head recursively if obj is a nested built-in list
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_dtype = Py_None;

    /* "cupy/core/core.pyx":2058
 *         typ = None
 *         dtype = None
 *         for elem in obj:             # <<<<<<<<<<<<<<
 *             # Find the head recursively if obj is a nested built-in list
 *             elem_shape, elem_type, elem_dtype = _get_concat_shape_impl(elem)
 */
    if (likely(PyList_CheckExact(__pyx_v_obj)) || PyTuple_CheckExact(__pyx_v_obj)) {
      __pyx_t_5 = __pyx_v_obj; __Pyx_INCREF(__pyx_t_5); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2058, __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, 2058, __pyx_L1_error)
    }
    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_2 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2058, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2058, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2058, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2058, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_8(__pyx_t_5);
        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, 2058, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":2060
 *         for elem in obj:
 *             # Find the head recursively if obj is a nested built-in list
 *             elem_shape, elem_type, elem_dtype = _get_concat_shape_impl(elem)             # <<<<<<<<<<<<<<
 * 
 *             # Use shape of the first element as the common shape.
 */
      __pyx_t_2 = __pyx_f_4cupy_4core_4core__get_concat_shape_impl(__pyx_v_elem); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2060, __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 != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 2060, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); 
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_10);
        #else
        __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2060, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2060, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2060, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 2060, __pyx_L1_error)
      }
      __Pyx_XDECREF_SET(__pyx_v_elem_shape, __pyx_t_1);
      __pyx_t_1 = 0;
      __Pyx_XDECREF_SET(__pyx_v_elem_type, __pyx_t_9);
      __pyx_t_9 = 0;
      __Pyx_XDECREF_SET(__pyx_v_elem_dtype, __pyx_t_10);
      __pyx_t_10 = 0;

      /* "cupy/core/core.pyx":2063
 * 
 *             # Use shape of the first element as the common shape.
 *             if shape is None:             # <<<<<<<<<<<<<<
 *                 shape = elem_shape
 *                 typ = elem_type
 */
      __pyx_t_3 = (__pyx_v_shape == Py_None);
      __pyx_t_4 = (__pyx_t_3 != 0);
      if (__pyx_t_4) {

        /* "cupy/core/core.pyx":2064
 *             # Use shape of the first element as the common shape.
 *             if shape is None:
 *                 shape = elem_shape             # <<<<<<<<<<<<<<
 *                 typ = elem_type
 *                 dtype = elem_dtype
 */
        __Pyx_INCREF(__pyx_v_elem_shape);
        __Pyx_DECREF_SET(__pyx_v_shape, __pyx_v_elem_shape);

        /* "cupy/core/core.pyx":2065
 *             if shape is None:
 *                 shape = elem_shape
 *                 typ = elem_type             # <<<<<<<<<<<<<<
 *                 dtype = elem_dtype
 * 
 */
        __Pyx_INCREF(__pyx_v_elem_type);
        __Pyx_DECREF_SET(__pyx_v_typ, __pyx_v_elem_type);

        /* "cupy/core/core.pyx":2066
 *                 shape = elem_shape
 *                 typ = elem_type
 *                 dtype = elem_dtype             # <<<<<<<<<<<<<<
 * 
 *             # `elem` is not concatable or the shape and dtype does not match
 */
        __Pyx_INCREF(__pyx_v_elem_dtype);
        __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_v_elem_dtype);

        /* "cupy/core/core.pyx":2063
 * 
 *             # Use shape of the first element as the common shape.
 *             if shape is None:             # <<<<<<<<<<<<<<
 *                 shape = elem_shape
 *                 typ = elem_type
 */
      }

      /* "cupy/core/core.pyx":2070
 *             # `elem` is not concatable or the shape and dtype does not match
 *             # with siblings.
 *             if (elem_shape is None             # <<<<<<<<<<<<<<
 *                     or shape != elem_shape
 *                     or dtype != elem_dtype):
 */
      __pyx_t_3 = (__pyx_v_elem_shape == Py_None);
      __pyx_t_6 = (__pyx_t_3 != 0);
      if (!__pyx_t_6) {
      } else {
        __pyx_t_4 = __pyx_t_6;
        goto __pyx_L11_bool_binop_done;
      }

      /* "cupy/core/core.pyx":2071
 *             # with siblings.
 *             if (elem_shape is None
 *                     or shape != elem_shape             # <<<<<<<<<<<<<<
 *                     or dtype != elem_dtype):
 *                 return (None, obj_type, None)
 */
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_shape, __pyx_v_elem_shape, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2071, __pyx_L1_error)
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 2071, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!__pyx_t_6) {
      } else {
        __pyx_t_4 = __pyx_t_6;
        goto __pyx_L11_bool_binop_done;
      }

      /* "cupy/core/core.pyx":2072
 *             if (elem_shape is None
 *                     or shape != elem_shape
 *                     or dtype != elem_dtype):             # <<<<<<<<<<<<<<
 *                 return (None, obj_type, None)
 * 
 */
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_dtype, __pyx_v_elem_dtype, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2072, __pyx_L1_error)
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 2072, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_4 = __pyx_t_6;
      __pyx_L11_bool_binop_done:;

      /* "cupy/core/core.pyx":2070
 *             # `elem` is not concatable or the shape and dtype does not match
 *             # with siblings.
 *             if (elem_shape is None             # <<<<<<<<<<<<<<
 *                     or shape != elem_shape
 *                     or dtype != elem_dtype):
 */
      if (__pyx_t_4) {

        /* "cupy/core/core.pyx":2073
 *                     or shape != elem_shape
 *                     or dtype != elem_dtype):
 *                 return (None, obj_type, None)             # <<<<<<<<<<<<<<
 * 
 *         if shape is None:
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2073, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(Py_None);
        __Pyx_GIVEREF(Py_None);
        PyTuple_SET_ITEM(__pyx_t_2, 0, Py_None);
        __Pyx_INCREF(__pyx_v_obj_type);
        __Pyx_GIVEREF(__pyx_v_obj_type);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_obj_type);
        __Pyx_INCREF(Py_None);
        __Pyx_GIVEREF(Py_None);
        PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
        __pyx_r = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L0;

        /* "cupy/core/core.pyx":2070
 *             # `elem` is not concatable or the shape and dtype does not match
 *             # with siblings.
 *             if (elem_shape is None             # <<<<<<<<<<<<<<
 *                     or shape != elem_shape
 *                     or dtype != elem_dtype):
 */
      }

      /* "cupy/core/core.pyx":2058
 *         typ = None
 *         dtype = None
 *         for elem in obj:             # <<<<<<<<<<<<<<
 *             # Find the head recursively if obj is a nested built-in list
 *             elem_shape, elem_type, elem_dtype = _get_concat_shape_impl(elem)
 */
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2075
 *                 return (None, obj_type, None)
 * 
 *         if shape is None:             # <<<<<<<<<<<<<<
 *             shape = ()
 *         return (
 */
    __pyx_t_4 = (__pyx_v_shape == Py_None);
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":2076
 * 
 *         if shape is None:
 *             shape = ()             # <<<<<<<<<<<<<<
 *         return (
 *             (len(obj),) + shape,
 */
      __Pyx_INCREF(__pyx_empty_tuple);
      __Pyx_DECREF_SET(__pyx_v_shape, __pyx_empty_tuple);

      /* "cupy/core/core.pyx":2075
 *                 return (None, obj_type, None)
 * 
 *         if shape is None:             # <<<<<<<<<<<<<<
 *             shape = ()
 *         return (
 */
    }

    /* "cupy/core/core.pyx":2077
 *         if shape is None:
 *             shape = ()
 *         return (             # <<<<<<<<<<<<<<
 *             (len(obj),) + shape,
 *             typ,
 */
    __Pyx_XDECREF(__pyx_r);

    /* "cupy/core/core.pyx":2078
 *             shape = ()
 *         return (
 *             (len(obj),) + shape,             # <<<<<<<<<<<<<<
 *             typ,
 *             dtype)
 */
    __pyx_t_7 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2078, __pyx_L1_error)
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2078, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2078, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Add(__pyx_t_2, __pyx_v_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2078, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2080
 *             (len(obj),) + shape,
 *             typ,
 *             dtype)             # <<<<<<<<<<<<<<
 *     # scalar or object
 *     return (None, obj_type, None)
 */
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2078, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_typ);
    __Pyx_GIVEREF(__pyx_v_typ);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_typ);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_dtype);
    __pyx_t_5 = 0;
    __pyx_r = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2054
 *         # obj.shape is () when obj.ndim == 0
 *         return (obj.shape, obj_type, obj.dtype)
 *     if isinstance(obj, (list, tuple)):             # <<<<<<<<<<<<<<
 *         shape = None
 *         typ = None
 */
  }

  /* "cupy/core/core.pyx":2082
 *             dtype)
 *     # scalar or object
 *     return (None, obj_type, None)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2082, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_2, 0, Py_None);
  __Pyx_INCREF(__pyx_v_obj_type);
  __Pyx_GIVEREF(__pyx_v_obj_type);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_obj_type);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
  __pyx_r = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2049
 * 
 * 
 * cdef tuple _get_concat_shape_impl(object obj):             # <<<<<<<<<<<<<<
 *     cdef obj_type = type(obj)
 *     if issubclass(obj_type, (numpy.ndarray, ndarray)):
 */

  /* 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_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.core.core._get_concat_shape_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_obj_type);
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_typ);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XDECREF(__pyx_v_elem_shape);
  __Pyx_XDECREF(__pyx_v_elem_type);
  __Pyx_XDECREF(__pyx_v_elem_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2085
 * 
 * 
 * cdef list _flatten_list(object obj):             # <<<<<<<<<<<<<<
 *     ret = []
 *     if isinstance(obj, (list, tuple)):
 */

static PyObject *__pyx_f_4cupy_4core_4core__flatten_list(PyObject *__pyx_v_obj) {
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_v_elem = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("_flatten_list", 0);

  /* "cupy/core/core.pyx":2086
 * 
 * cdef list _flatten_list(object obj):
 *     ret = []             # <<<<<<<<<<<<<<
 *     if isinstance(obj, (list, tuple)):
 *         for elem in obj:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2087
 * cdef list _flatten_list(object obj):
 *     ret = []
 *     if isinstance(obj, (list, tuple)):             # <<<<<<<<<<<<<<
 *         for elem in obj:
 *             ret += _flatten_list(elem)
 */
  __pyx_t_3 = PyList_Check(__pyx_v_obj); 
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = PyTuple_Check(__pyx_v_obj); 
  __pyx_t_3 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2088
 *     ret = []
 *     if isinstance(obj, (list, tuple)):
 *         for elem in obj:             # <<<<<<<<<<<<<<
 *             ret += _flatten_list(elem)
 *         return ret
 */
    if (likely(PyList_CheckExact(__pyx_v_obj)) || PyTuple_CheckExact(__pyx_v_obj)) {
      __pyx_t_1 = __pyx_v_obj; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2088, __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(0, 2088, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_5 >= 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_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 2088, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2088, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        } else {
          if (__pyx_t_5 >= 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_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 2088, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2088, __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(0, 2088, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "cupy/core/core.pyx":2089
 *     if isinstance(obj, (list, tuple)):
 *         for elem in obj:
 *             ret += _flatten_list(elem)             # <<<<<<<<<<<<<<
 *         return ret
 *     return [obj]
 */
      __pyx_t_7 = __pyx_f_4cupy_4core_4core__flatten_list(__pyx_v_elem); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2089, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyNumber_InPlaceAdd(__pyx_v_ret, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2089, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF_SET(__pyx_v_ret, ((PyObject*)__pyx_t_8));
      __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":2088
 *     ret = []
 *     if isinstance(obj, (list, tuple)):
 *         for elem in obj:             # <<<<<<<<<<<<<<
 *             ret += _flatten_list(elem)
 *         return ret
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2090
 *         for elem in obj:
 *             ret += _flatten_list(elem)
 *         return ret             # <<<<<<<<<<<<<<
 *     return [obj]
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_ret);
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2087
 * cdef list _flatten_list(object obj):
 *     ret = []
 *     if isinstance(obj, (list, tuple)):             # <<<<<<<<<<<<<<
 *         for elem in obj:
 *             ret += _flatten_list(elem)
 */
  }

  /* "cupy/core/core.pyx":2091
 *             ret += _flatten_list(elem)
 *         return ret
 *     return [obj]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2091, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_obj);
  __Pyx_GIVEREF(__pyx_v_obj);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_obj);
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2085
 * 
 * 
 * cdef list _flatten_list(object obj):             # <<<<<<<<<<<<<<
 *     ret = []
 *     if isinstance(obj, (list, tuple)):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.core.core._flatten_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2094
 * 
 * 
 * cdef ndarray _send_object_to_gpu(obj, dtype, order, Py_ssize_t ndmin):             # <<<<<<<<<<<<<<
 *     if order is not None and len(order) >= 1 and order[0] in 'KAka':
 *         if isinstance(obj, numpy.ndarray) and obj.flags.f_contiguous:
 */

static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__send_object_to_gpu(PyObject *__pyx_v_obj, PyObject *__pyx_v_dtype, PyObject *__pyx_v_order, Py_ssize_t __pyx_v_ndmin) {
  PyObject *__pyx_v_a_cpu = NULL;
  PyObject *__pyx_v_a_dtype = NULL;
  std::vector<Py_ssize_t>  __pyx_v_a_shape;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  Py_ssize_t __pyx_v_nbytes;
  PyObject *__pyx_v_stream = NULL;
  struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *__pyx_v_mem = 0;
  PyObject *__pyx_v_src_cpu = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  std::vector<Py_ssize_t>  __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("_send_object_to_gpu", 0);
  __Pyx_INCREF(__pyx_v_order);

  /* "cupy/core/core.pyx":2095
 * 
 * cdef ndarray _send_object_to_gpu(obj, dtype, order, Py_ssize_t ndmin):
 *     if order is not None and len(order) >= 1 and order[0] in 'KAka':             # <<<<<<<<<<<<<<
 *         if isinstance(obj, numpy.ndarray) and obj.flags.f_contiguous:
 *             order = 'F'
 */
  __pyx_t_2 = (__pyx_v_order != 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_Length(__pyx_v_order); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2095, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_t_4 >= 1) != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_order, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2095, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = (__Pyx_PyUnicode_ContainsTF(__pyx_t_5, __pyx_n_u_KAka, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2095, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2096
 * cdef ndarray _send_object_to_gpu(obj, dtype, order, Py_ssize_t ndmin):
 *     if order is not None and len(order) >= 1 and order[0] in 'KAka':
 *         if isinstance(obj, numpy.ndarray) and obj.flags.f_contiguous:             # <<<<<<<<<<<<<<
 *             order = 'F'
 *         else:
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2096, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2096, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_6); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 2096, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_3 = (__pyx_t_2 != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_1 = __pyx_t_3;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_flags); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2096, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_f_contiguous); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2096, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2096, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_1 = __pyx_t_3;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":2097
 *     if order is not None and len(order) >= 1 and order[0] in 'KAka':
 *         if isinstance(obj, numpy.ndarray) and obj.flags.f_contiguous:
 *             order = 'F'             # <<<<<<<<<<<<<<
 *         else:
 *             order = 'C'
 */
      __Pyx_INCREF(__pyx_n_u_F);
      __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_u_F);

      /* "cupy/core/core.pyx":2096
 * cdef ndarray _send_object_to_gpu(obj, dtype, order, Py_ssize_t ndmin):
 *     if order is not None and len(order) >= 1 and order[0] in 'KAka':
 *         if isinstance(obj, numpy.ndarray) and obj.flags.f_contiguous:             # <<<<<<<<<<<<<<
 *             order = 'F'
 *         else:
 */
      goto __pyx_L7;
    }

    /* "cupy/core/core.pyx":2099
 *             order = 'F'
 *         else:
 *             order = 'C'             # <<<<<<<<<<<<<<
 *     a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,
 *                         ndmin=ndmin)
 */
    /*else*/ {
      __Pyx_INCREF(__pyx_n_u_C);
      __Pyx_DECREF_SET(__pyx_v_order, __pyx_n_u_C);
    }
    __pyx_L7:;

    /* "cupy/core/core.pyx":2095
 * 
 * cdef ndarray _send_object_to_gpu(obj, dtype, order, Py_ssize_t ndmin):
 *     if order is not None and len(order) >= 1 and order[0] in 'KAka':             # <<<<<<<<<<<<<<
 *         if isinstance(obj, numpy.ndarray) and obj.flags.f_contiguous:
 *             order = 'F'
 */
  }

  /* "cupy/core/core.pyx":2100
 *         else:
 *             order = 'C'
 *     a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,             # <<<<<<<<<<<<<<
 *                         ndmin=ndmin)
 *     a_dtype = a_cpu.dtype  # converted to numpy.dtype
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_obj);
  __Pyx_GIVEREF(__pyx_v_obj);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_obj);
  __pyx_t_7 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 2100, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 2100, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 2100, __pyx_L1_error)

  /* "cupy/core/core.pyx":2101
 *             order = 'C'
 *     a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,
 *                         ndmin=ndmin)             # <<<<<<<<<<<<<<
 *     a_dtype = a_cpu.dtype  # converted to numpy.dtype
 *     if a_dtype.char not in '?bhilqBHILQefdFD':
 */
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_ndmin); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_ndmin, __pyx_t_8) < 0) __PYX_ERR(0, 2100, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2100
 *         else:
 *             order = 'C'
 *     a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,             # <<<<<<<<<<<<<<
 *                         ndmin=ndmin)
 *     a_dtype = a_cpu.dtype  # converted to numpy.dtype
 */
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_a_cpu = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2102
 *     a_cpu = numpy.array(obj, dtype=dtype, copy=False, order=order,
 *                         ndmin=ndmin)
 *     a_dtype = a_cpu.dtype  # converted to numpy.dtype             # <<<<<<<<<<<<<<
 *     if a_dtype.char not in '?bhilqBHILQefdFD':
 *         raise ValueError('Unsupported dtype %s' % a_dtype)
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2102, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v_a_dtype = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2103
 *                         ndmin=ndmin)
 *     a_dtype = a_cpu.dtype  # converted to numpy.dtype
 *     if a_dtype.char not in '?bhilqBHILQefdFD':             # <<<<<<<<<<<<<<
 *         raise ValueError('Unsupported dtype %s' % a_dtype)
 *     cdef vector.vector[Py_ssize_t] a_shape = a_cpu.shape
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_dtype, __pyx_n_s_char); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2103, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = (__Pyx_PyUnicode_ContainsTF(__pyx_t_8, __pyx_kp_u_bhilqBHILQefdFD, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2103, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_3)) {

    /* "cupy/core/core.pyx":2104
 *     a_dtype = a_cpu.dtype  # converted to numpy.dtype
 *     if a_dtype.char not in '?bhilqBHILQefdFD':
 *         raise ValueError('Unsupported dtype %s' % a_dtype)             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] a_shape = a_cpu.shape
 *     cdef ndarray a = ndarray(a_shape, dtype=a_dtype, order=order)
 */
    __pyx_t_8 = PyUnicode_Format(__pyx_kp_u_Unsupported_dtype_s, __pyx_v_a_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2104, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2104, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_Raise(__pyx_t_7, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __PYX_ERR(0, 2104, __pyx_L1_error)

    /* "cupy/core/core.pyx":2103
 *                         ndmin=ndmin)
 *     a_dtype = a_cpu.dtype  # converted to numpy.dtype
 *     if a_dtype.char not in '?bhilqBHILQefdFD':             # <<<<<<<<<<<<<<
 *         raise ValueError('Unsupported dtype %s' % a_dtype)
 *     cdef vector.vector[Py_ssize_t] a_shape = a_cpu.shape
 */
  }

  /* "cupy/core/core.pyx":2105
 *     if a_dtype.char not in '?bhilqBHILQefdFD':
 *         raise ValueError('Unsupported dtype %s' % a_dtype)
 *     cdef vector.vector[Py_ssize_t] a_shape = a_cpu.shape             # <<<<<<<<<<<<<<
 *     cdef ndarray a = ndarray(a_shape, dtype=a_dtype, order=order)
 *     if a_cpu.ndim == 0:
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_shape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2105, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_a_shape = __pyx_t_9;

  /* "cupy/core/core.pyx":2106
 *         raise ValueError('Unsupported dtype %s' % a_dtype)
 *     cdef vector.vector[Py_ssize_t] a_shape = a_cpu.shape
 *     cdef ndarray a = ndarray(a_shape, dtype=a_dtype, order=order)             # <<<<<<<<<<<<<<
 *     if a_cpu.ndim == 0:
 *         a.fill(a_cpu)
 */
  __pyx_t_7 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_a_shape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2106, __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 = 0;
  __pyx_t_7 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_v_a_dtype) < 0) __PYX_ERR(0, 2106, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 2106, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2107
 *     cdef vector.vector[Py_ssize_t] a_shape = a_cpu.shape
 *     cdef ndarray a = ndarray(a_shape, dtype=a_dtype, order=order)
 *     if a_cpu.ndim == 0:             # <<<<<<<<<<<<<<
 *         a.fill(a_cpu)
 *         return a
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_ndim); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = __Pyx_PyInt_EqObjC(__pyx_t_5, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2108
 *     cdef ndarray a = ndarray(a_shape, dtype=a_dtype, order=order)
 *     if a_cpu.ndim == 0:
 *         a.fill(a_cpu)             # <<<<<<<<<<<<<<
 *         return a
 *     cdef Py_ssize_t nbytes = a.nbytes
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->fill(__pyx_v_a, __pyx_v_a_cpu, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2109
 *     if a_cpu.ndim == 0:
 *         a.fill(a_cpu)
 *         return a             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t nbytes = a.nbytes
 * 
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2107
 *     cdef vector.vector[Py_ssize_t] a_shape = a_cpu.shape
 *     cdef ndarray a = ndarray(a_shape, dtype=a_dtype, order=order)
 *     if a_cpu.ndim == 0:             # <<<<<<<<<<<<<<
 *         a.fill(a_cpu)
 *         return a
 */
  }

  /* "cupy/core/core.pyx":2110
 *         a.fill(a_cpu)
 *         return a
 *     cdef Py_ssize_t nbytes = a.nbytes             # <<<<<<<<<<<<<<
 * 
 *     stream = stream_module.get_current_stream()
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2110, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_nbytes = __pyx_t_4;

  /* "cupy/core/core.pyx":2112
 *     cdef Py_ssize_t nbytes = a.nbytes
 * 
 *     stream = stream_module.get_current_stream()             # <<<<<<<<<<<<<<
 *     cdef pinned_memory.PinnedMemoryPointer mem = (
 *         _alloc_async_transfer_buffer(nbytes))
 */
  __pyx_t_7 = __pyx_f_4cupy_4cuda_6stream_get_current_stream(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_v_stream = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2114
 *     stream = stream_module.get_current_stream()
 *     cdef pinned_memory.PinnedMemoryPointer mem = (
 *         _alloc_async_transfer_buffer(nbytes))             # <<<<<<<<<<<<<<
 *     if mem is not None:
 *         src_cpu = numpy.frombuffer(mem, a_dtype, a_cpu.size)
 */
  __pyx_t_7 = __pyx_f_4cupy_4core_4core__alloc_async_transfer_buffer(__pyx_v_nbytes); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer))))) __PYX_ERR(0, 2114, __pyx_L1_error)
  __pyx_v_mem = ((struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2115
 *     cdef pinned_memory.PinnedMemoryPointer mem = (
 *         _alloc_async_transfer_buffer(nbytes))
 *     if mem is not None:             # <<<<<<<<<<<<<<
 *         src_cpu = numpy.frombuffer(mem, a_dtype, a_cpu.size)
 *         src_cpu[:] = a_cpu.ravel(order)
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_mem) != Py_None);
  __pyx_t_1 = (__pyx_t_3 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2116
 *         _alloc_async_transfer_buffer(nbytes))
 *     if mem is not None:
 *         src_cpu = numpy.frombuffer(mem, a_dtype, a_cpu.size)             # <<<<<<<<<<<<<<
 *         src_cpu[:] = a_cpu.ravel(order)
 *         a.data.copy_from_host_async(ctypes.c_void_p(mem.ptr), nbytes)
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2116, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2116, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2116, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(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);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, ((PyObject *)__pyx_v_mem), __pyx_v_a_dtype, __pyx_t_5};
      __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2116, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __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[4] = {__pyx_t_6, ((PyObject *)__pyx_v_mem), __pyx_v_a_dtype, __pyx_t_5};
      __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2116, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2116, __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(((PyObject *)__pyx_v_mem));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mem));
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, ((PyObject *)__pyx_v_mem));
      __Pyx_INCREF(__pyx_v_a_dtype);
      __Pyx_GIVEREF(__pyx_v_a_dtype);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_v_a_dtype);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2116, __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_v_src_cpu = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2117
 *     if mem is not None:
 *         src_cpu = numpy.frombuffer(mem, a_dtype, a_cpu.size)
 *         src_cpu[:] = a_cpu.ravel(order)             # <<<<<<<<<<<<<<
 *         a.data.copy_from_host_async(ctypes.c_void_p(mem.ptr), nbytes)
 *         pinned_memory._add_to_watch_list(stream.record(), mem)
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_ravel); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (!__pyx_t_11) {
      __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_order); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2117, __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_11, __pyx_v_order};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2117, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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_11, __pyx_v_order};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2117, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_7);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2117, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_INCREF(__pyx_v_order);
        __Pyx_GIVEREF(__pyx_v_order);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_order);
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2117, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_src_cpu, __pyx_t_7, 0, 0, NULL, NULL, &__pyx_slice__40, 0, 0, 1) < 0) __PYX_ERR(0, 2117, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2118
 *         src_cpu = numpy.frombuffer(mem, a_dtype, a_cpu.size)
 *         src_cpu[:] = a_cpu.ravel(order)
 *         a.data.copy_from_host_async(ctypes.c_void_p(mem.ptr), nbytes)             # <<<<<<<<<<<<<<
 *         pinned_memory._add_to_watch_list(stream.record(), mem)
 *     else:
 */
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2118, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_c_void_p); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2118, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_mem->ptr); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2118, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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_7 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2118, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_7);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_8};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2118, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_8};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2118, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2118, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_8);
        __pyx_t_8 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2118, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_a->data->__pyx_vtab)->copy_from_host_async(__pyx_v_a->data, __pyx_t_7, __pyx_v_nbytes, 0, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2118, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2119
 *         src_cpu[:] = a_cpu.ravel(order)
 *         a.data.copy_from_host_async(ctypes.c_void_p(mem.ptr), nbytes)
 *         pinned_memory._add_to_watch_list(stream.record(), mem)             # <<<<<<<<<<<<<<
 *     else:
 *         a.data.copy_from_host(
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_stream, __pyx_n_s_record); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2119, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = NULL;
    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);
      }
    }
    if (__pyx_t_6) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2119, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2119, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __pyx_f_4cupy_4cuda_13pinned_memory__add_to_watch_list(__pyx_t_5, ((PyObject *)__pyx_v_mem), 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2119, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/core.pyx":2115
 *     cdef pinned_memory.PinnedMemoryPointer mem = (
 *         _alloc_async_transfer_buffer(nbytes))
 *     if mem is not None:             # <<<<<<<<<<<<<<
 *         src_cpu = numpy.frombuffer(mem, a_dtype, a_cpu.size)
 *         src_cpu[:] = a_cpu.ravel(order)
 */
    goto __pyx_L12;
  }

  /* "cupy/core/core.pyx":2121
 *         pinned_memory._add_to_watch_list(stream.record(), mem)
 *     else:
 *         a.data.copy_from_host(             # <<<<<<<<<<<<<<
 *             ctypes.c_void_p(a_cpu.__array_interface__['data'][0]),
 *             nbytes)
 */
  /*else*/ {

    /* "cupy/core/core.pyx":2122
 *     else:
 *         a.data.copy_from_host(
 *             ctypes.c_void_p(a_cpu.__array_interface__['data'][0]),             # <<<<<<<<<<<<<<
 *             nbytes)
 * 
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_c_void_p); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_array_interface); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = __Pyx_PyObject_Dict_GetItem(__pyx_t_5, __pyx_n_u_data); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2122, __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_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);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2122, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_7);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_5};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2122, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __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[2] = {__pyx_t_8, __pyx_t_5};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2122, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __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(0, 2122, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2122, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":2121
 *         pinned_memory._add_to_watch_list(stream.record(), mem)
 *     else:
 *         a.data.copy_from_host(             # <<<<<<<<<<<<<<
 *             ctypes.c_void_p(a_cpu.__array_interface__['data'][0]),
 *             nbytes)
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_a->data->__pyx_vtab)->copy_from_host(__pyx_v_a->data, __pyx_t_7, __pyx_v_nbytes, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __pyx_L12:;

  /* "cupy/core/core.pyx":2125
 *             nbytes)
 * 
 *     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":2094
 * 
 * 
 * cdef ndarray _send_object_to_gpu(obj, dtype, order, Py_ssize_t ndmin):             # <<<<<<<<<<<<<<
 *     if order is not None and len(order) >= 1 and order[0] in 'KAka':
 *         if isinstance(obj, numpy.ndarray) and obj.flags.f_contiguous:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core._send_object_to_gpu", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_a_cpu);
  __Pyx_XDECREF(__pyx_v_a_dtype);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_stream);
  __Pyx_XDECREF((PyObject *)__pyx_v_mem);
  __Pyx_XDECREF(__pyx_v_src_cpu);
  __Pyx_XDECREF(__pyx_v_order);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2128
 * 
 * 
 * cdef ndarray _send_numpy_array_list_to_gpu(             # <<<<<<<<<<<<<<
 *         list arrays, src_dtype, dst_dtype,
 *         const vector.vector[Py_ssize_t]& shape,
 */

static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__send_numpy_array_list_to_gpu(PyObject *__pyx_v_arrays, PyObject *__pyx_v_src_dtype, PyObject *__pyx_v_dst_dtype, std::vector<Py_ssize_t>  const &__pyx_v_shape, PyObject *__pyx_v_order, Py_ssize_t __pyx_v_ndmin) {
  PyObject *__pyx_v_a_dtype = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  size_t __pyx_v_itemcount;
  size_t __pyx_v_nbytes;
  PyObject *__pyx_v_stream = NULL;
  struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *__pyx_v_mem = 0;
  PyObject *__pyx_v_src_cpu = NULL;
  PyObject *__pyx_v_a_cpu = NULL;
  PyObject *__pyx_8genexpr5__pyx_v_e = 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;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("_send_numpy_array_list_to_gpu", 0);

  /* "cupy/core/core.pyx":2133
 *         order, Py_ssize_t ndmin):
 * 
 *     a_dtype = get_dtype(dst_dtype)  # convert to numpy.dtype             # <<<<<<<<<<<<<<
 *     if a_dtype.char not in '?bhilqBHILQefdFD':
 *         raise ValueError('Unsupported dtype %s' % a_dtype)
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_dst_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_a_dtype = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2134
 * 
 *     a_dtype = get_dtype(dst_dtype)  # convert to numpy.dtype
 *     if a_dtype.char not in '?bhilqBHILQefdFD':             # <<<<<<<<<<<<<<
 *         raise ValueError('Unsupported dtype %s' % a_dtype)
 *     cdef ndarray a  # allocate it after pinned memory is secured
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_dtype, __pyx_n_s_char); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyUnicode_ContainsTF(__pyx_t_1, __pyx_kp_u_bhilqBHILQefdFD, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2134, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (unlikely(__pyx_t_3)) {

    /* "cupy/core/core.pyx":2135
 *     a_dtype = get_dtype(dst_dtype)  # convert to numpy.dtype
 *     if a_dtype.char not in '?bhilqBHILQefdFD':
 *         raise ValueError('Unsupported dtype %s' % a_dtype)             # <<<<<<<<<<<<<<
 *     cdef ndarray a  # allocate it after pinned memory is secured
 *     cdef size_t itemcount = internal.prod(shape)
 */
    __pyx_t_1 = PyUnicode_Format(__pyx_kp_u_Unsupported_dtype_s, __pyx_v_a_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2135, __pyx_L1_error)

    /* "cupy/core/core.pyx":2134
 * 
 *     a_dtype = get_dtype(dst_dtype)  # convert to numpy.dtype
 *     if a_dtype.char not in '?bhilqBHILQefdFD':             # <<<<<<<<<<<<<<
 *         raise ValueError('Unsupported dtype %s' % a_dtype)
 *     cdef ndarray a  # allocate it after pinned memory is secured
 */
  }

  /* "cupy/core/core.pyx":2137
 *         raise ValueError('Unsupported dtype %s' % a_dtype)
 *     cdef ndarray a  # allocate it after pinned memory is secured
 *     cdef size_t itemcount = internal.prod(shape)             # <<<<<<<<<<<<<<
 *     cdef size_t nbytes = itemcount * a_dtype.itemsize
 * 
 */
  __pyx_v_itemcount = __pyx_f_4cupy_4core_8internal_prod(__pyx_v_shape, 0);

  /* "cupy/core/core.pyx":2138
 *     cdef ndarray a  # allocate it after pinned memory is secured
 *     cdef size_t itemcount = internal.prod(shape)
 *     cdef size_t nbytes = itemcount * a_dtype.itemsize             # <<<<<<<<<<<<<<
 * 
 *     stream = stream_module.get_current_stream()
 */
  __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_itemcount); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_6 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2138, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_nbytes = __pyx_t_6;

  /* "cupy/core/core.pyx":2140
 *     cdef size_t nbytes = itemcount * a_dtype.itemsize
 * 
 *     stream = stream_module.get_current_stream()             # <<<<<<<<<<<<<<
 *     cdef pinned_memory.PinnedMemoryPointer mem = (
 *         _alloc_async_transfer_buffer(nbytes))
 */
  __pyx_t_5 = __pyx_f_4cupy_4cuda_6stream_get_current_stream(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_stream = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2142
 *     stream = stream_module.get_current_stream()
 *     cdef pinned_memory.PinnedMemoryPointer mem = (
 *         _alloc_async_transfer_buffer(nbytes))             # <<<<<<<<<<<<<<
 *     cdef size_t offset, length
 *     if mem is not None:
 */
  __pyx_t_5 = __pyx_f_4cupy_4core_4core__alloc_async_transfer_buffer(__pyx_v_nbytes); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer))))) __PYX_ERR(0, 2142, __pyx_L1_error)
  __pyx_v_mem = ((struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2144
 *         _alloc_async_transfer_buffer(nbytes))
 *     cdef size_t offset, length
 *     if mem is not None:             # <<<<<<<<<<<<<<
 *         # write concatenated arrays to the pinned memory directly
 *         src_cpu = (
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_mem) != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2147
 *         # write concatenated arrays to the pinned memory directly
 *         src_cpu = (
 *             numpy.frombuffer(mem, a_dtype, itemcount)             # <<<<<<<<<<<<<<
 *             .reshape(shape, order=order))
 *         _concatenate_numpy_array(
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_itemcount); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        __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[4] = {__pyx_t_7, ((PyObject *)__pyx_v_mem), __pyx_v_a_dtype, __pyx_t_1};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2147, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, ((PyObject *)__pyx_v_mem), __pyx_v_a_dtype, __pyx_t_1};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2147, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2147, __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(((PyObject *)__pyx_v_mem));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mem));
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, ((PyObject *)__pyx_v_mem));
      __Pyx_INCREF(__pyx_v_a_dtype);
      __Pyx_GIVEREF(__pyx_v_a_dtype);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_a_dtype);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2148
 *         src_cpu = (
 *             numpy.frombuffer(mem, a_dtype, itemcount)
 *             .reshape(shape, order=order))             # <<<<<<<<<<<<<<
 *         _concatenate_numpy_array(
 *             [numpy.expand_dims(e, 0) for e in arrays],
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2148, __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 = 0;
    __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 2148, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_src_cpu = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2149
 *             numpy.frombuffer(mem, a_dtype, itemcount)
 *             .reshape(shape, order=order))
 *         _concatenate_numpy_array(             # <<<<<<<<<<<<<<
 *             [numpy.expand_dims(e, 0) for e in arrays],
 *             0,
 */
    { /* enter inner scope */

      /* "cupy/core/core.pyx":2150
 *             .reshape(shape, order=order))
 *         _concatenate_numpy_array(
 *             [numpy.expand_dims(e, 0) for e in arrays],             # <<<<<<<<<<<<<<
 *             0,
 *             get_dtype(src_dtype),
 */
      __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2150, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(__pyx_v_arrays == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(0, 2150, __pyx_L7_error)
      }
      __pyx_t_5 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_5); __pyx_t_10 = 0;
      for (;;) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_9 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_10); __Pyx_INCREF(__pyx_t_9); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 2150, __pyx_L7_error)
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_5, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2150, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_9);
        #endif
        __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_e, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2150, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_expand_dims); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2150, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = NULL;
        __pyx_t_8 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_7, function);
            __pyx_t_8 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_7)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_8genexpr5__pyx_v_e, __pyx_int_0};
          __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2150, __pyx_L7_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_9);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_8genexpr5__pyx_v_e, __pyx_int_0};
          __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2150, __pyx_L7_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_9);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2150, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_11);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(__pyx_8genexpr5__pyx_v_e);
          __Pyx_GIVEREF(__pyx_8genexpr5__pyx_v_e);
          PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_8, __pyx_8genexpr5__pyx_v_e);
          __Pyx_INCREF(__pyx_int_0);
          __Pyx_GIVEREF(__pyx_int_0);
          PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_8, __pyx_int_0);
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2150, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 2150, __pyx_L7_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_e); __pyx_8genexpr5__pyx_v_e = 0;
      goto __pyx_L10_exit_scope;
      __pyx_L7_error:;
      __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_e); __pyx_8genexpr5__pyx_v_e = 0;
      goto __pyx_L1_error;
      __pyx_L10_exit_scope:;
    } /* exit inner scope */

    /* "cupy/core/core.pyx":2152
 *             [numpy.expand_dims(e, 0) for e in arrays],
 *             0,
 *             get_dtype(src_dtype),             # <<<<<<<<<<<<<<
 *             a_dtype,
 *             src_cpu)
 */
    __pyx_t_5 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_src_dtype, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);

    /* "cupy/core/core.pyx":2149
 *             numpy.frombuffer(mem, a_dtype, itemcount)
 *             .reshape(shape, order=order))
 *         _concatenate_numpy_array(             # <<<<<<<<<<<<<<
 *             [numpy.expand_dims(e, 0) for e in arrays],
 *             0,
 */
    __pyx_t_9 = __pyx_f_4cupy_4core_4core__concatenate_numpy_array(__pyx_t_1, __pyx_int_0, __pyx_t_5, __pyx_v_a_dtype, __pyx_v_src_cpu); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2149, __pyx_L1_error)
    __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_9); __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":2155
 *             a_dtype,
 *             src_cpu)
 *         a = ndarray(shape, dtype=a_dtype, order=order)             # <<<<<<<<<<<<<<
 *         a.data.copy_from_host_async(ctypes.c_void_p(mem.ptr), nbytes)
 *         pinned_memory._add_to_watch_list(stream.record(), mem)
 */
    __pyx_t_9 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_shape); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2155, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2155, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2155, __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, 2155, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 2155, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2155, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2156
 *             src_cpu)
 *         a = ndarray(shape, dtype=a_dtype, order=order)
 *         a.data.copy_from_host_async(ctypes.c_void_p(mem.ptr), nbytes)             # <<<<<<<<<<<<<<
 *         pinned_memory._add_to_watch_list(stream.record(), mem)
 *     else:
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_c_void_p); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_mem->ptr); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2156, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_9};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2156, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __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[2] = {__pyx_t_7, __pyx_t_9};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2156, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __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(0, 2156, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2156, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_a->data->__pyx_vtab)->copy_from_host_async(__pyx_v_a->data, __pyx_t_1, __pyx_v_nbytes, 0, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2157
 *         a = ndarray(shape, dtype=a_dtype, order=order)
 *         a.data.copy_from_host_async(ctypes.c_void_p(mem.ptr), nbytes)
 *         pinned_memory._add_to_watch_list(stream.record(), mem)             # <<<<<<<<<<<<<<
 *     else:
 *         # fallback to numpy array and send it to GPU
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_stream, __pyx_n_s_record); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    if (__pyx_t_11) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2157, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else {
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2157, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __pyx_f_4cupy_4cuda_13pinned_memory__add_to_watch_list(__pyx_t_5, ((PyObject *)__pyx_v_mem), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2157, __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":2144
 *         _alloc_async_transfer_buffer(nbytes))
 *     cdef size_t offset, length
 *     if mem is not None:             # <<<<<<<<<<<<<<
 *         # write concatenated arrays to the pinned memory directly
 *         src_cpu = (
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":2161
 *         # fallback to numpy array and send it to GPU
 *         # Note: a_cpu.ndim is always >= 1
 *         a_cpu = numpy.array(arrays, dtype=a_dtype, copy=False, order=order,             # <<<<<<<<<<<<<<
 *                             ndmin=ndmin)
 *         a = ndarray(shape, dtype=a_dtype, order=order)
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2161, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2161, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2161, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_arrays);
    __Pyx_GIVEREF(__pyx_v_arrays);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_arrays);
    __pyx_t_11 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2161, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, __pyx_v_a_dtype) < 0) __PYX_ERR(0, 2161, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 2161, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 2161, __pyx_L1_error)

    /* "cupy/core/core.pyx":2162
 *         # Note: a_cpu.ndim is always >= 1
 *         a_cpu = numpy.array(arrays, dtype=a_dtype, copy=False, order=order,
 *                             ndmin=ndmin)             # <<<<<<<<<<<<<<
 *         a = ndarray(shape, dtype=a_dtype, order=order)
 *         a.data.copy_from_host(
 */
    __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_ndmin); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2162, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_ndmin, __pyx_t_9) < 0) __PYX_ERR(0, 2161, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":2161
 *         # fallback to numpy array and send it to GPU
 *         # Note: a_cpu.ndim is always >= 1
 *         a_cpu = numpy.array(arrays, dtype=a_dtype, copy=False, order=order,             # <<<<<<<<<<<<<<
 *                             ndmin=ndmin)
 *         a = ndarray(shape, dtype=a_dtype, order=order)
 */
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2161, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_v_a_cpu = __pyx_t_9;
    __pyx_t_9 = 0;

    /* "cupy/core/core.pyx":2163
 *         a_cpu = numpy.array(arrays, dtype=a_dtype, copy=False, order=order,
 *                             ndmin=ndmin)
 *         a = ndarray(shape, dtype=a_dtype, order=order)             # <<<<<<<<<<<<<<
 *         a.data.copy_from_host(
 *             ctypes.c_void_p(a_cpu.__array_interface__['data'][0]),
 */
    __pyx_t_9 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_shape); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2163, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2163, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2163, __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, 2163, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 2163, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_11, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2163, __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_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2165
 *         a = ndarray(shape, dtype=a_dtype, order=order)
 *         a.data.copy_from_host(
 *             ctypes.c_void_p(a_cpu.__array_interface__['data'][0]),             # <<<<<<<<<<<<<<
 *             nbytes)
 * 
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2165, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_c_void_p); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2165, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_a_cpu, __pyx_n_s_array_interface); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2165, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_5 = __Pyx_PyObject_Dict_GetItem(__pyx_t_9, __pyx_n_u_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2165, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2165, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2165, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_9};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2165, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_9};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2165, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2165, __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_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2165, __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;

    /* "cupy/core/core.pyx":2164
 *                             ndmin=ndmin)
 *         a = ndarray(shape, dtype=a_dtype, order=order)
 *         a.data.copy_from_host(             # <<<<<<<<<<<<<<
 *             ctypes.c_void_p(a_cpu.__array_interface__['data'][0]),
 *             nbytes)
 */
    __pyx_t_11 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_a->data->__pyx_vtab)->copy_from_host(__pyx_v_a->data, __pyx_t_1, __pyx_v_nbytes, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":2168
 *             nbytes)
 * 
 *     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":2128
 * 
 * 
 * cdef ndarray _send_numpy_array_list_to_gpu(             # <<<<<<<<<<<<<<
 *         list arrays, src_dtype, dst_dtype,
 *         const vector.vector[Py_ssize_t]& shape,
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.core.core._send_numpy_array_list_to_gpu", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_a_dtype);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_stream);
  __Pyx_XDECREF((PyObject *)__pyx_v_mem);
  __Pyx_XDECREF(__pyx_v_src_cpu);
  __Pyx_XDECREF(__pyx_v_a_cpu);
  __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_e);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2175
 * 
 * 
 * cdef inline _concatenate_numpy_array(arrays, axis, src_dtype, dst_dtype, out):             # <<<<<<<<<<<<<<
 *     # type(*_dtype) must be numpy.dtype
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__concatenate_numpy_array(PyObject *__pyx_v_arrays, PyObject *__pyx_v_axis, PyObject *__pyx_v_src_dtype, PyObject *__pyx_v_dst_dtype, PyObject *__pyx_v_out) {
  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;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("_concatenate_numpy_array", 0);

  /* "cupy/core/core.pyx":2178
 *     # type(*_dtype) must be numpy.dtype
 * 
 *     if (_numpy_concatenate_has_out_argument             # <<<<<<<<<<<<<<
 *             and src_dtype.kind == dst_dtype.kind):
 *         # concatenate only accepts same_kind casting
 */
  __pyx_t_2 = (__pyx_v_4cupy_4core_4core__numpy_concatenate_has_out_argument != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }

  /* "cupy/core/core.pyx":2179
 * 
 *     if (_numpy_concatenate_has_out_argument
 *             and src_dtype.kind == dst_dtype.kind):             # <<<<<<<<<<<<<<
 *         # concatenate only accepts same_kind casting
 *         numpy.concatenate(arrays, axis, out)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_src_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2179, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __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, 2179, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;

  /* "cupy/core/core.pyx":2178
 *     # type(*_dtype) must be numpy.dtype
 * 
 *     if (_numpy_concatenate_has_out_argument             # <<<<<<<<<<<<<<
 *             and src_dtype.kind == dst_dtype.kind):
 *         # concatenate only accepts same_kind casting
 */
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2181
 *             and src_dtype.kind == dst_dtype.kind):
 *         # concatenate only accepts same_kind casting
 *         numpy.concatenate(arrays, axis, out)             # <<<<<<<<<<<<<<
 *     else:
 *         out[:] = numpy.concatenate(arrays, axis)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2181, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2181, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    __pyx_t_6 = 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_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_arrays, __pyx_v_axis, __pyx_v_out};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2181, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_arrays, __pyx_v_axis, __pyx_v_out};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2181, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2181, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_v_arrays);
      __Pyx_GIVEREF(__pyx_v_arrays);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_arrays);
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_axis);
      __Pyx_INCREF(__pyx_v_out);
      __Pyx_GIVEREF(__pyx_v_out);
      PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_out);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2181, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":2178
 *     # type(*_dtype) must be numpy.dtype
 * 
 *     if (_numpy_concatenate_has_out_argument             # <<<<<<<<<<<<<<
 *             and src_dtype.kind == dst_dtype.kind):
 *         # concatenate only accepts same_kind casting
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2183
 *         numpy.concatenate(arrays, axis, out)
 *     else:
 *         out[:] = numpy.concatenate(arrays, axis)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2183, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2183, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_arrays, __pyx_v_axis};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2183, __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_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_arrays, __pyx_v_axis};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2183, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2183, __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_arrays);
      __Pyx_GIVEREF(__pyx_v_arrays);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_arrays);
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_axis);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2183, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__Pyx_PyObject_SetSlice(__pyx_v_out, __pyx_t_5, 0, 0, NULL, NULL, &__pyx_slice__41, 0, 0, 1) < 0) __PYX_ERR(0, 2183, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":2175
 * 
 * 
 * cdef inline _concatenate_numpy_array(arrays, axis, src_dtype, dst_dtype, out):             # <<<<<<<<<<<<<<
 *     # type(*_dtype) must be numpy.dtype
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __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._concatenate_numpy_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2186
 * 
 * 
 * cdef inline _alloc_async_transfer_buffer(Py_ssize_t nbytes):             # <<<<<<<<<<<<<<
 *     try:
 *         return pinned_memory.alloc_pinned_memory(nbytes)
 */

static CYTHON_INLINE PyObject *__pyx_f_4cupy_4core_4core__alloc_async_transfer_buffer(Py_ssize_t __pyx_v_nbytes) {
  PyObject *__pyx_v_e = 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;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  char const *__pyx_t_17;
  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;
  PyObject *__pyx_t_23 = NULL;
  __Pyx_RefNannySetupContext("_alloc_async_transfer_buffer", 0);

  /* "cupy/core/core.pyx":2187
 * 
 * cdef inline _alloc_async_transfer_buffer(Py_ssize_t nbytes):
 *     try:             # <<<<<<<<<<<<<<
 *         return pinned_memory.alloc_pinned_memory(nbytes)
 *     except CUDARuntimeError as e:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "cupy/core/core.pyx":2188
 * cdef inline _alloc_async_transfer_buffer(Py_ssize_t nbytes):
 *     try:
 *         return pinned_memory.alloc_pinned_memory(nbytes)             # <<<<<<<<<<<<<<
 *     except CUDARuntimeError as e:
 *         if e.status != runtime.cudaErrorMemoryAllocation:
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4cuda_13pinned_memory_alloc_pinned_memory(__pyx_v_nbytes, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2188, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L7_try_return;

      /* "cupy/core/core.pyx":2187
 * 
 * cdef inline _alloc_async_transfer_buffer(Py_ssize_t nbytes):
 *     try:             # <<<<<<<<<<<<<<
 *         return pinned_memory.alloc_pinned_memory(nbytes)
 *     except CUDARuntimeError as e:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2189
 *     try:
 *         return pinned_memory.alloc_pinned_memory(nbytes)
 *     except CUDARuntimeError as e:             # <<<<<<<<<<<<<<
 *         if e.status != runtime.cudaErrorMemoryAllocation:
 *             raise
 */
    __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_CUDARuntimeError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2189, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_4, __pyx_t_7);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_ErrRestore(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0;
    if (__pyx_t_8) {
      __Pyx_AddTraceback("cupy.core.core._alloc_async_transfer_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) __PYX_ERR(0, 2189, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __pyx_v_e = __pyx_t_5;
      /*try:*/ {

        /* "cupy/core/core.pyx":2190
 *         return pinned_memory.alloc_pinned_memory(nbytes)
 *     except CUDARuntimeError as e:
 *         if e.status != runtime.cudaErrorMemoryAllocation:             # <<<<<<<<<<<<<<
 *             raise
 *         warnings.warn(
 */
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_status); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2190, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_9 = __Pyx_PyInt_From_int(cudaErrorMemoryAllocation); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2190, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = PyObject_RichCompare(__pyx_t_7, __pyx_t_9, Py_NE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2190, __pyx_L14_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2190, __pyx_L14_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(__pyx_t_11)) {

          /* "cupy/core/core.pyx":2191
 *     except CUDARuntimeError as e:
 *         if e.status != runtime.cudaErrorMemoryAllocation:
 *             raise             # <<<<<<<<<<<<<<
 *         warnings.warn(
 *             'Using synchronous transfer as pinned memory ({} bytes) '
 */
          __Pyx_GIVEREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_5);
          __Pyx_XGIVEREF(__pyx_t_4);
          __Pyx_ErrRestoreWithState(__pyx_t_6, __pyx_t_5, __pyx_t_4);
          __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0; 
          __PYX_ERR(0, 2191, __pyx_L14_error)

          /* "cupy/core/core.pyx":2190
 *         return pinned_memory.alloc_pinned_memory(nbytes)
 *     except CUDARuntimeError as e:
 *         if e.status != runtime.cudaErrorMemoryAllocation:             # <<<<<<<<<<<<<<
 *             raise
 *         warnings.warn(
 */
        }

        /* "cupy/core/core.pyx":2192
 *         if e.status != runtime.cudaErrorMemoryAllocation:
 *             raise
 *         warnings.warn(             # <<<<<<<<<<<<<<
 *             'Using synchronous transfer as pinned memory ({} bytes) '
 *             'could not be allocated. '
 */
        __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_warnings); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2192, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_warn); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2192, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "cupy/core/core.pyx":2196
 *             'could not be allocated. '
 *             'This generally occurs because of insufficient host memory. '
 *             'The original error was: {}'.format(nbytes, e),             # <<<<<<<<<<<<<<
 *             util.PerformanceWarning)
 * 
 */
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Using_synchronous_transfer_as_pi, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2196, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_13 = PyInt_FromSsize_t(__pyx_v_nbytes); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2196, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_14 = NULL;
        __pyx_t_8 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_12);
          if (likely(__pyx_t_14)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_12, function);
            __pyx_t_8 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_t_13, __pyx_v_e};
          __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2196, __pyx_L14_error)
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_t_13, __pyx_v_e};
          __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2196, __pyx_L14_error)
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        } else
        #endif
        {
          __pyx_t_15 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2196, __pyx_L14_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_13);
          PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_8, __pyx_t_13);
          __Pyx_INCREF(__pyx_v_e);
          __Pyx_GIVEREF(__pyx_v_e);
          PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_8, __pyx_v_e);
          __pyx_t_13 = 0;
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_15, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2196, __pyx_L14_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        }
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

        /* "cupy/core/core.pyx":2197
 *             'This generally occurs because of insufficient host memory. '
 *             'The original error was: {}'.format(nbytes, e),
 *             util.PerformanceWarning)             # <<<<<<<<<<<<<<
 * 
 *     return None
 */
        __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2197, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_PerformanceWarning); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2197, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = NULL;
        __pyx_t_8 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_7);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_7, function);
            __pyx_t_8 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_7)) {
          PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_9, __pyx_t_15};
          __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2192, __pyx_L14_error)
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
          PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_9, __pyx_t_15};
          __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2192, __pyx_L14_error)
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        } else
        #endif
        {
          __pyx_t_13 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2192, __pyx_L14_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_GIVEREF(__pyx_t_9);
          PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_8, __pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_15);
          PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_8, __pyx_t_15);
          __pyx_t_9 = 0;
          __pyx_t_15 = 0;
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2192, __pyx_L14_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }

      /* "cupy/core/core.pyx":2189
 *     try:
 *         return pinned_memory.alloc_pinned_memory(nbytes)
 *     except CUDARuntimeError as e:             # <<<<<<<<<<<<<<
 *         if e.status != runtime.cudaErrorMemoryAllocation:
 *             raise
 */
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_DECREF(__pyx_v_e);
          __pyx_v_e = NULL;
          goto __pyx_L15;
        }
        __pyx_L14_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __pyx_t_8 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_17 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e);
            __pyx_v_e = NULL;
          }
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_XGIVEREF(__pyx_t_22);
            __Pyx_XGIVEREF(__pyx_t_23);
            __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
          }
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_ErrRestore(__pyx_t_18, __pyx_t_19, __pyx_t_20);
          __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
          __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_17;
          goto __pyx_L5_except_error;
        }
        __pyx_L15:;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L4_exception_handled;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "cupy/core/core.pyx":2187
 * 
 * cdef inline _alloc_async_transfer_buffer(Py_ssize_t nbytes):
 *     try:             # <<<<<<<<<<<<<<
 *         return pinned_memory.alloc_pinned_memory(nbytes)
 *     except CUDARuntimeError as e:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  }

  /* "cupy/core/core.pyx":2199
 *             util.PerformanceWarning)
 * 
 *     return None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2186
 * 
 * 
 * cdef inline _alloc_async_transfer_buffer(Py_ssize_t nbytes):             # <<<<<<<<<<<<<<
 *     try:
 *         return pinned_memory.alloc_pinned_memory(nbytes)
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("cupy.core.core._alloc_async_transfer_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2202
 * 
 * 
 * cpdef ndarray _internal_ascontiguousarray(ndarray a):             # <<<<<<<<<<<<<<
 *     if a._c_contiguous:
 *         return a
 */

static PyObject *__pyx_pw_4cupy_4core_4core_13_internal_ascontiguousarray(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED 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
  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("_internal_ascontiguousarray", 0);

  /* "cupy/core/core.pyx":2203
 * 
 * cpdef ndarray _internal_ascontiguousarray(ndarray a):
 *     if a._c_contiguous:             # <<<<<<<<<<<<<<
 *         return a
 *     newarray = _ndarray_init(a._shape, a.dtype)
 */
  __pyx_t_1 = (__pyx_v_a->_c_contiguous != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2204
 * cpdef ndarray _internal_ascontiguousarray(ndarray a):
 *     if a._c_contiguous:
 *         return a             # <<<<<<<<<<<<<<
 *     newarray = _ndarray_init(a._shape, a.dtype)
 *     elementwise_copy(a, newarray)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2203
 * 
 * cpdef ndarray _internal_ascontiguousarray(ndarray a):
 *     if a._c_contiguous:             # <<<<<<<<<<<<<<
 *         return a
 *     newarray = _ndarray_init(a._shape, a.dtype)
 */
  }

  /* "cupy/core/core.pyx":2205
 *     if a._c_contiguous:
 *         return a
 *     newarray = _ndarray_init(a._shape, a.dtype)             # <<<<<<<<<<<<<<
 *     elementwise_copy(a, newarray)
 *     return newarray
 */
  __pyx_t_2 = __pyx_v_a->dtype;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core__ndarray_init(__pyx_v_a->_shape, __pyx_t_2)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2206
 *         return a
 *     newarray = _ndarray_init(a._shape, a.dtype)
 *     elementwise_copy(a, newarray)             # <<<<<<<<<<<<<<
 *     return newarray
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __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_4, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2206, __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_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2206, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2206, __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_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_a));
    __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_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2206, __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_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2207
 *     newarray = _ndarray_init(a._shape, a.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":2202
 * 
 * 
 * cpdef ndarray _internal_ascontiguousarray(ndarray a):             # <<<<<<<<<<<<<<
 *     if a._c_contiguous:
 *         return a
 */

  /* 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._internal_ascontiguousarray", __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_13_internal_ascontiguousarray(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
static char __pyx_doc_4cupy_4core_4core_12_internal_ascontiguousarray[] = "_internal_ascontiguousarray(ndarray a) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_13_internal_ascontiguousarray(PyObject *__pyx_self, PyObject *__pyx_v_a) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_internal_ascontiguousarray (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2202, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_12_internal_ascontiguousarray(__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_12_internal_ascontiguousarray(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("_internal_ascontiguousarray", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_a, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2202, __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._internal_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":2210
 * 
 * 
 * cpdef ndarray _internal_asfortranarray(ndarray a):             # <<<<<<<<<<<<<<
 *     cdef ndarray newarray
 *     cdef int m, n
 */

static PyObject *__pyx_pw_4cupy_4core_4core_15_internal_asfortranarray(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__internal_asfortranarray(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_newarray = 0;
  int __pyx_v_m;
  int __pyx_v_n;
  PyObject *__pyx_v_handle = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  int __pyx_t_9;
  intptr_t __pyx_t_10;
  __Pyx_RefNannySetupContext("_internal_asfortranarray", 0);

  /* "cupy/core/core.pyx":2214
 *     cdef int m, n
 * 
 *     if a._f_contiguous:             # <<<<<<<<<<<<<<
 *         return a
 * 
 */
  __pyx_t_1 = (__pyx_v_a->_f_contiguous != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2215
 * 
 *     if a._f_contiguous:
 *         return a             # <<<<<<<<<<<<<<
 * 
 *     newarray = ndarray(a.shape, a.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":2214
 *     cdef int m, n
 * 
 *     if a._f_contiguous:             # <<<<<<<<<<<<<<
 *         return a
 * 
 */
  }

  /* "cupy/core/core.pyx":2217
 *         return a
 * 
 *     newarray = ndarray(a.shape, a.dtype, order='F')             # <<<<<<<<<<<<<<
 *     if (a._c_contiguous and a._shape.size() == 2 and
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64)):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2217, __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_v_a->dtype);
  __Pyx_GIVEREF(__pyx_v_a->dtype);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_a->dtype);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_order, __pyx_n_u_F) < 0) __PYX_ERR(0, 2217, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2217, __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_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2218
 * 
 *     newarray = ndarray(a.shape, a.dtype, order='F')
 *     if (a._c_contiguous and a._shape.size() == 2 and             # <<<<<<<<<<<<<<
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64)):
 *         m, n = a.shape
 */
  __pyx_t_5 = (__pyx_v_a->_c_contiguous != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_v_a->_shape.size() == 2) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L5_bool_binop_done;
  }

  /* "cupy/core/core.pyx":2219
 *     newarray = ndarray(a.shape, a.dtype, order='F')
 *     if (a._c_contiguous and a._shape.size() == 2 and
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64)):             # <<<<<<<<<<<<<<
 *         m, n = a.shape
 *         handle = device.get_cublas_handle()
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2219, __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, 2219, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2219, __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, 2219, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __pyx_t_5;
  __pyx_L5_bool_binop_done:;

  /* "cupy/core/core.pyx":2218
 * 
 *     newarray = ndarray(a.shape, a.dtype, order='F')
 *     if (a._c_contiguous and a._shape.size() == 2 and             # <<<<<<<<<<<<<<
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64)):
 *         m, n = a.shape
 */
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2220
 *     if (a._c_contiguous and a._shape.size() == 2 and
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64)):
 *         m, n = a.shape             # <<<<<<<<<<<<<<
 *         handle = device.get_cublas_handle()
 *         if a.dtype == numpy.float32:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2220, __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 != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 2220, __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); 
      } else {
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2220, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2220, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2220, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      index = 1; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) __PYX_ERR(0, 2220, __pyx_L1_error)
      __pyx_t_7 = NULL;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L10_unpacking_done;
      __pyx_L9_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, 2220, __pyx_L1_error)
      __pyx_L10_unpacking_done:;
    }
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2220, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2220, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_m = __pyx_t_8;
    __pyx_v_n = __pyx_t_9;

    /* "cupy/core/core.pyx":2221
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64)):
 *         m, n = a.shape
 *         handle = device.get_cublas_handle()             # <<<<<<<<<<<<<<
 *         if a.dtype == numpy.float32:
 *             cublas.sgeam(
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_device); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2221, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_cublas_handle); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2221, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __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_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2221, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2221, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_handle = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2222
 *         m, n = a.shape
 *         handle = device.get_cublas_handle()
 *         if a.dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *             cublas.sgeam(
 *                 handle,
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2222, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2222, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":2224
 *         if a.dtype == numpy.float32:
 *             cublas.sgeam(
 *                 handle,             # <<<<<<<<<<<<<<
 *                 1,  # transpose a
 *                 1,  # transpose newarray
 */
      __pyx_t_10 = PyInt_AsSsize_t(__pyx_v_handle); if (unlikely((__pyx_t_10 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2224, __pyx_L1_error)

      /* "cupy/core/core.pyx":2223
 *         handle = device.get_cublas_handle()
 *         if a.dtype == numpy.float32:
 *             cublas.sgeam(             # <<<<<<<<<<<<<<
 *                 handle,
 *                 1,  # transpose a
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_6cublas_sgeam(__pyx_t_10, 1, 1, __pyx_v_m, __pyx_v_n, 1., __pyx_v_a->data->ptr, __pyx_v_n, 0., __pyx_v_a->data->ptr, __pyx_v_n, __pyx_v_newarray->data->ptr, __pyx_v_m, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2223, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2222
 *         m, n = a.shape
 *         handle = device.get_cublas_handle()
 *         if a.dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *             cublas.sgeam(
 *                 handle,
 */
      goto __pyx_L11;
    }

    /* "cupy/core/core.pyx":2229
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,
 *                 newarray.data.ptr, m)
 *         elif a.dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *             cublas.dgeam(
 *                 handle,
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2229, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2229, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_a->dtype, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2229, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2229, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":2231
 *         elif a.dtype == numpy.float64:
 *             cublas.dgeam(
 *                 handle,             # <<<<<<<<<<<<<<
 *                 1,  # transpose a
 *                 1,  # transpose newarray
 */
      __pyx_t_10 = PyInt_AsSsize_t(__pyx_v_handle); if (unlikely((__pyx_t_10 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2231, __pyx_L1_error)

      /* "cupy/core/core.pyx":2230
 *                 newarray.data.ptr, m)
 *         elif a.dtype == numpy.float64:
 *             cublas.dgeam(             # <<<<<<<<<<<<<<
 *                 handle,
 *                 1,  # transpose a
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_6cublas_dgeam(__pyx_t_10, 1, 1, __pyx_v_m, __pyx_v_n, 1., __pyx_v_a->data->ptr, __pyx_v_n, 0., __pyx_v_a->data->ptr, __pyx_v_n, __pyx_v_newarray->data->ptr, __pyx_v_m, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2230, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2229
 *                 m, n, 1., a.data.ptr, n, 0., a.data.ptr, n,
 *                 newarray.data.ptr, m)
 *         elif a.dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *             cublas.dgeam(
 *                 handle,
 */
    }
    __pyx_L11:;

    /* "cupy/core/core.pyx":2218
 * 
 *     newarray = ndarray(a.shape, a.dtype, order='F')
 *     if (a._c_contiguous and a._shape.size() == 2 and             # <<<<<<<<<<<<<<
 *             (a.dtype == numpy.float32 or a.dtype == numpy.float64)):
 *         m, n = a.shape
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":2237
 *                 newarray.data.ptr, m)
 *     else:
 *         elementwise_copy(a, newarray)             # <<<<<<<<<<<<<<
 *     return newarray
 * 
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    __pyx_t_9 = 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_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2237, __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_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2237, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2237, __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_a));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
      PyTuple_SET_ITEM(__pyx_t_6, 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_6, 1+__pyx_t_9, ((PyObject *)__pyx_v_newarray));
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2237, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":2238
 *     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":2210
 * 
 * 
 * cpdef ndarray _internal_asfortranarray(ndarray a):             # <<<<<<<<<<<<<<
 *     cdef ndarray newarray
 *     cdef int m, n
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_15_internal_asfortranarray(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
static char __pyx_doc_4cupy_4core_4core_14_internal_asfortranarray[] = "_internal_asfortranarray(ndarray a) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_15_internal_asfortranarray(PyObject *__pyx_self, PyObject *__pyx_v_a) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_internal_asfortranarray (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 2210, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_14_internal_asfortranarray(__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_14_internal_asfortranarray(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("_internal_asfortranarray", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_asfortranarray(__pyx_v_a, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2210, __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._internal_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":2241
 * 
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     cdef bint same_dtype = False
 *     zero_dim = a._shape.size() == 0
 */

static PyObject *__pyx_pw_4cupy_4core_4core_17ascontiguousarray(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);
  int __pyx_v_same_dtype;
  PyObject *__pyx_v_zero_dim = NULL;
  PyObject *__pyx_v_shape = 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;
  int __pyx_t_2;
  int __pyx_t_3;
  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":2242
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     cdef bint same_dtype = False             # <<<<<<<<<<<<<<
 *     zero_dim = a._shape.size() == 0
 *     if dtype is None:
 */
  __pyx_v_same_dtype = 0;

  /* "cupy/core/core.pyx":2243
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     cdef bint same_dtype = False
 *     zero_dim = a._shape.size() == 0             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         same_dtype = True
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_a->_shape.size() == 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2243, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_zero_dim = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2244
 *     cdef bint same_dtype = False
 *     zero_dim = a._shape.size() == 0
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         same_dtype = True
 *         dtype = a.dtype
 */
  __pyx_t_2 = (__pyx_v_dtype == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2245
 *     zero_dim = a._shape.size() == 0
 *     if dtype is None:
 *         same_dtype = True             # <<<<<<<<<<<<<<
 *         dtype = a.dtype
 *     else:
 */
    __pyx_v_same_dtype = 1;

    /* "cupy/core/core.pyx":2246
 *     if dtype is None:
 *         same_dtype = True
 *         dtype = a.dtype             # <<<<<<<<<<<<<<
 *     else:
 *         dtype = get_dtype(dtype)
 */
    __pyx_t_1 = __pyx_v_a->dtype;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2244
 *     cdef bint same_dtype = False
 *     zero_dim = a._shape.size() == 0
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         same_dtype = True
 *         dtype = a.dtype
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2248
 *         dtype = a.dtype
 *     else:
 *         dtype = get_dtype(dtype)             # <<<<<<<<<<<<<<
 *         same_dtype = dtype == a.dtype
 * 
 */
  /*else*/ {
    __pyx_t_1 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2248, __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":2249
 *     else:
 *         dtype = get_dtype(dtype)
 *         same_dtype = dtype == a.dtype             # <<<<<<<<<<<<<<
 * 
 *     if same_dtype and a._c_contiguous:
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_dtype, __pyx_v_a->dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2249, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2249, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_same_dtype = __pyx_t_3;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":2251
 *         same_dtype = dtype == a.dtype
 * 
 *     if same_dtype and a._c_contiguous:             # <<<<<<<<<<<<<<
 *         if zero_dim:
 *             return _manipulation._ndarray_ravel(a, 'C')
 */
  __pyx_t_2 = (__pyx_v_same_dtype != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_3 = __pyx_t_2;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_a->_c_contiguous != 0);
  __pyx_t_3 = __pyx_t_2;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2252
 * 
 *     if same_dtype and a._c_contiguous:
 *         if zero_dim:             # <<<<<<<<<<<<<<
 *             return _manipulation._ndarray_ravel(a, 'C')
 *         return a
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_zero_dim); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2252, __pyx_L1_error)
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":2253
 *     if same_dtype and a._c_contiguous:
 *         if zero_dim:
 *             return _manipulation._ndarray_ravel(a, 'C')             # <<<<<<<<<<<<<<
 *         return a
 * 
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_ravel(__pyx_v_a, __pyx_n_u_C)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2253, __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":2252
 * 
 *     if same_dtype and a._c_contiguous:
 *         if zero_dim:             # <<<<<<<<<<<<<<
 *             return _manipulation._ndarray_ravel(a, 'C')
 *         return a
 */
    }

    /* "cupy/core/core.pyx":2254
 *         if zero_dim:
 *             return _manipulation._ndarray_ravel(a, 'C')
 *         return a             # <<<<<<<<<<<<<<
 * 
 *     shape = (1,) if zero_dim else a.shape
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2251
 *         same_dtype = dtype == a.dtype
 * 
 *     if same_dtype and a._c_contiguous:             # <<<<<<<<<<<<<<
 *         if zero_dim:
 *             return _manipulation._ndarray_ravel(a, 'C')
 */
  }

  /* "cupy/core/core.pyx":2256
 *         return a
 * 
 *     shape = (1,) if zero_dim else a.shape             # <<<<<<<<<<<<<<
 *     newarray = ndarray(shape, dtype)
 *     elementwise_copy(a, newarray)
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_zero_dim); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2256, __pyx_L1_error)
  if (__pyx_t_3) {
    __Pyx_INCREF(__pyx_tuple__42);
    __pyx_t_1 = __pyx_tuple__42;
  } else {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2256, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __pyx_t_4;
    __pyx_t_4 = 0;
  }
  __pyx_v_shape = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2257
 * 
 *     shape = (1,) if zero_dim else a.shape
 *     newarray = ndarray(shape, dtype)             # <<<<<<<<<<<<<<
 *     elementwise_copy(a, newarray)
 *     return newarray
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_shape);
  __Pyx_GIVEREF(__pyx_v_shape);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_shape);
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_dtype);
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2258
 *     shape = (1,) if zero_dim else a.shape
 *     newarray = ndarray(shape, dtype)
 *     elementwise_copy(a, newarray)             # <<<<<<<<<<<<<<
 *     return newarray
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2258, __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_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2258, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2258, __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_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2258, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2259
 *     newarray = ndarray(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":2241
 * 
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     cdef bint same_dtype = False
 *     zero_dim = a._shape.size() == 0
 */

  /* 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_7);
  __Pyx_AddTraceback("cupy.core.core.ascontiguousarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_zero_dim);
  __Pyx_XDECREF(__pyx_v_shape);
  __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_17ascontiguousarray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_16ascontiguousarray[] = "ascontiguousarray(ndarray a, dtype=None) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_17ascontiguousarray(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, 2241, __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, 2241, __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, 2241, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_16ascontiguousarray(__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_16ascontiguousarray(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, 2241, __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":2262
 * 
 * 
 * cpdef ndarray asfortranarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     cdef ndarray newarray
 *     cdef int m, n
 */

static PyObject *__pyx_pw_4cupy_4core_4core_19asfortranarray(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_same_dtype;
  PyObject *__pyx_v_zero_dim = 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;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = 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":2265
 *     cdef ndarray newarray
 *     cdef int m, n
 *     cdef bint same_dtype = False             # <<<<<<<<<<<<<<
 *     zero_dim = a._shape.size() == 0
 * 
 */
  __pyx_v_same_dtype = 0;

  /* "cupy/core/core.pyx":2266
 *     cdef int m, n
 *     cdef bint same_dtype = False
 *     zero_dim = a._shape.size() == 0             # <<<<<<<<<<<<<<
 * 
 *     if dtype is None:
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_a->_shape.size() == 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_zero_dim = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2268
 *     zero_dim = a._shape.size() == 0
 * 
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         dtype = a.dtype
 *         same_dtype = True
 */
  __pyx_t_2 = (__pyx_v_dtype == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2269
 * 
 *     if dtype is None:
 *         dtype = a.dtype             # <<<<<<<<<<<<<<
 *         same_dtype = True
 *     else:
 */
    __pyx_t_1 = __pyx_v_a->dtype;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_dtype, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2270
 *     if dtype is None:
 *         dtype = a.dtype
 *         same_dtype = True             # <<<<<<<<<<<<<<
 *     else:
 *         dtype = get_dtype(dtype)
 */
    __pyx_v_same_dtype = 1;

    /* "cupy/core/core.pyx":2268
 *     zero_dim = a._shape.size() == 0
 * 
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         dtype = a.dtype
 *         same_dtype = True
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2272
 *         same_dtype = True
 *     else:
 *         dtype = get_dtype(dtype)             # <<<<<<<<<<<<<<
 *         same_dtype = dtype == a.dtype
 * 
 */
  /*else*/ {
    __pyx_t_1 = __pyx_f_4cupy_4core_6_dtype_get_dtype(__pyx_v_dtype, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2272, __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":2273
 *     else:
 *         dtype = get_dtype(dtype)
 *         same_dtype = dtype == a.dtype             # <<<<<<<<<<<<<<
 * 
 *     if same_dtype and a._f_contiguous:
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_dtype, __pyx_v_a->dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2273, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2273, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_same_dtype = __pyx_t_3;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":2275
 *         same_dtype = dtype == a.dtype
 * 
 *     if same_dtype and a._f_contiguous:             # <<<<<<<<<<<<<<
 *         if zero_dim:
 *             return _manipulation._ndarray_ravel(a, 'F')
 */
  __pyx_t_2 = (__pyx_v_same_dtype != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_3 = __pyx_t_2;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_a->_f_contiguous != 0);
  __pyx_t_3 = __pyx_t_2;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2276
 * 
 *     if same_dtype and a._f_contiguous:
 *         if zero_dim:             # <<<<<<<<<<<<<<
 *             return _manipulation._ndarray_ravel(a, 'F')
 *         return a
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_zero_dim); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2276, __pyx_L1_error)
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":2277
 *     if same_dtype and a._f_contiguous:
 *         if zero_dim:
 *             return _manipulation._ndarray_ravel(a, 'F')             # <<<<<<<<<<<<<<
 *         return a
 * 
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_ravel(__pyx_v_a, __pyx_n_u_F)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2277, __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":2276
 * 
 *     if same_dtype and a._f_contiguous:
 *         if zero_dim:             # <<<<<<<<<<<<<<
 *             return _manipulation._ndarray_ravel(a, 'F')
 *         return a
 */
    }

    /* "cupy/core/core.pyx":2278
 *         if zero_dim:
 *             return _manipulation._ndarray_ravel(a, 'F')
 *         return a             # <<<<<<<<<<<<<<
 * 
 *     if same_dtype and not zero_dim:
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2275
 *         same_dtype = dtype == a.dtype
 * 
 *     if same_dtype and a._f_contiguous:             # <<<<<<<<<<<<<<
 *         if zero_dim:
 *             return _manipulation._ndarray_ravel(a, 'F')
 */
  }

  /* "cupy/core/core.pyx":2280
 *         return a
 * 
 *     if same_dtype and not zero_dim:             # <<<<<<<<<<<<<<
 *         return _internal_asfortranarray(a)
 * 
 */
  __pyx_t_2 = (__pyx_v_same_dtype != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_3 = __pyx_t_2;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_zero_dim); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2280, __pyx_L1_error)
  __pyx_t_4 = ((!__pyx_t_2) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L9_bool_binop_done:;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2281
 * 
 *     if same_dtype and not zero_dim:
 *         return _internal_asfortranarray(a)             # <<<<<<<<<<<<<<
 * 
 *     newarray = ndarray((1,) if zero_dim else a.shape, dtype, order='F')
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_asfortranarray(__pyx_v_a, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2281, __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":2280
 *         return a
 * 
 *     if same_dtype and not zero_dim:             # <<<<<<<<<<<<<<
 *         return _internal_asfortranarray(a)
 * 
 */
  }

  /* "cupy/core/core.pyx":2283
 *         return _internal_asfortranarray(a)
 * 
 *     newarray = ndarray((1,) if zero_dim else a.shape, dtype, order='F')             # <<<<<<<<<<<<<<
 *     elementwise_copy(a, newarray)
 *     return newarray
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_zero_dim); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2283, __pyx_L1_error)
  if (__pyx_t_3) {
    __Pyx_INCREF(__pyx_tuple__43);
    __pyx_t_1 = __pyx_tuple__43;
  } else {
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __pyx_t_5;
    __pyx_t_5 = 0;
  }
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2283, __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(__pyx_v_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_dtype);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_order, __pyx_n_u_F) < 0) __PYX_ERR(0, 2283, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2283, __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_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":2284
 * 
 *     newarray = ndarray((1,) if zero_dim else a.shape, dtype, order='F')
 *     elementwise_copy(a, newarray)             # <<<<<<<<<<<<<<
 *     return newarray
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
    __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2284, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
    __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2284, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2284, __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(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, ((PyObject *)__pyx_v_a));
    __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_newarray));
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, ((PyObject *)__pyx_v_newarray));
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2284, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":2285
 *     newarray = ndarray((1,) if zero_dim else a.shape, dtype, order='F')
 *     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":2262
 * 
 * 
 * cpdef ndarray asfortranarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     cdef ndarray newarray
 *     cdef int m, n
 */

  /* 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_8);
  __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_zero_dim);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_19asfortranarray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_18asfortranarray[] = "asfortranarray(ndarray a, dtype=None) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_19asfortranarray(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, 2262, __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, 2262, __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, 2262, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_18asfortranarray(__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_18asfortranarray(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, 2262, __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":2292
 * # -----------------------------------------------------------------------------
 * 
 * cpdef _create_bit_op(name, op, no_bool, doc=''):             # <<<<<<<<<<<<<<
 *     types = () if no_bool else ('??->?',)
 *     return create_ufunc(
 */

static PyObject *__pyx_pw_4cupy_4core_4core_21_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_u__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":2293
 * 
 * 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, 2293, __pyx_L1_error)
  if (__pyx_t_2) {
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_t_1 = __pyx_empty_tuple;
  } else {
    __Pyx_INCREF(__pyx_tuple__45);
    __pyx_t_1 = __pyx_tuple__45;
  }
  __pyx_v_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2294
 * 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, 2294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":2295
 *     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_u_cupy_2, __pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/core.pyx":2296
 *     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__46); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":2298
 *         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 = PyUnicode_Format(__pyx_kp_u_out0_in0_s_in1, __pyx_v_op); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":2294
 * 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, 2294, __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":2299
 *                  '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, 2299, __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, 2299, __pyx_L1_error)

  /* "cupy/core/core.pyx":2294
 * 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, 2294, __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":2292
 * # -----------------------------------------------------------------------------
 * 
 * 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_21_create_bit_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_20_create_bit_op[] = "_create_bit_op(name, op, no_bool, doc=u'')";
static PyObject *__pyx_pw_4cupy_4core_4core_21_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_2,&__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_u__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_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_op)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_bit_op", 0, 3, 4, 1); __PYX_ERR(0, 2292, __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, 2292, __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, 2292, __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, 2292, __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_20_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_20_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, 2292, __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":2378
 * # -----------------------------------------------------------------------------
 * 
 * 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_23dot(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_22_routines_manipulation_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":2384
 *     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":2385
 * 
 *     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":2387
 *     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, 2387, __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, 2387, __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, 2387, __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, 2387, __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, 2387, __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, 2387, __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, 2387, __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, 2387, __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":2388
 * 
 *     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__47, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2388, __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, 2388, __pyx_L1_error)

    /* "cupy/core/core.pyx":2387
 *     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":2390
 *         raise ValueError('Not supported dtype combination.')
 * 
 *     if a_ndim == 0 or b_ndim == 0:             # <<<<<<<<<<<<<<
 *         return _math._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":2391
 * 
 *     if a_ndim == 0 or b_ndim == 0:
 *         return _math._multiply(a, b, out=out)             # <<<<<<<<<<<<<<
 * 
 *     input_a_is_vec = a_ndim == 1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(((PyObject *)__pyx_v_a));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_a));
    __Pyx_INCREF(((PyObject *)__pyx_v_b));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_b));
    PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_b));
    __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_out, ((PyObject *)__pyx_v_out)) < 0) __PYX_ERR(0, 2391, __pyx_L1_error)
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_v_4cupy_4core_14_routines_math__multiply, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2391, __pyx_L1_error)
    __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8);
    __pyx_t_8 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":2390
 *         raise ValueError('Not supported dtype combination.')
 * 
 *     if a_ndim == 0 or b_ndim == 0:             # <<<<<<<<<<<<<<
 *         return _math._multiply(a, b, out=out)
 * 
 */
  }

  /* "cupy/core/core.pyx":2393
 *         return _math._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":2394
 * 
 *     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":2395
 *     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":2396
 *     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":2397
 *     if input_a_is_vec:
 *         shape.clear()
 *         shape.push_back(1)             # <<<<<<<<<<<<<<
 *         shape.push_back(a.size)
 *         a = _manipulation._reshape(a, shape)
 */
    try {
      __pyx_v_shape.push_back(1);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2397, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2398
 *         shape.clear()
 *         shape.push_back(1)
 *         shape.push_back(a.size)             # <<<<<<<<<<<<<<
 *         a = _manipulation._reshape(a, shape)
 *         a_ndim = 2
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_a->size);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2398, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2399
 *         shape.push_back(1)
 *         shape.push_back(a.size)
 *         a = _manipulation._reshape(a, shape)             # <<<<<<<<<<<<<<
 *         a_ndim = 2
 *     if input_b_is_vec:
 */
    __pyx_t_8 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__reshape(__pyx_v_a, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8));
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":2400
 *         shape.push_back(a.size)
 *         a = _manipulation._reshape(a, shape)
 *         a_ndim = 2             # <<<<<<<<<<<<<<
 *     if input_b_is_vec:
 *         shape.clear()
 */
    __pyx_v_a_ndim = 2;

    /* "cupy/core/core.pyx":2395
 *     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":2401
 *         a = _manipulation._reshape(a, 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":2402
 *         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":2403
 *     if input_b_is_vec:
 *         shape.clear()
 *         shape.push_back(b.size)             # <<<<<<<<<<<<<<
 *         shape.push_back(1)
 *         b = _manipulation._reshape(b, shape)
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_b->size);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2403, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2404
 *         shape.clear()
 *         shape.push_back(b.size)
 *         shape.push_back(1)             # <<<<<<<<<<<<<<
 *         b = _manipulation._reshape(b, shape)
 *         b_ndim = 2
 */
    try {
      __pyx_v_shape.push_back(1);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2404, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2405
 *         shape.push_back(b.size)
 *         shape.push_back(1)
 *         b = _manipulation._reshape(b, shape)             # <<<<<<<<<<<<<<
 *         b_ndim = 2
 * 
 */
    __pyx_t_8 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__reshape(__pyx_v_b, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2405, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8));
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":2406
 *         shape.push_back(1)
 *         b = _manipulation._reshape(b, shape)
 *         b_ndim = 2             # <<<<<<<<<<<<<<
 * 
 *     a_axis = a_ndim - 1
 */
    __pyx_v_b_ndim = 2;

    /* "cupy/core/core.pyx":2401
 *         a = _manipulation._reshape(a, shape)
 *         a_ndim = 2
 *     if input_b_is_vec:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(b.size)
 */
  }

  /* "cupy/core/core.pyx":2408
 *         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":2409
 * 
 *     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":2411
 *     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":2412
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:
 *         raise ValueError('Axis dimension mismatch')             # <<<<<<<<<<<<<<
 * 
 *     if a_axis:
 */
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2412, __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, 2412, __pyx_L1_error)

    /* "cupy/core/core.pyx":2411
 *     b_axis = b_ndim - 2
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:             # <<<<<<<<<<<<<<
 *         raise ValueError('Axis dimension mismatch')
 * 
 */
  }

  /* "cupy/core/core.pyx":2414
 *         raise ValueError('Axis dimension mismatch')
 * 
 *     if a_axis:             # <<<<<<<<<<<<<<
 *         a = _manipulation.rollaxis(a, a_axis, 0)
 *     if b_axis:
 */
  __pyx_t_1 = (__pyx_v_a_axis != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2415
 * 
 *     if a_axis:
 *         a = _manipulation.rollaxis(a, a_axis, 0)             # <<<<<<<<<<<<<<
 *     if b_axis:
 *         b = _manipulation.rollaxis(b, b_axis, 0)
 */
    __pyx_t_9.__pyx_n = 1;
    __pyx_t_9.start = 0;
    __pyx_t_8 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation_rollaxis(__pyx_v_a, __pyx_v_a_axis, 0, &__pyx_t_9)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8));
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":2414
 *         raise ValueError('Axis dimension mismatch')
 * 
 *     if a_axis:             # <<<<<<<<<<<<<<
 *         a = _manipulation.rollaxis(a, a_axis, 0)
 *     if b_axis:
 */
  }

  /* "cupy/core/core.pyx":2416
 *     if a_axis:
 *         a = _manipulation.rollaxis(a, a_axis, 0)
 *     if b_axis:             # <<<<<<<<<<<<<<
 *         b = _manipulation.rollaxis(b, b_axis, 0)
 * 
 */
  __pyx_t_1 = (__pyx_v_b_axis != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2417
 *         a = _manipulation.rollaxis(a, a_axis, 0)
 *     if b_axis:
 *         b = _manipulation.rollaxis(b, b_axis, 0)             # <<<<<<<<<<<<<<
 * 
 *     k = a._shape[0]
 */
    __pyx_t_9.__pyx_n = 1;
    __pyx_t_9.start = 0;
    __pyx_t_8 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation_rollaxis(__pyx_v_b, __pyx_v_b_axis, 0, &__pyx_t_9)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8));
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":2416
 *     if a_axis:
 *         a = _manipulation.rollaxis(a, a_axis, 0)
 *     if b_axis:             # <<<<<<<<<<<<<<
 *         b = _manipulation.rollaxis(b, b_axis, 0)
 * 
 */
  }

  /* "cupy/core/core.pyx":2419
 *         b = _manipulation.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":2420
 * 
 *     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":2421
 *     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, 2421, __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, 2421, __pyx_L1_error)
    }
    __pyx_v_m = __Pyx_div_Py_ssize_t(__pyx_v_b->size, __pyx_v_k);

    /* "cupy/core/core.pyx":2422
 *     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, 2422, __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, 2422, __pyx_L1_error)
    }
    __pyx_v_n = __Pyx_div_Py_ssize_t(__pyx_v_a->size, __pyx_v_k);

    /* "cupy/core/core.pyx":2420
 * 
 *     k = a._shape[0]
 *     if k != 0:             # <<<<<<<<<<<<<<
 *         m = b.size // k
 *         n = a.size // k
 */
    goto __pyx_L14;
  }

  /* "cupy/core/core.pyx":2426
 *         # 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":2427
 *         # like NumPy.
 *         m = 0
 *         n = 0             # <<<<<<<<<<<<<<
 * 
 *     if not input_a_is_vec:
 */
    __pyx_v_n = 0;
  }
  __pyx_L14:;

  /* "cupy/core/core.pyx":2429
 *         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":2430
 * 
 *     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, 2430, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2429
 *         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":2431
 *     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":2432
 *         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, 2432, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2431
 *     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":2433
 *     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":2434
 *         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":2435
 *     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_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2435, __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, 2435, __pyx_L1_error)

      /* "cupy/core/core.pyx":2434
 *         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":2436
 *         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":2437
 *             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_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2437, __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, 2437, __pyx_L1_error)

      /* "cupy/core/core.pyx":2436
 *         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":2433
 *     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":2439
 *             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_8 = ((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_8)) __PYX_ERR(0, 2439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8);
  __pyx_t_8 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2378
 * # -----------------------------------------------------------------------------
 * 
 * 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_23dot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_22dot[] = "dot(ndarray a, ndarray b, ndarray out=None) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_23dot(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, 2378, __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, 2378, __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, 2378, __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, 2378, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(0, 2378, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 2378, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_22dot(__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_22dot(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, 2378, __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":2448
 * 
 * 
 * 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) {
  int __pyx_v_ndim;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_idx = 0;
  long __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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  long __pyx_t_9;
  long __pyx_t_10;
  long __pyx_t_11;
  __Pyx_RefNannySetupContext("_mat_ptrs", 0);

  /* "cupy/core/core.pyx":2458
 *         GPU array of pointers to matrices.
 *     """
 *     cdef int ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *     assert ndim > 2
 *     cdef Py_ssize_t sh_, st_
 */
  __pyx_v_ndim = __pyx_v_a->_shape.size();

  /* "cupy/core/core.pyx":2459
 *     """
 *     cdef int ndim = a._shape.size()
 *     assert ndim > 2             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t sh_, st_
 *     cdef ndarray idx
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_ndim > 2) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 2459, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/core/core.pyx":2463
 *     cdef ndarray idx
 *     idx = _mat_ptrs_kernel(
 *         a.data.ptr, a._strides[0],             # <<<<<<<<<<<<<<
 *         ndarray((a._shape[0],), dtype=numpy.uintp))
 * 
 */
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_a->data->ptr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_a->_strides[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/core.pyx":2464
 *     idx = _mat_ptrs_kernel(
 *         a.data.ptr, a._strides[0],
 *         ndarray((a._shape[0],), dtype=numpy.uintp))             # <<<<<<<<<<<<<<
 * 
 *     for i in range(1, ndim - 2):
 */
  __pyx_t_4 = PyInt_FromSsize_t((__pyx_v_a->_shape[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2464, __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 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uintp); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 2464, __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_4, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__mat_ptrs_kernel);
  __pyx_t_5 = __pyx_v_4cupy_4core_4core__mat_ptrs_kernel; __pyx_t_4 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_2, __pyx_t_3, __pyx_t_7};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2462, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_2, __pyx_t_3, __pyx_t_7};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2462, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2462, __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_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_8, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_8, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_8, __pyx_t_7);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_7 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2462, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":2462
 *     cdef Py_ssize_t sh_, st_
 *     cdef ndarray idx
 *     idx = _mat_ptrs_kernel(             # <<<<<<<<<<<<<<
 *         a.data.ptr, a._strides[0],
 *         ndarray((a._shape[0],), dtype=numpy.uintp))
 */
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2462, __pyx_L1_error)
  __pyx_v_idx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2466
 *         ndarray((a._shape[0],), dtype=numpy.uintp))
 * 
 *     for i in range(1, ndim - 2):             # <<<<<<<<<<<<<<
 *         idx = _mat_ptrs_kernel(
 *             idx[:, None], a._strides[i],
 */
  __pyx_t_9 = (__pyx_v_ndim - 2);
  __pyx_t_10 = __pyx_t_9;
  for (__pyx_t_11 = 1; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
    __pyx_v_i = __pyx_t_11;

    /* "cupy/core/core.pyx":2468
 *     for i in range(1, ndim - 2):
 *         idx = _mat_ptrs_kernel(
 *             idx[:, None], a._strides[i],             # <<<<<<<<<<<<<<
 *             ndarray((idx.size, a._shape[i]), dtype=numpy.uintp))
 *         idx = idx.ravel()
 */
    __pyx_t_5 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_idx), __pyx_tuple__52); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2468, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyInt_FromSsize_t((__pyx_v_a->_strides[__pyx_v_i])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2468, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);

    /* "cupy/core/core.pyx":2469
 *         idx = _mat_ptrs_kernel(
 *             idx[:, None], a._strides[i],
 *             ndarray((idx.size, a._shape[i]), dtype=numpy.uintp))             # <<<<<<<<<<<<<<
 *         idx = idx.ravel()
 *     return idx
 */
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_idx->size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2469, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_a->_shape[__pyx_v_i])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2469, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2469, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __pyx_t_7 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2469, __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, 2469, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2469, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uintp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2469, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 2469, __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_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2469, __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_INCREF(__pyx_v_4cupy_4core_4core__mat_ptrs_kernel);
    __pyx_t_2 = __pyx_v_4cupy_4core_4core__mat_ptrs_kernel; __pyx_t_3 = NULL;
    __pyx_t_8 = 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_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_5, __pyx_t_6, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2467, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __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[4] = {__pyx_t_3, __pyx_t_5, __pyx_t_6, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2467, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2467, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_8, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_8, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_8, __pyx_t_4);
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2467, __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;

    /* "cupy/core/core.pyx":2467
 * 
 *     for i in range(1, ndim - 2):
 *         idx = _mat_ptrs_kernel(             # <<<<<<<<<<<<<<
 *             idx[:, None], a._strides[i],
 *             ndarray((idx.size, a._shape[i]), dtype=numpy.uintp))
 */
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2467, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_idx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2470
 *             idx[:, None], a._strides[i],
 *             ndarray((idx.size, a._shape[i]), dtype=numpy.uintp))
 *         idx = idx.ravel()             # <<<<<<<<<<<<<<
 *     return idx
 * 
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_idx->__pyx_vtab)->ravel(__pyx_v_idx, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2470, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_idx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;
  }

  /* "cupy/core/core.pyx":2471
 *             ndarray((idx.size, a._shape[i]), dtype=numpy.uintp))
 *         idx = idx.ravel()
 *     return idx             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_idx));
  __pyx_r = __pyx_v_idx;
  goto __pyx_L0;

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

/* "cupy/core/core.pyx":2474
 * 
 * 
 * cdef Py_ssize_t _get_stride_for_strided_batched_gemm(ndarray a) except?0:             # <<<<<<<<<<<<<<
 *     cdef int ndim = a._shape.size()
 *     assert ndim > 2
 */

static Py_ssize_t __pyx_f_4cupy_4core_4core__get_stride_for_strided_batched_gemm(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a) {
  int __pyx_v_ndim;
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  __Pyx_RefNannySetupContext("_get_stride_for_strided_batched_gemm", 0);

  /* "cupy/core/core.pyx":2475
 * 
 * cdef Py_ssize_t _get_stride_for_strided_batched_gemm(ndarray a) except?0:
 *     cdef int ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *     assert ndim > 2
 *     return a._strides[ndim - 3] // <Py_ssize_t>a.itemsize
 */
  __pyx_v_ndim = __pyx_v_a->_shape.size();

  /* "cupy/core/core.pyx":2476
 * cdef Py_ssize_t _get_stride_for_strided_batched_gemm(ndarray a) except?0:
 *     cdef int ndim = a._shape.size()
 *     assert ndim > 2             # <<<<<<<<<<<<<<
 *     return a._strides[ndim - 3] // <Py_ssize_t>a.itemsize
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_ndim > 2) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 2476, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/core/core.pyx":2477
 *     cdef int ndim = a._shape.size()
 *     assert ndim > 2
 *     return a._strides[ndim - 3] // <Py_ssize_t>a.itemsize             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = (__pyx_v_a->_strides[(__pyx_v_ndim - 3)]);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2477, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(((Py_ssize_t)__pyx_t_3) == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 2477, __pyx_L1_error)
  }
  else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(((Py_ssize_t)__pyx_t_3) == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_1))) {
    PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
    __PYX_ERR(0, 2477, __pyx_L1_error)
  }
  __pyx_r = __Pyx_div_Py_ssize_t(__pyx_t_1, ((Py_ssize_t)__pyx_t_3));
  goto __pyx_L0;

  /* "cupy/core/core.pyx":2474
 * 
 * 
 * cdef Py_ssize_t _get_stride_for_strided_batched_gemm(ndarray a) except?0:             # <<<<<<<<<<<<<<
 *     cdef int ndim = a._shape.size()
 *     assert ndim > 2
 */

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

/* "cupy/core/core.pyx":2480
 * 
 * 
 * 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_25matmul(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_a_sh;
  Py_ssize_t __pyx_v_b_sh;
  Py_ssize_t __pyx_v_c_sh;
  Py_ssize_t __pyx_v_batchCount;
  Py_ssize_t __pyx_v_a_part_outshape;
  Py_ssize_t __pyx_v_b_part_outshape;
  int __pyx_v_orig_a_ndim;
  int __pyx_v_orig_b_ndim;
  int __pyx_v_a_ndim;
  int __pyx_v_b_ndim;
  int __pyx_v_ndim;
  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;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_out_view = 0;
  int __pyx_v_use_broadcast;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_orig_a = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_orig_b = NULL;
  Py_ssize_t __pyx_v_ldout;
  PyObject *__pyx_v_ret_dtype = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_out_shape = NULL;
  Py_ssize_t __pyx_v_lda;
  Py_ssize_t __pyx_v_ldb;
  PyObject *__pyx_v_handle = NULL;
  Py_ssize_t __pyx_v_strideA;
  Py_ssize_t __pyx_v_strideB;
  Py_ssize_t __pyx_v_strideC;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = NULL;
  PyObject *__pyx_8genexpr6__pyx_v__ = NULL;
  PyObject *__pyx_8genexpr7__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;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  struct __pyx_opt_args_4cupy_4core_4core_dot __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  std::vector<Py_ssize_t>  __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  std::vector<Py_ssize_t>  __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray __pyx_t_14;
  long __pyx_t_15;
  long __pyx_t_16;
  Py_ssize_t __pyx_t_17;
  Py_ssize_t __pyx_t_18;
  Py_ssize_t __pyx_t_19;
  int __pyx_t_20;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *(*__pyx_t_24)(PyObject *);
  PyObject *__pyx_t_25 = NULL;
  intptr_t __pyx_t_26;
  __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":2502
 *     """
 * 
 *     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":2503
 * 
 *     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__53, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2503, __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, 2503, __pyx_L1_error)

    /* "cupy/core/core.pyx":2502
 *     """
 * 
 *     if out is not None:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError('The out array as input is currently not '
 *                                   'supported')
 */
  }

  /* "cupy/core/core.pyx":2512
 *     cdef bint use_broadcast
 * 
 *     orig_a_ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *     orig_b_ndim = b._shape.size()
 *     if orig_a_ndim == 0 or orig_b_ndim == 0:
 */
  __pyx_v_orig_a_ndim = __pyx_v_a->_shape.size();

  /* "cupy/core/core.pyx":2513
 * 
 *     orig_a_ndim = a._shape.size()
 *     orig_b_ndim = b._shape.size()             # <<<<<<<<<<<<<<
 *     if orig_a_ndim == 0 or orig_b_ndim == 0:
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')
 */
  __pyx_v_orig_b_ndim = __pyx_v_b->_shape.size();

  /* "cupy/core/core.pyx":2514
 *     orig_a_ndim = a._shape.size()
 *     orig_b_ndim = b._shape.size()
 *     if orig_a_ndim == 0 or orig_b_ndim == 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')
 * 
 */
  __pyx_t_1 = ((__pyx_v_orig_a_ndim == 0) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_orig_b_ndim == 0) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L5_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "cupy/core/core.pyx":2515
 *     orig_b_ndim = b._shape.size()
 *     if orig_a_ndim == 0 or orig_b_ndim == 0:
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')             # <<<<<<<<<<<<<<
 * 
 *     ndim = max(orig_a_ndim, orig_b_ndim)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2515, __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, 2515, __pyx_L1_error)

    /* "cupy/core/core.pyx":2514
 *     orig_a_ndim = a._shape.size()
 *     orig_b_ndim = b._shape.size()
 *     if orig_a_ndim == 0 or orig_b_ndim == 0:             # <<<<<<<<<<<<<<
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')
 * 
 */
  }

  /* "cupy/core/core.pyx":2517
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')
 * 
 *     ndim = max(orig_a_ndim, orig_b_ndim)             # <<<<<<<<<<<<<<
 *     if ndim <= 2:
 *         return dot(a, b, out)
 */
  __pyx_t_4 = __pyx_v_orig_b_ndim;
  __pyx_t_5 = __pyx_v_orig_a_ndim;
  if (((__pyx_t_4 > __pyx_t_5) != 0)) {
    __pyx_t_6 = __pyx_t_4;
  } else {
    __pyx_t_6 = __pyx_t_5;
  }
  __pyx_v_ndim = __pyx_t_6;

  /* "cupy/core/core.pyx":2518
 * 
 *     ndim = max(orig_a_ndim, orig_b_ndim)
 *     if ndim <= 2:             # <<<<<<<<<<<<<<
 *         return dot(a, b, out)
 * 
 */
  __pyx_t_2 = ((__pyx_v_ndim <= 2) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2519
 *     ndim = max(orig_a_ndim, orig_b_ndim)
 *     if ndim <= 2:
 *         return dot(a, b, out)             # <<<<<<<<<<<<<<
 * 
 *     orig_a = a
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_7.__pyx_n = 1;
    __pyx_t_7.out = __pyx_v_out;
    __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_dot(__pyx_v_a, __pyx_v_b, 0, &__pyx_t_7)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2519, __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":2518
 * 
 *     ndim = max(orig_a_ndim, orig_b_ndim)
 *     if ndim <= 2:             # <<<<<<<<<<<<<<
 *         return dot(a, b, out)
 * 
 */
  }

  /* "cupy/core/core.pyx":2521
 *         return dot(a, b, out)
 * 
 *     orig_a = a             # <<<<<<<<<<<<<<
 *     orig_b = b
 *     a_part_outshape = b_part_outshape = 0
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_a));
  __pyx_v_orig_a = __pyx_v_a;

  /* "cupy/core/core.pyx":2522
 * 
 *     orig_a = a
 *     orig_b = b             # <<<<<<<<<<<<<<
 *     a_part_outshape = b_part_outshape = 0
 *     if orig_a_ndim == 1:
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_b));
  __pyx_v_orig_b = __pyx_v_b;

  /* "cupy/core/core.pyx":2523
 *     orig_a = a
 *     orig_b = b
 *     a_part_outshape = b_part_outshape = 0             # <<<<<<<<<<<<<<
 *     if orig_a_ndim == 1:
 *         a = _manipulation._reshape(a, (1, a.size))
 */
  __pyx_v_a_part_outshape = 0;
  __pyx_v_b_part_outshape = 0;

  /* "cupy/core/core.pyx":2524
 *     orig_b = b
 *     a_part_outshape = b_part_outshape = 0
 *     if orig_a_ndim == 1:             # <<<<<<<<<<<<<<
 *         a = _manipulation._reshape(a, (1, a.size))
 *     else:
 */
  __pyx_t_2 = ((__pyx_v_orig_a_ndim == 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2525
 *     a_part_outshape = b_part_outshape = 0
 *     if orig_a_ndim == 1:
 *         a = _manipulation._reshape(a, (1, a.size))             # <<<<<<<<<<<<<<
 *     else:
 *         a = a.view()
 */
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_a->size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_int_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_9 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2525, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__reshape(__pyx_v_a, __pyx_t_9, 0)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8));
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":2524
 *     orig_b = b
 *     a_part_outshape = b_part_outshape = 0
 *     if orig_a_ndim == 1:             # <<<<<<<<<<<<<<
 *         a = _manipulation._reshape(a, (1, a.size))
 *     else:
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":2527
 *         a = _manipulation._reshape(a, (1, a.size))
 *     else:
 *         a = a.view()             # <<<<<<<<<<<<<<
 *         a_part_outshape = a._shape[orig_a_ndim - 2]
 *     if orig_b_ndim == 1:
 */
  /*else*/ {
    __pyx_t_8 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2527, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_8));
    __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":2528
 *     else:
 *         a = a.view()
 *         a_part_outshape = a._shape[orig_a_ndim - 2]             # <<<<<<<<<<<<<<
 *     if orig_b_ndim == 1:
 *         b = _manipulation._reshape(b, (b.size, 1))
 */
    __pyx_v_a_part_outshape = (__pyx_v_a->_shape[(__pyx_v_orig_a_ndim - 2)]);
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":2529
 *         a = a.view()
 *         a_part_outshape = a._shape[orig_a_ndim - 2]
 *     if orig_b_ndim == 1:             # <<<<<<<<<<<<<<
 *         b = _manipulation._reshape(b, (b.size, 1))
 *         ldout = 1
 */
  __pyx_t_2 = ((__pyx_v_orig_b_ndim == 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2530
 *         a_part_outshape = a._shape[orig_a_ndim - 2]
 *     if orig_b_ndim == 1:
 *         b = _manipulation._reshape(b, (b.size, 1))             # <<<<<<<<<<<<<<
 *         ldout = 1
 *     else:
 */
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_b->size); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2530, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2530, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8);
    __Pyx_INCREF(__pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
    __pyx_t_8 = 0;
    __pyx_t_9 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2530, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__reshape(__pyx_v_b, __pyx_t_9, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2530, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2531
 *     if orig_b_ndim == 1:
 *         b = _manipulation._reshape(b, (b.size, 1))
 *         ldout = 1             # <<<<<<<<<<<<<<
 *     else:
 *         b = b.view()
 */
    __pyx_v_ldout = 1;

    /* "cupy/core/core.pyx":2529
 *         a = a.view()
 *         a_part_outshape = a._shape[orig_a_ndim - 2]
 *     if orig_b_ndim == 1:             # <<<<<<<<<<<<<<
 *         b = _manipulation._reshape(b, (b.size, 1))
 *         ldout = 1
 */
    goto __pyx_L9;
  }

  /* "cupy/core/core.pyx":2533
 *         ldout = 1
 *     else:
 *         b = b.view()             # <<<<<<<<<<<<<<
 *         b_part_outshape = ldout = b._shape[orig_b_ndim - 1]
 * 
 */
  /*else*/ {
    __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, 2533, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2534
 *     else:
 *         b = b.view()
 *         b_part_outshape = ldout = b._shape[orig_b_ndim - 1]             # <<<<<<<<<<<<<<
 * 
 *     # expand dims
 */
    __pyx_t_10 = (__pyx_v_b->_shape[(__pyx_v_orig_b_ndim - 1)]);
    __pyx_v_b_part_outshape = __pyx_t_10;
    __pyx_v_ldout = __pyx_t_10;
  }
  __pyx_L9:;

  /* "cupy/core/core.pyx":2537
 * 
 *     # expand dims
 *     a_ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *     b_ndim = b._shape.size()
 *     if a_ndim < ndim:
 */
  __pyx_v_a_ndim = __pyx_v_a->_shape.size();

  /* "cupy/core/core.pyx":2538
 *     # expand dims
 *     a_ndim = a._shape.size()
 *     b_ndim = b._shape.size()             # <<<<<<<<<<<<<<
 *     if a_ndim < ndim:
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 */
  __pyx_v_b_ndim = __pyx_v_b->_shape.size();

  /* "cupy/core/core.pyx":2539
 *     a_ndim = a._shape.size()
 *     b_ndim = b._shape.size()
 *     if a_ndim < ndim:             # <<<<<<<<<<<<<<
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 *         a._set_shape_and_strides(
 */
  __pyx_t_2 = ((__pyx_v_a_ndim < __pyx_v_ndim) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2542
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 *         a._set_shape_and_strides(
 *             (1,) * (ndim - a_ndim) + a.shape,             # <<<<<<<<<<<<<<
 *             (0,) * (ndim - a_ndim) + a.strides,
 *             True, True)
 */
    __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_ndim - __pyx_v_a_ndim)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = PyNumber_Multiply(__pyx_tuple__55, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2542, __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, 2542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = PyNumber_Add(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_9 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_11); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2542, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

    /* "cupy/core/core.pyx":2543
 *         a._set_shape_and_strides(
 *             (1,) * (ndim - a_ndim) + a.shape,
 *             (0,) * (ndim - a_ndim) + a.strides,             # <<<<<<<<<<<<<<
 *             True, True)
 *     if b_ndim < ndim:
 */
    __pyx_t_11 = __Pyx_PyInt_From_int((__pyx_v_ndim - __pyx_v_a_ndim)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__56, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_strides); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_8 = PyNumber_Add(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_12 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2543, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":2541
 *     if a_ndim < ndim:
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 *         a._set_shape_and_strides(             # <<<<<<<<<<<<<<
 *             (1,) * (ndim - a_ndim) + a.shape,
 *             (0,) * (ndim - a_ndim) + a.strides,
 */
    __pyx_t_8 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->_set_shape_and_strides(__pyx_v_a, __pyx_t_9, __pyx_t_12, 1, 1, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2541, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":2539
 *     a_ndim = a._shape.size()
 *     b_ndim = b._shape.size()
 *     if a_ndim < ndim:             # <<<<<<<<<<<<<<
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 *         a._set_shape_and_strides(
 */
  }

  /* "cupy/core/core.pyx":2545
 *             (0,) * (ndim - a_ndim) + a.strides,
 *             True, True)
 *     if b_ndim < ndim:             # <<<<<<<<<<<<<<
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 *         b._set_shape_and_strides(
 */
  __pyx_t_2 = ((__pyx_v_b_ndim < __pyx_v_ndim) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2548
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 *         b._set_shape_and_strides(
 *             (1,) * (ndim - b_ndim) + b.shape,             # <<<<<<<<<<<<<<
 *             (0,) * (ndim - b_ndim) + b.strides,
 *             True, True)
 */
    __pyx_t_8 = __Pyx_PyInt_From_int((__pyx_v_ndim - __pyx_v_b_ndim)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2548, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_11 = PyNumber_Multiply(__pyx_tuple__57, __pyx_t_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2548, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2548, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = PyNumber_Add(__pyx_t_11, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2548, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_12 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2548, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2549
 *         b._set_shape_and_strides(
 *             (1,) * (ndim - b_ndim) + b.shape,
 *             (0,) * (ndim - b_ndim) + b.strides,             # <<<<<<<<<<<<<<
 *             True, True)
 * 
 */
    __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_ndim - __pyx_v_b_ndim)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = PyNumber_Multiply(__pyx_tuple__58, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2549, __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_b), __pyx_n_s_strides); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = PyNumber_Add(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_9 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_t_11); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2549, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

    /* "cupy/core/core.pyx":2547
 *     if b_ndim < ndim:
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 *         b._set_shape_and_strides(             # <<<<<<<<<<<<<<
 *             (1,) * (ndim - b_ndim) + b.shape,
 *             (0,) * (ndim - b_ndim) + b.strides,
 */
    __pyx_t_11 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->_set_shape_and_strides(__pyx_v_b, __pyx_t_12, __pyx_t_9, 1, 1, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2547, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

    /* "cupy/core/core.pyx":2545
 *             (0,) * (ndim - a_ndim) + a.strides,
 *             True, True)
 *     if b_ndim < ndim:             # <<<<<<<<<<<<<<
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 *         b._set_shape_and_strides(
 */
  }

  /* "cupy/core/core.pyx":2552
 *             True, True)
 * 
 *     ret_dtype = numpy.promote_types(a.dtype, b.dtype)             # <<<<<<<<<<<<<<
 *     dtype = numpy.promote_types(ret_dtype, 'f')
 * 
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_promote_types); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_a->dtype, __pyx_v_b->dtype};
    __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2552, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_11);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_a->dtype, __pyx_v_b->dtype};
    __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2552, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_11);
  } else
  #endif
  {
    __pyx_t_13 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_a->dtype);
    __Pyx_GIVEREF(__pyx_v_a->dtype);
    PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_6, __pyx_v_a->dtype);
    __Pyx_INCREF(__pyx_v_b->dtype);
    __Pyx_GIVEREF(__pyx_v_b->dtype);
    PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_6, __pyx_v_b->dtype);
    __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_13, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_ret_dtype = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "cupy/core/core.pyx":2553
 * 
 *     ret_dtype = numpy.promote_types(a.dtype, b.dtype)
 *     dtype = numpy.promote_types(ret_dtype, 'f')             # <<<<<<<<<<<<<<
 * 
 *     a = ascontiguousarray(a, dtype)
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2553, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_promote_types); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2553, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_13)) {
    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_ret_dtype, __pyx_n_u_f};
    __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2553, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_11);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_ret_dtype, __pyx_n_u_f};
    __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2553, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_11);
  } else
  #endif
  {
    __pyx_t_3 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2553, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_INCREF(__pyx_v_ret_dtype);
    __Pyx_GIVEREF(__pyx_v_ret_dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, __pyx_v_ret_dtype);
    __Pyx_INCREF(__pyx_n_u_f);
    __Pyx_GIVEREF(__pyx_n_u_f);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, __pyx_n_u_f);
    __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_3, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2553, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_v_dtype = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "cupy/core/core.pyx":2555
 *     dtype = numpy.promote_types(ret_dtype, 'f')
 * 
 *     a = ascontiguousarray(a, dtype)             # <<<<<<<<<<<<<<
 *     b = ascontiguousarray(b, dtype)
 * 
 */
  __pyx_t_14.__pyx_n = 1;
  __pyx_t_14.dtype = __pyx_v_dtype;
  __pyx_t_11 = ((PyObject *)__pyx_f_4cupy_4core_4core_ascontiguousarray(__pyx_v_a, 0, &__pyx_t_14)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2555, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_11));
  __pyx_t_11 = 0;

  /* "cupy/core/core.pyx":2556
 * 
 *     a = ascontiguousarray(a, dtype)
 *     b = ascontiguousarray(b, dtype)             # <<<<<<<<<<<<<<
 * 
 *     # broadcast
 */
  __pyx_t_14.__pyx_n = 1;
  __pyx_t_14.dtype = __pyx_v_dtype;
  __pyx_t_11 = ((PyObject *)__pyx_f_4cupy_4core_4core_ascontiguousarray(__pyx_v_b, 0, &__pyx_t_14)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_11));
  __pyx_t_11 = 0;

  /* "cupy/core/core.pyx":2559
 * 
 *     # broadcast
 *     batchCount = 1  # batchCount = numpy.prod(out_shape[:-2])             # <<<<<<<<<<<<<<
 *     out_shape = []
 *     use_broadcast = False
 */
  __pyx_v_batchCount = 1;

  /* "cupy/core/core.pyx":2560
 *     # broadcast
 *     batchCount = 1  # batchCount = numpy.prod(out_shape[:-2])
 *     out_shape = []             # <<<<<<<<<<<<<<
 *     use_broadcast = False
 *     for i in range(0, ndim - 2):
 */
  __pyx_t_11 = PyList_New(0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_v_out_shape = ((PyObject*)__pyx_t_11);
  __pyx_t_11 = 0;

  /* "cupy/core/core.pyx":2561
 *     batchCount = 1  # batchCount = numpy.prod(out_shape[:-2])
 *     out_shape = []
 *     use_broadcast = False             # <<<<<<<<<<<<<<
 *     for i in range(0, ndim - 2):
 *         a_sh = a._shape[i]
 */
  __pyx_v_use_broadcast = 0;

  /* "cupy/core/core.pyx":2562
 *     out_shape = []
 *     use_broadcast = False
 *     for i in range(0, ndim - 2):             # <<<<<<<<<<<<<<
 *         a_sh = a._shape[i]
 *         b_sh = b._shape[i]
 */
  __pyx_t_15 = (__pyx_v_ndim - 2);
  __pyx_t_16 = __pyx_t_15;
  for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_16; __pyx_t_10+=1) {
    __pyx_v_i = __pyx_t_10;

    /* "cupy/core/core.pyx":2563
 *     use_broadcast = False
 *     for i in range(0, ndim - 2):
 *         a_sh = a._shape[i]             # <<<<<<<<<<<<<<
 *         b_sh = b._shape[i]
 *         if a_sh != b_sh and a_sh != 1 and b_sh != 1:
 */
    __pyx_v_a_sh = (__pyx_v_a->_shape[__pyx_v_i]);

    /* "cupy/core/core.pyx":2564
 *     for i in range(0, ndim - 2):
 *         a_sh = a._shape[i]
 *         b_sh = b._shape[i]             # <<<<<<<<<<<<<<
 *         if a_sh != b_sh and a_sh != 1 and b_sh != 1:
 *             raise ValueError(
 */
    __pyx_v_b_sh = (__pyx_v_b->_shape[__pyx_v_i]);

    /* "cupy/core/core.pyx":2565
 *         a_sh = a._shape[i]
 *         b_sh = b._shape[i]
 *         if a_sh != b_sh and a_sh != 1 and b_sh != 1:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'operands could not be broadcast together with '
 */
    __pyx_t_1 = ((__pyx_v_a_sh != __pyx_v_b_sh) != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L15_bool_binop_done;
    }
    __pyx_t_1 = ((__pyx_v_a_sh != 1) != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L15_bool_binop_done;
    }
    __pyx_t_1 = ((__pyx_v_b_sh != 1) != 0);
    __pyx_t_2 = __pyx_t_1;
    __pyx_L15_bool_binop_done:;
    if (unlikely(__pyx_t_2)) {

      /* "cupy/core/core.pyx":2566
 *         b_sh = b._shape[i]
 *         if a_sh != b_sh and a_sh != 1 and b_sh != 1:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'operands could not be broadcast together with '
 *                 'remapped shapes')
 */
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2566, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_Raise(__pyx_t_11, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __PYX_ERR(0, 2566, __pyx_L1_error)

      /* "cupy/core/core.pyx":2565
 *         a_sh = a._shape[i]
 *         b_sh = b._shape[i]
 *         if a_sh != b_sh and a_sh != 1 and b_sh != 1:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'operands could not be broadcast together with '
 */
    }

    /* "cupy/core/core.pyx":2570
 *                 'remapped shapes')
 * 
 *         if a_sh == 0 or b_sh == 0:             # <<<<<<<<<<<<<<
 *             c_sh = 0
 *         else:
 */
    __pyx_t_1 = ((__pyx_v_a_sh == 0) != 0);
    if (!__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L19_bool_binop_done;
    }
    __pyx_t_1 = ((__pyx_v_b_sh == 0) != 0);
    __pyx_t_2 = __pyx_t_1;
    __pyx_L19_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2571
 * 
 *         if a_sh == 0 or b_sh == 0:
 *             c_sh = 0             # <<<<<<<<<<<<<<
 *         else:
 *             c_sh = max(a_sh, b_sh)
 */
      __pyx_v_c_sh = 0;

      /* "cupy/core/core.pyx":2570
 *                 'remapped shapes')
 * 
 *         if a_sh == 0 or b_sh == 0:             # <<<<<<<<<<<<<<
 *             c_sh = 0
 *         else:
 */
      goto __pyx_L18;
    }

    /* "cupy/core/core.pyx":2573
 *             c_sh = 0
 *         else:
 *             c_sh = max(a_sh, b_sh)             # <<<<<<<<<<<<<<
 *         batchCount *= c_sh
 *         out_shape.append(c_sh)
 */
    /*else*/ {
      __pyx_t_17 = __pyx_v_b_sh;
      __pyx_t_18 = __pyx_v_a_sh;
      if (((__pyx_t_17 > __pyx_t_18) != 0)) {
        __pyx_t_19 = __pyx_t_17;
      } else {
        __pyx_t_19 = __pyx_t_18;
      }
      __pyx_v_c_sh = __pyx_t_19;
    }
    __pyx_L18:;

    /* "cupy/core/core.pyx":2574
 *         else:
 *             c_sh = max(a_sh, b_sh)
 *         batchCount *= c_sh             # <<<<<<<<<<<<<<
 *         out_shape.append(c_sh)
 *         if a_sh == 1 and c_sh > 1:
 */
    __pyx_v_batchCount = (__pyx_v_batchCount * __pyx_v_c_sh);

    /* "cupy/core/core.pyx":2575
 *             c_sh = max(a_sh, b_sh)
 *         batchCount *= c_sh
 *         out_shape.append(c_sh)             # <<<<<<<<<<<<<<
 *         if a_sh == 1 and c_sh > 1:
 *             a._strides[i] = 0
 */
    __pyx_t_11 = PyInt_FromSsize_t(__pyx_v_c_sh); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2575, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_out_shape, __pyx_t_11); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 2575, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

    /* "cupy/core/core.pyx":2576
 *         batchCount *= c_sh
 *         out_shape.append(c_sh)
 *         if a_sh == 1 and c_sh > 1:             # <<<<<<<<<<<<<<
 *             a._strides[i] = 0
 *             a._shape[i] = c_sh
 */
    __pyx_t_1 = ((__pyx_v_a_sh == 1) != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L22_bool_binop_done;
    }
    __pyx_t_1 = ((__pyx_v_c_sh > 1) != 0);
    __pyx_t_2 = __pyx_t_1;
    __pyx_L22_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2577
 *         out_shape.append(c_sh)
 *         if a_sh == 1 and c_sh > 1:
 *             a._strides[i] = 0             # <<<<<<<<<<<<<<
 *             a._shape[i] = c_sh
 *             a._c_contiguous = a._f_contiguous = False
 */
      (__pyx_v_a->_strides[__pyx_v_i]) = 0;

      /* "cupy/core/core.pyx":2578
 *         if a_sh == 1 and c_sh > 1:
 *             a._strides[i] = 0
 *             a._shape[i] = c_sh             # <<<<<<<<<<<<<<
 *             a._c_contiguous = a._f_contiguous = False
 *             use_broadcast = True
 */
      (__pyx_v_a->_shape[__pyx_v_i]) = __pyx_v_c_sh;

      /* "cupy/core/core.pyx":2579
 *             a._strides[i] = 0
 *             a._shape[i] = c_sh
 *             a._c_contiguous = a._f_contiguous = False             # <<<<<<<<<<<<<<
 *             use_broadcast = True
 * 
 */
      __pyx_v_a->_c_contiguous = 0;
      __pyx_v_a->_f_contiguous = 0;

      /* "cupy/core/core.pyx":2580
 *             a._shape[i] = c_sh
 *             a._c_contiguous = a._f_contiguous = False
 *             use_broadcast = True             # <<<<<<<<<<<<<<
 * 
 *         if b_sh == 1 and c_sh > 1:
 */
      __pyx_v_use_broadcast = 1;

      /* "cupy/core/core.pyx":2576
 *         batchCount *= c_sh
 *         out_shape.append(c_sh)
 *         if a_sh == 1 and c_sh > 1:             # <<<<<<<<<<<<<<
 *             a._strides[i] = 0
 *             a._shape[i] = c_sh
 */
    }

    /* "cupy/core/core.pyx":2582
 *             use_broadcast = True
 * 
 *         if b_sh == 1 and c_sh > 1:             # <<<<<<<<<<<<<<
 *             b._strides[i] = 0
 *             b._shape[i] = c_sh
 */
    __pyx_t_1 = ((__pyx_v_b_sh == 1) != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L25_bool_binop_done;
    }
    __pyx_t_1 = ((__pyx_v_c_sh > 1) != 0);
    __pyx_t_2 = __pyx_t_1;
    __pyx_L25_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2583
 * 
 *         if b_sh == 1 and c_sh > 1:
 *             b._strides[i] = 0             # <<<<<<<<<<<<<<
 *             b._shape[i] = c_sh
 *             b._c_contiguous = b._f_contiguous = False
 */
      (__pyx_v_b->_strides[__pyx_v_i]) = 0;

      /* "cupy/core/core.pyx":2584
 *         if b_sh == 1 and c_sh > 1:
 *             b._strides[i] = 0
 *             b._shape[i] = c_sh             # <<<<<<<<<<<<<<
 *             b._c_contiguous = b._f_contiguous = False
 *             use_broadcast = True
 */
      (__pyx_v_b->_shape[__pyx_v_i]) = __pyx_v_c_sh;

      /* "cupy/core/core.pyx":2585
 *             b._strides[i] = 0
 *             b._shape[i] = c_sh
 *             b._c_contiguous = b._f_contiguous = False             # <<<<<<<<<<<<<<
 *             use_broadcast = True
 * 
 */
      __pyx_v_b->_c_contiguous = 0;
      __pyx_v_b->_f_contiguous = 0;

      /* "cupy/core/core.pyx":2586
 *             b._shape[i] = c_sh
 *             b._c_contiguous = b._f_contiguous = False
 *             use_broadcast = True             # <<<<<<<<<<<<<<
 * 
 *     if orig_a_ndim != 1:
 */
      __pyx_v_use_broadcast = 1;

      /* "cupy/core/core.pyx":2582
 *             use_broadcast = True
 * 
 *         if b_sh == 1 and c_sh > 1:             # <<<<<<<<<<<<<<
 *             b._strides[i] = 0
 *             b._shape[i] = c_sh
 */
    }
  }

  /* "cupy/core/core.pyx":2588
 *             use_broadcast = True
 * 
 *     if orig_a_ndim != 1:             # <<<<<<<<<<<<<<
 *         out_shape.append(a_part_outshape)
 *     if orig_b_ndim != 1:
 */
  __pyx_t_2 = ((__pyx_v_orig_a_ndim != 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2589
 * 
 *     if orig_a_ndim != 1:
 *         out_shape.append(a_part_outshape)             # <<<<<<<<<<<<<<
 *     if orig_b_ndim != 1:
 *         out_shape.append(b_part_outshape)
 */
    __pyx_t_11 = PyInt_FromSsize_t(__pyx_v_a_part_outshape); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2589, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_out_shape, __pyx_t_11); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 2589, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

    /* "cupy/core/core.pyx":2588
 *             use_broadcast = True
 * 
 *     if orig_a_ndim != 1:             # <<<<<<<<<<<<<<
 *         out_shape.append(a_part_outshape)
 *     if orig_b_ndim != 1:
 */
  }

  /* "cupy/core/core.pyx":2590
 *     if orig_a_ndim != 1:
 *         out_shape.append(a_part_outshape)
 *     if orig_b_ndim != 1:             # <<<<<<<<<<<<<<
 *         out_shape.append(b_part_outshape)
 * 
 */
  __pyx_t_2 = ((__pyx_v_orig_b_ndim != 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2591
 *         out_shape.append(a_part_outshape)
 *     if orig_b_ndim != 1:
 *         out_shape.append(b_part_outshape)             # <<<<<<<<<<<<<<
 * 
 *     # (A B)^T = B^T A^T
 */
    __pyx_t_11 = PyInt_FromSsize_t(__pyx_v_b_part_outshape); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2591, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_out_shape, __pyx_t_11); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 2591, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

    /* "cupy/core/core.pyx":2590
 *     if orig_a_ndim != 1:
 *         out_shape.append(a_part_outshape)
 *     if orig_b_ndim != 1:             # <<<<<<<<<<<<<<
 *         out_shape.append(b_part_outshape)
 * 
 */
  }

  /* "cupy/core/core.pyx":2594
 * 
 *     # (A B)^T = B^T A^T
 *     a, b = b, a             # <<<<<<<<<<<<<<
 * 
 *     ka = a._shape[ndim - 2]
 */
  __pyx_t_21 = ((PyObject *)__pyx_v_b);
  __pyx_t_22 = ((PyObject *)__pyx_v_a);
  __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_21);
  __pyx_t_21 = 0;
  __pyx_v_b = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_22);
  __pyx_t_22 = 0;

  /* "cupy/core/core.pyx":2596
 *     a, b = b, a
 * 
 *     ka = a._shape[ndim - 2]             # <<<<<<<<<<<<<<
 *     lda = n = a._shape[ndim - 1]
 *     m = b._shape[ndim - 2]
 */
  __pyx_v_ka = (__pyx_v_a->_shape[(__pyx_v_ndim - 2)]);

  /* "cupy/core/core.pyx":2597
 * 
 *     ka = a._shape[ndim - 2]
 *     lda = n = a._shape[ndim - 1]             # <<<<<<<<<<<<<<
 *     m = b._shape[ndim - 2]
 *     ldb = kb = b._shape[ndim - 1]
 */
  __pyx_t_10 = (__pyx_v_a->_shape[(__pyx_v_ndim - 1)]);
  __pyx_v_lda = __pyx_t_10;
  __pyx_v_n = __pyx_t_10;

  /* "cupy/core/core.pyx":2598
 *     ka = a._shape[ndim - 2]
 *     lda = n = a._shape[ndim - 1]
 *     m = b._shape[ndim - 2]             # <<<<<<<<<<<<<<
 *     ldb = kb = b._shape[ndim - 1]
 * 
 */
  __pyx_v_m = (__pyx_v_b->_shape[(__pyx_v_ndim - 2)]);

  /* "cupy/core/core.pyx":2599
 *     lda = n = a._shape[ndim - 1]
 *     m = b._shape[ndim - 2]
 *     ldb = kb = b._shape[ndim - 1]             # <<<<<<<<<<<<<<
 * 
 *     if ka != kb:
 */
  __pyx_t_10 = (__pyx_v_b->_shape[(__pyx_v_ndim - 1)]);
  __pyx_v_ldb = __pyx_t_10;
  __pyx_v_kb = __pyx_t_10;

  /* "cupy/core/core.pyx":2601
 *     ldb = kb = b._shape[ndim - 1]
 * 
 *     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":2603
 *     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_u_shapes_and_not_aligned, __pyx_n_s_format); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2603, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);

    /* "cupy/core/core.pyx":2604
 *         raise ValueError(
 *             'shapes ({}) and ({}) not aligned'.format(
 *                 ','.join([str(_) for _ in orig_a.shape]),             # <<<<<<<<<<<<<<
 *                 ','.join([str(_) for _ in orig_b.shape])))
 * 
 */
    { /* enter inner scope */
      __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2604, __pyx_L32_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_orig_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2604, __pyx_L32_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) {
        __pyx_t_23 = __pyx_t_8; __Pyx_INCREF(__pyx_t_23); __pyx_t_10 = 0;
        __pyx_t_24 = NULL;
      } else {
        __pyx_t_10 = -1; __pyx_t_23 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 2604, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_23);
        __pyx_t_24 = Py_TYPE(__pyx_t_23)->tp_iternext; if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2604, __pyx_L32_error)
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      for (;;) {
        if (likely(!__pyx_t_24)) {
          if (likely(PyList_CheckExact(__pyx_t_23))) {
            if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_23)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_8 = PyList_GET_ITEM(__pyx_t_23, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 2604, __pyx_L32_error)
            #else
            __pyx_t_8 = PySequence_ITEM(__pyx_t_23, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2604, __pyx_L32_error)
            __Pyx_GOTREF(__pyx_t_8);
            #endif
          } else {
            if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_23)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_23, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 2604, __pyx_L32_error)
            #else
            __pyx_t_8 = PySequence_ITEM(__pyx_t_23, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2604, __pyx_L32_error)
            __Pyx_GOTREF(__pyx_t_8);
            #endif
          }
        } else {
          __pyx_t_8 = __pyx_t_24(__pyx_t_23);
          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, 2604, __pyx_L32_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_8);
        }
        __Pyx_XDECREF_SET(__pyx_8genexpr6__pyx_v__, __pyx_t_8);
        __pyx_t_8 = 0;
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_8genexpr6__pyx_v__); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2604, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_8);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 2604, __pyx_L32_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __Pyx_XDECREF(__pyx_8genexpr6__pyx_v__); __pyx_8genexpr6__pyx_v__ = 0;
      goto __pyx_L35_exit_scope;
      __pyx_L32_error:;
      __Pyx_XDECREF(__pyx_8genexpr6__pyx_v__); __pyx_8genexpr6__pyx_v__ = 0;
      goto __pyx_L1_error;
      __pyx_L35_exit_scope:;
    } /* exit inner scope */
    __pyx_t_23 = PyUnicode_Join(__pyx_kp_u__60, __pyx_t_3); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 2604, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":2605
 *             'shapes ({}) and ({}) not aligned'.format(
 *                 ','.join([str(_) for _ in orig_a.shape]),
 *                 ','.join([str(_) for _ in orig_b.shape])))             # <<<<<<<<<<<<<<
 * 
 *     if a.size == 0 or b.size == 0:
 */
    { /* enter inner scope */
      __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2605, __pyx_L38_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_orig_b), __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2605, __pyx_L38_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) {
        __pyx_t_25 = __pyx_t_8; __Pyx_INCREF(__pyx_t_25); __pyx_t_10 = 0;
        __pyx_t_24 = NULL;
      } else {
        __pyx_t_10 = -1; __pyx_t_25 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2605, __pyx_L38_error)
        __Pyx_GOTREF(__pyx_t_25);
        __pyx_t_24 = Py_TYPE(__pyx_t_25)->tp_iternext; if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2605, __pyx_L38_error)
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      for (;;) {
        if (likely(!__pyx_t_24)) {
          if (likely(PyList_CheckExact(__pyx_t_25))) {
            if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_25)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_8 = PyList_GET_ITEM(__pyx_t_25, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 2605, __pyx_L38_error)
            #else
            __pyx_t_8 = PySequence_ITEM(__pyx_t_25, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2605, __pyx_L38_error)
            __Pyx_GOTREF(__pyx_t_8);
            #endif
          } else {
            if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_25)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_25, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 2605, __pyx_L38_error)
            #else
            __pyx_t_8 = PySequence_ITEM(__pyx_t_25, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2605, __pyx_L38_error)
            __Pyx_GOTREF(__pyx_t_8);
            #endif
          }
        } else {
          __pyx_t_8 = __pyx_t_24(__pyx_t_25);
          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, 2605, __pyx_L38_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_8);
        }
        __Pyx_XDECREF_SET(__pyx_8genexpr7__pyx_v__, __pyx_t_8);
        __pyx_t_8 = 0;
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_8genexpr7__pyx_v__); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2605, __pyx_L38_error)
        __Pyx_GOTREF(__pyx_t_8);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 2605, __pyx_L38_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
      __Pyx_XDECREF(__pyx_8genexpr7__pyx_v__); __pyx_8genexpr7__pyx_v__ = 0;
      goto __pyx_L41_exit_scope;
      __pyx_L38_error:;
      __Pyx_XDECREF(__pyx_8genexpr7__pyx_v__); __pyx_8genexpr7__pyx_v__ = 0;
      goto __pyx_L1_error;
      __pyx_L41_exit_scope:;
    } /* exit inner scope */
    __pyx_t_25 = PyUnicode_Join(__pyx_kp_u__60, __pyx_t_3); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2605, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    __pyx_t_6 = 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_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_13)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_23, __pyx_t_25};
      __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2603, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 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[3] = {__pyx_t_3, __pyx_t_23, __pyx_t_25};
      __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2603, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2603, __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_23);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_6, __pyx_t_23);
      __Pyx_GIVEREF(__pyx_t_25);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_6, __pyx_t_25);
      __pyx_t_23 = 0;
      __pyx_t_25 = 0;
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_8, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2603, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

    /* "cupy/core/core.pyx":2602
 * 
 *     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_11); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2602, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_Raise(__pyx_t_13, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __PYX_ERR(0, 2602, __pyx_L1_error)

    /* "cupy/core/core.pyx":2601
 *     ldb = kb = b._shape[ndim - 1]
 * 
 *     if ka != kb:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'shapes ({}) and ({}) not aligned'.format(
 */
  }

  /* "cupy/core/core.pyx":2607
 *                 ','.join([str(_) for _ in orig_b.shape])))
 * 
 *     if a.size == 0 or b.size == 0:             # <<<<<<<<<<<<<<
 *         return cupy.zeros(out_shape, ret_dtype)
 * 
 */
  __pyx_t_1 = ((__pyx_v_a->size == 0) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L43_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_b->size == 0) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L43_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2608
 * 
 *     if a.size == 0 or b.size == 0:
 *         return cupy.zeros(out_shape, ret_dtype)             # <<<<<<<<<<<<<<
 * 
 *     out = ndarray(out_shape, dtype=dtype)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2608, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_zeros); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2608, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = NULL;
    __pyx_t_6 = 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_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_out_shape, __pyx_v_ret_dtype};
      __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2608, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_13);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_out_shape, __pyx_v_ret_dtype};
      __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2608, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_13);
    } else
    #endif
    {
      __pyx_t_25 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2608, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);
      if (__pyx_t_11) {
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_25, 0, __pyx_t_11); __pyx_t_11 = NULL;
      }
      __Pyx_INCREF(__pyx_v_out_shape);
      __Pyx_GIVEREF(__pyx_v_out_shape);
      PyTuple_SET_ITEM(__pyx_t_25, 0+__pyx_t_6, __pyx_v_out_shape);
      __Pyx_INCREF(__pyx_v_ret_dtype);
      __Pyx_GIVEREF(__pyx_v_ret_dtype);
      PyTuple_SET_ITEM(__pyx_t_25, 1+__pyx_t_6, __pyx_v_ret_dtype);
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_25, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2608, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2608, __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":2607
 *                 ','.join([str(_) for _ in orig_b.shape])))
 * 
 *     if a.size == 0 or b.size == 0:             # <<<<<<<<<<<<<<
 *         return cupy.zeros(out_shape, ret_dtype)
 * 
 */
  }

  /* "cupy/core/core.pyx":2610
 *         return cupy.zeros(out_shape, ret_dtype)
 * 
 *     out = ndarray(out_shape, dtype=dtype)             # <<<<<<<<<<<<<<
 * 
 *     if orig_a_ndim == 1 or orig_b_ndim == 1:
 */
  __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2610, __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_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2610, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 2610, __pyx_L1_error)
  __pyx_t_25 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_13, __pyx_t_8); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2610, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_25);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_25));
  __pyx_t_25 = 0;

  /* "cupy/core/core.pyx":2612
 *     out = ndarray(out_shape, dtype=dtype)
 * 
 *     if orig_a_ndim == 1 or orig_b_ndim == 1:             # <<<<<<<<<<<<<<
 *         out_view = out.view()
 *         if orig_b_ndim == 1:
 */
  __pyx_t_1 = ((__pyx_v_orig_a_ndim == 1) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L46_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_orig_b_ndim == 1) != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L46_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2613
 * 
 *     if orig_a_ndim == 1 or orig_b_ndim == 1:
 *         out_view = out.view()             # <<<<<<<<<<<<<<
 *         if orig_b_ndim == 1:
 *             out_view._shape.push_back(1)
 */
    __pyx_t_25 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_out->__pyx_vtab)->view(__pyx_v_out, 0, NULL)); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2613, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __pyx_v_out_view = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_25);
    __pyx_t_25 = 0;

    /* "cupy/core/core.pyx":2614
 *     if orig_a_ndim == 1 or orig_b_ndim == 1:
 *         out_view = out.view()
 *         if orig_b_ndim == 1:             # <<<<<<<<<<<<<<
 *             out_view._shape.push_back(1)
 *             out_view._strides.push_back(0)
 */
    __pyx_t_2 = ((__pyx_v_orig_b_ndim == 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2615
 *         out_view = out.view()
 *         if orig_b_ndim == 1:
 *             out_view._shape.push_back(1)             # <<<<<<<<<<<<<<
 *             out_view._strides.push_back(0)
 *         if orig_a_ndim == 1:
 */
      try {
        __pyx_v_out_view->_shape.push_back(1);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 2615, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":2616
 *         if orig_b_ndim == 1:
 *             out_view._shape.push_back(1)
 *             out_view._strides.push_back(0)             # <<<<<<<<<<<<<<
 *         if orig_a_ndim == 1:
 *             out_view._shape.insert(out_view._shape.end() - 1, 1)
 */
      try {
        __pyx_v_out_view->_strides.push_back(0);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 2616, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":2614
 *     if orig_a_ndim == 1 or orig_b_ndim == 1:
 *         out_view = out.view()
 *         if orig_b_ndim == 1:             # <<<<<<<<<<<<<<
 *             out_view._shape.push_back(1)
 *             out_view._strides.push_back(0)
 */
    }

    /* "cupy/core/core.pyx":2617
 *             out_view._shape.push_back(1)
 *             out_view._strides.push_back(0)
 *         if orig_a_ndim == 1:             # <<<<<<<<<<<<<<
 *             out_view._shape.insert(out_view._shape.end() - 1, 1)
 *             out_view._strides.insert(out_view._strides.end() - 1, 0)
 */
    __pyx_t_2 = ((__pyx_v_orig_a_ndim == 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2618
 *             out_view._strides.push_back(0)
 *         if orig_a_ndim == 1:
 *             out_view._shape.insert(out_view._shape.end() - 1, 1)             # <<<<<<<<<<<<<<
 *             out_view._strides.insert(out_view._strides.end() - 1, 0)
 *         assert out_view._c_contiguous
 */
      try {
        __pyx_v_out_view->_shape.insert((__pyx_v_out_view->_shape.end() - 1), 1);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 2618, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":2619
 *         if orig_a_ndim == 1:
 *             out_view._shape.insert(out_view._shape.end() - 1, 1)
 *             out_view._strides.insert(out_view._strides.end() - 1, 0)             # <<<<<<<<<<<<<<
 *         assert out_view._c_contiguous
 *         out_view._update_f_contiguity()
 */
      try {
        __pyx_v_out_view->_strides.insert((__pyx_v_out_view->_strides.end() - 1), 0);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 2619, __pyx_L1_error)
      }

      /* "cupy/core/core.pyx":2617
 *             out_view._shape.push_back(1)
 *             out_view._strides.push_back(0)
 *         if orig_a_ndim == 1:             # <<<<<<<<<<<<<<
 *             out_view._shape.insert(out_view._shape.end() - 1, 1)
 *             out_view._strides.insert(out_view._strides.end() - 1, 0)
 */
    }

    /* "cupy/core/core.pyx":2620
 *             out_view._shape.insert(out_view._shape.end() - 1, 1)
 *             out_view._strides.insert(out_view._strides.end() - 1, 0)
 *         assert out_view._c_contiguous             # <<<<<<<<<<<<<<
 *         out_view._update_f_contiguity()
 *     else:
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      if (unlikely(!(__pyx_v_out_view->_c_contiguous != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(0, 2620, __pyx_L1_error)
      }
    }
    #endif

    /* "cupy/core/core.pyx":2621
 *             out_view._strides.insert(out_view._strides.end() - 1, 0)
 *         assert out_view._c_contiguous
 *         out_view._update_f_contiguity()             # <<<<<<<<<<<<<<
 *     else:
 *         out_view = out
 */
    __pyx_t_25 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_out_view->__pyx_vtab)->_update_f_contiguity(__pyx_v_out_view, 0); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2621, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

    /* "cupy/core/core.pyx":2612
 *     out = ndarray(out_shape, dtype=dtype)
 * 
 *     if orig_a_ndim == 1 or orig_b_ndim == 1:             # <<<<<<<<<<<<<<
 *         out_view = out.view()
 *         if orig_b_ndim == 1:
 */
    goto __pyx_L45;
  }

  /* "cupy/core/core.pyx":2623
 *         out_view._update_f_contiguity()
 *     else:
 *         out_view = out             # <<<<<<<<<<<<<<
 * 
 *     global _cuda_runtime_version
 */
  /*else*/ {
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __pyx_v_out_view = __pyx_v_out;
  }
  __pyx_L45:;

  /* "cupy/core/core.pyx":2626
 * 
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version < 0:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  __pyx_t_2 = ((__pyx_v_4cupy_4core_4core__cuda_runtime_version < 0) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2627
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version < 0:
 *         _cuda_runtime_version = runtime.runtimeGetVersion()             # <<<<<<<<<<<<<<
 * 
 *     handle = device.get_cublas_handle()
 */
    __pyx_t_6 = __pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion(0); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2627, __pyx_L1_error)
    __pyx_v_4cupy_4core_4core__cuda_runtime_version = __pyx_t_6;

    /* "cupy/core/core.pyx":2626
 * 
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version < 0:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  }

  /* "cupy/core/core.pyx":2629
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 *     handle = device.get_cublas_handle()             # <<<<<<<<<<<<<<
 * 
 *     # TODO(anaruse) use cublasGemmStridedBatchedEx() when cuda version >= 9.1
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_device); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_get_cublas_handle); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(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);
    }
  }
  if (__pyx_t_8) {
    __pyx_t_25 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_8); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2629, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    __pyx_t_25 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2629, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_25);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_v_handle = __pyx_t_25;
  __pyx_t_25 = 0;

  /* "cupy/core/core.pyx":2632
 * 
 *     # TODO(anaruse) use cublasGemmStridedBatchedEx() when cuda version >= 9.1
 *     if not use_broadcast:             # <<<<<<<<<<<<<<
 *         strideA = _get_stride_for_strided_batched_gemm(a)
 *         strideB = _get_stride_for_strided_batched_gemm(b)
 */
  __pyx_t_2 = ((!(__pyx_v_use_broadcast != 0)) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2633
 *     # TODO(anaruse) use cublasGemmStridedBatchedEx() when cuda version >= 9.1
 *     if not use_broadcast:
 *         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_t_10 = __pyx_f_4cupy_4core_4core__get_stride_for_strided_batched_gemm(__pyx_v_a); if (unlikely(__pyx_t_10 == ((Py_ssize_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2633, __pyx_L1_error)
    __pyx_v_strideA = __pyx_t_10;

    /* "cupy/core/core.pyx":2634
 *     if not use_broadcast:
 *         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_t_10 = __pyx_f_4cupy_4core_4core__get_stride_for_strided_batched_gemm(__pyx_v_b); if (unlikely(__pyx_t_10 == ((Py_ssize_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2634, __pyx_L1_error)
    __pyx_v_strideB = __pyx_t_10;

    /* "cupy/core/core.pyx":2635
 *         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:
 *             cublas.sgemmStridedBatched(
 */
    __pyx_t_10 = __pyx_f_4cupy_4core_4core__get_stride_for_strided_batched_gemm(__pyx_v_out_view); if (unlikely(__pyx_t_10 == ((Py_ssize_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2635, __pyx_L1_error)
    __pyx_v_strideC = __pyx_t_10;

    /* "cupy/core/core.pyx":2636
 *         strideB = _get_stride_for_strided_batched_gemm(b)
 *         strideC = _get_stride_for_strided_batched_gemm(out_view)
 *         if dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *             cublas.sgemmStridedBatched(
 *                 handle,
 */
    __pyx_t_25 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2636, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_n_s_float32); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2636, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    __pyx_t_25 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_13, Py_EQ); __Pyx_XGOTREF(__pyx_t_25); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2636, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_25); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2636, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2638
 *         if dtype == numpy.float32:
 *             cublas.sgemmStridedBatched(
 *                 handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_26 = PyInt_AsSsize_t(__pyx_v_handle); if (unlikely((__pyx_t_26 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2638, __pyx_L1_error)

      /* "cupy/core/core.pyx":2637
 *         strideC = _get_stride_for_strided_batched_gemm(out_view)
 *         if dtype == numpy.float32:
 *             cublas.sgemmStridedBatched(             # <<<<<<<<<<<<<<
 *                 handle,
 *                 0,  # transa
 */
      __pyx_t_25 = __pyx_f_4cupy_4cuda_6cublas_sgemmStridedBatched(__pyx_t_26, 0, 0, __pyx_v_n, __pyx_v_m, __pyx_v_ka, 1.0, __pyx_v_a->data->ptr, __pyx_v_lda, __pyx_v_strideA, __pyx_v_b->data->ptr, __pyx_v_ldb, __pyx_v_strideB, 0.0, __pyx_v_out_view->data->ptr, __pyx_v_ldout, __pyx_v_strideC, __pyx_v_batchCount, 0); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2637, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

      /* "cupy/core/core.pyx":2636
 *         strideB = _get_stride_for_strided_batched_gemm(b)
 *         strideC = _get_stride_for_strided_batched_gemm(out_view)
 *         if dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *             cublas.sgemmStridedBatched(
 *                 handle,
 */
      goto __pyx_L52;
    }

    /* "cupy/core/core.pyx":2646
 *                 0.0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 *         elif dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *             cublas.dgemmStridedBatched(
 *                 handle,
 */
    __pyx_t_25 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2646, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_n_s_float64); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2646, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    __pyx_t_25 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_13, Py_EQ); __Pyx_XGOTREF(__pyx_t_25); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2646, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_25); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2646, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2648
 *         elif dtype == numpy.float64:
 *             cublas.dgemmStridedBatched(
 *                 handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_26 = PyInt_AsSsize_t(__pyx_v_handle); if (unlikely((__pyx_t_26 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2648, __pyx_L1_error)

      /* "cupy/core/core.pyx":2647
 *                 batchCount)
 *         elif dtype == numpy.float64:
 *             cublas.dgemmStridedBatched(             # <<<<<<<<<<<<<<
 *                 handle,
 *                 0,  # transa
 */
      __pyx_t_25 = __pyx_f_4cupy_4cuda_6cublas_dgemmStridedBatched(__pyx_t_26, 0, 0, __pyx_v_n, __pyx_v_m, __pyx_v_ka, 1.0, __pyx_v_a->data->ptr, __pyx_v_lda, __pyx_v_strideA, __pyx_v_b->data->ptr, __pyx_v_ldb, __pyx_v_strideB, 0.0, __pyx_v_out_view->data->ptr, __pyx_v_ldout, __pyx_v_strideC, __pyx_v_batchCount, 0); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2647, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

      /* "cupy/core/core.pyx":2646
 *                 0.0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 *         elif dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *             cublas.dgemmStridedBatched(
 *                 handle,
 */
      goto __pyx_L52;
    }

    /* "cupy/core/core.pyx":2656
 *                 0.0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 *         elif dtype == numpy.complex64:             # <<<<<<<<<<<<<<
 *             cublas.cgemmStridedBatched(
 *                 handle,
 */
    __pyx_t_25 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2656, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_n_s_complex64); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2656, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    __pyx_t_25 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_13, Py_EQ); __Pyx_XGOTREF(__pyx_t_25); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2656, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_25); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2656, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2658
 *         elif dtype == numpy.complex64:
 *             cublas.cgemmStridedBatched(
 *                 handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_26 = PyInt_AsSsize_t(__pyx_v_handle); if (unlikely((__pyx_t_26 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2658, __pyx_L1_error)

      /* "cupy/core/core.pyx":2657
 *                 batchCount)
 *         elif dtype == numpy.complex64:
 *             cublas.cgemmStridedBatched(             # <<<<<<<<<<<<<<
 *                 handle,
 *                 0,  # transa
 */
      __pyx_t_25 = __pyx_f_4cupy_4cuda_6cublas_cgemmStridedBatched(__pyx_t_26, 0, 0, __pyx_v_n, __pyx_v_m, __pyx_v_ka, __pyx_t_float_complex_from_parts(1, 0), __pyx_v_a->data->ptr, __pyx_v_lda, __pyx_v_strideA, __pyx_v_b->data->ptr, __pyx_v_ldb, __pyx_v_strideB, __pyx_t_float_complex_from_parts(0, 0), __pyx_v_out_view->data->ptr, __pyx_v_ldout, __pyx_v_strideC, __pyx_v_batchCount, 0); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2657, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

      /* "cupy/core/core.pyx":2656
 *                 0.0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 *         elif dtype == numpy.complex64:             # <<<<<<<<<<<<<<
 *             cublas.cgemmStridedBatched(
 *                 handle,
 */
      goto __pyx_L52;
    }

    /* "cupy/core/core.pyx":2666
 *                 0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 *         elif dtype == numpy.complex128:             # <<<<<<<<<<<<<<
 *             cublas.zgemmStridedBatched(
 *                 handle,
 */
    __pyx_t_25 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2666, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_n_s_complex128); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2666, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    __pyx_t_25 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_13, Py_EQ); __Pyx_XGOTREF(__pyx_t_25); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2666, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_25); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2666, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    if (likely(__pyx_t_2)) {

      /* "cupy/core/core.pyx":2668
 *         elif dtype == numpy.complex128:
 *             cublas.zgemmStridedBatched(
 *                 handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_26 = PyInt_AsSsize_t(__pyx_v_handle); if (unlikely((__pyx_t_26 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2668, __pyx_L1_error)

      /* "cupy/core/core.pyx":2667
 *                 batchCount)
 *         elif dtype == numpy.complex128:
 *             cublas.zgemmStridedBatched(             # <<<<<<<<<<<<<<
 *                 handle,
 *                 0,  # transa
 */
      __pyx_t_25 = __pyx_f_4cupy_4cuda_6cublas_zgemmStridedBatched(__pyx_t_26, 0, 0, __pyx_v_n, __pyx_v_m, __pyx_v_ka, __pyx_t_double_complex_from_parts(1, 0), __pyx_v_a->data->ptr, __pyx_v_lda, __pyx_v_strideA, __pyx_v_b->data->ptr, __pyx_v_ldb, __pyx_v_strideB, __pyx_t_double_complex_from_parts(0, 0), __pyx_v_out_view->data->ptr, __pyx_v_ldout, __pyx_v_strideC, __pyx_v_batchCount, 0); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2667, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

      /* "cupy/core/core.pyx":2666
 *                 0, out_view.data.ptr, ldout, strideC,
 *                 batchCount)
 *         elif dtype == numpy.complex128:             # <<<<<<<<<<<<<<
 *             cublas.zgemmStridedBatched(
 *                 handle,
 */
      goto __pyx_L52;
    }

    /* "cupy/core/core.pyx":2677
 *                 batchCount)
 *         else:
 *             raise TypeError(dtype, a.dtype, b.dtype)             # <<<<<<<<<<<<<<
 *     else:
 *         ap = _mat_ptrs(a)
 */
    /*else*/ {
      __pyx_t_25 = PyTuple_New(3); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2677, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_25, 0, __pyx_v_dtype);
      __Pyx_INCREF(__pyx_v_a->dtype);
      __Pyx_GIVEREF(__pyx_v_a->dtype);
      PyTuple_SET_ITEM(__pyx_t_25, 1, __pyx_v_a->dtype);
      __Pyx_INCREF(__pyx_v_b->dtype);
      __Pyx_GIVEREF(__pyx_v_b->dtype);
      PyTuple_SET_ITEM(__pyx_t_25, 2, __pyx_v_b->dtype);
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_25, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2677, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
      __Pyx_Raise(__pyx_t_13, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __PYX_ERR(0, 2677, __pyx_L1_error)
    }
    __pyx_L52:;

    /* "cupy/core/core.pyx":2632
 * 
 *     # TODO(anaruse) use cublasGemmStridedBatchedEx() when cuda version >= 9.1
 *     if not use_broadcast:             # <<<<<<<<<<<<<<
 *         strideA = _get_stride_for_strided_batched_gemm(a)
 *         strideB = _get_stride_for_strided_batched_gemm(b)
 */
    goto __pyx_L51;
  }

  /* "cupy/core/core.pyx":2679
 *             raise TypeError(dtype, a.dtype, b.dtype)
 *     else:
 *         ap = _mat_ptrs(a)             # <<<<<<<<<<<<<<
 *         bp = _mat_ptrs(b)
 *         outp = _mat_ptrs(out_view)
 */
  /*else*/ {
    __pyx_t_13 = ((PyObject *)__pyx_f_4cupy_4core_4core__mat_ptrs(__pyx_v_a)); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2679, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_v_ap = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_13);
    __pyx_t_13 = 0;

    /* "cupy/core/core.pyx":2680
 *     else:
 *         ap = _mat_ptrs(a)
 *         bp = _mat_ptrs(b)             # <<<<<<<<<<<<<<
 *         outp = _mat_ptrs(out_view)
 *         if dtype == numpy.float32:
 */
    __pyx_t_13 = ((PyObject *)__pyx_f_4cupy_4core_4core__mat_ptrs(__pyx_v_b)); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2680, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_v_bp = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_13);
    __pyx_t_13 = 0;

    /* "cupy/core/core.pyx":2681
 *         ap = _mat_ptrs(a)
 *         bp = _mat_ptrs(b)
 *         outp = _mat_ptrs(out_view)             # <<<<<<<<<<<<<<
 *         if dtype == numpy.float32:
 *             cublas.sgemmBatched(
 */
    __pyx_t_13 = ((PyObject *)__pyx_f_4cupy_4core_4core__mat_ptrs(__pyx_v_out_view)); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2681, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_v_outp = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_13);
    __pyx_t_13 = 0;

    /* "cupy/core/core.pyx":2682
 *         bp = _mat_ptrs(b)
 *         outp = _mat_ptrs(out_view)
 *         if dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *             cublas.sgemmBatched(
 *                 handle,
 */
    __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_float32); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_25, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2682, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2682, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2684
 *         if dtype == numpy.float32:
 *             cublas.sgemmBatched(
 *                 handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_26 = PyInt_AsSsize_t(__pyx_v_handle); if (unlikely((__pyx_t_26 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2684, __pyx_L1_error)

      /* "cupy/core/core.pyx":2683
 *         outp = _mat_ptrs(out_view)
 *         if dtype == numpy.float32:
 *             cublas.sgemmBatched(             # <<<<<<<<<<<<<<
 *                 handle,
 *                 0,  # transa
 */
      __pyx_t_13 = __pyx_f_4cupy_4cuda_6cublas_sgemmBatched(__pyx_t_26, 0, 0, __pyx_v_n, __pyx_v_m, __pyx_v_ka, 1.0, __pyx_v_ap->data->ptr, __pyx_v_lda, __pyx_v_bp->data->ptr, __pyx_v_ldb, 0.0, __pyx_v_outp->data->ptr, __pyx_v_ldout, __pyx_v_batchCount, 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2683, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "cupy/core/core.pyx":2682
 *         bp = _mat_ptrs(b)
 *         outp = _mat_ptrs(out_view)
 *         if dtype == numpy.float32:             # <<<<<<<<<<<<<<
 *             cublas.sgemmBatched(
 *                 handle,
 */
      goto __pyx_L53;
    }

    /* "cupy/core/core.pyx":2691
 *                 bp.data.ptr, ldb,
 *                 0.0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *             cublas.dgemmBatched(
 *                 handle,
 */
    __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2691, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_float64); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2691, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_25, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2691, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2691, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2693
 *         elif dtype == numpy.float64:
 *             cublas.dgemmBatched(
 *                 handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_26 = PyInt_AsSsize_t(__pyx_v_handle); if (unlikely((__pyx_t_26 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2693, __pyx_L1_error)

      /* "cupy/core/core.pyx":2692
 *                 0.0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.float64:
 *             cublas.dgemmBatched(             # <<<<<<<<<<<<<<
 *                 handle,
 *                 0,  # transa
 */
      __pyx_t_13 = __pyx_f_4cupy_4cuda_6cublas_dgemmBatched(__pyx_t_26, 0, 0, __pyx_v_n, __pyx_v_m, __pyx_v_ka, 1.0, __pyx_v_ap->data->ptr, __pyx_v_lda, __pyx_v_bp->data->ptr, __pyx_v_ldb, 0.0, __pyx_v_outp->data->ptr, __pyx_v_ldout, __pyx_v_batchCount, 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2692, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "cupy/core/core.pyx":2691
 *                 bp.data.ptr, ldb,
 *                 0.0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.float64:             # <<<<<<<<<<<<<<
 *             cublas.dgemmBatched(
 *                 handle,
 */
      goto __pyx_L53;
    }

    /* "cupy/core/core.pyx":2700
 *                 bp.data.ptr, ldb,
 *                 0.0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.complex64:             # <<<<<<<<<<<<<<
 *             cublas.cgemmBatched(
 *                 handle,
 */
    __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2700, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_complex64); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2700, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_25, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2700, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2700, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":2702
 *         elif dtype == numpy.complex64:
 *             cublas.cgemmBatched(
 *                 handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_26 = PyInt_AsSsize_t(__pyx_v_handle); if (unlikely((__pyx_t_26 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2702, __pyx_L1_error)

      /* "cupy/core/core.pyx":2701
 *                 0.0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.complex64:
 *             cublas.cgemmBatched(             # <<<<<<<<<<<<<<
 *                 handle,
 *                 0,  # transa
 */
      __pyx_t_13 = __pyx_f_4cupy_4cuda_6cublas_cgemmBatched(__pyx_t_26, 0, 0, __pyx_v_n, __pyx_v_m, __pyx_v_ka, __pyx_t_float_complex_from_parts(1, 0), __pyx_v_ap->data->ptr, __pyx_v_lda, __pyx_v_bp->data->ptr, __pyx_v_ldb, __pyx_t_float_complex_from_parts(0, 0), __pyx_v_outp->data->ptr, __pyx_v_ldout, __pyx_v_batchCount, 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2701, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "cupy/core/core.pyx":2700
 *                 bp.data.ptr, ldb,
 *                 0.0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.complex64:             # <<<<<<<<<<<<<<
 *             cublas.cgemmBatched(
 *                 handle,
 */
      goto __pyx_L53;
    }

    /* "cupy/core/core.pyx":2709
 *                 bp.data.ptr, ldb,
 *                 0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.complex128:             # <<<<<<<<<<<<<<
 *             cublas.zgemmBatched(
 *                 handle,
 */
    __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_complex128); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_25, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2709, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2709, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    if (likely(__pyx_t_2)) {

      /* "cupy/core/core.pyx":2711
 *         elif dtype == numpy.complex128:
 *             cublas.zgemmBatched(
 *                 handle,             # <<<<<<<<<<<<<<
 *                 0,  # transa
 *                 0,  # transb
 */
      __pyx_t_26 = PyInt_AsSsize_t(__pyx_v_handle); if (unlikely((__pyx_t_26 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2711, __pyx_L1_error)

      /* "cupy/core/core.pyx":2710
 *                 0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.complex128:
 *             cublas.zgemmBatched(             # <<<<<<<<<<<<<<
 *                 handle,
 *                 0,  # transa
 */
      __pyx_t_13 = __pyx_f_4cupy_4cuda_6cublas_zgemmBatched(__pyx_t_26, 0, 0, __pyx_v_n, __pyx_v_m, __pyx_v_ka, __pyx_t_double_complex_from_parts(1, 0), __pyx_v_ap->data->ptr, __pyx_v_lda, __pyx_v_bp->data->ptr, __pyx_v_ldb, __pyx_t_double_complex_from_parts(0, 0), __pyx_v_outp->data->ptr, __pyx_v_ldout, __pyx_v_batchCount, 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2710, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "cupy/core/core.pyx":2709
 *                 bp.data.ptr, ldb,
 *                 0, outp.data.ptr, ldout, batchCount)
 *         elif dtype == numpy.complex128:             # <<<<<<<<<<<<<<
 *             cublas.zgemmBatched(
 *                 handle,
 */
      goto __pyx_L53;
    }

    /* "cupy/core/core.pyx":2719
 *                 0, outp.data.ptr, ldout, batchCount)
 *         else:
 *             raise TypeError(dtype, a.dtype, b.dtype)             # <<<<<<<<<<<<<<
 * 
 *     if dtype == ret_dtype:
 */
    /*else*/ {
      __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2719, __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_25 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_13, NULL); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2719, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_25);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_Raise(__pyx_t_25, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
      __PYX_ERR(0, 2719, __pyx_L1_error)
    }
    __pyx_L53:;
  }
  __pyx_L51:;

  /* "cupy/core/core.pyx":2721
 *             raise TypeError(dtype, a.dtype, b.dtype)
 * 
 *     if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *         return out
 *     else:
 */
  __pyx_t_25 = PyObject_RichCompare(__pyx_v_dtype, __pyx_v_ret_dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_25); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2721, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_25); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":2722
 * 
 *     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":2721
 *             raise TypeError(dtype, a.dtype, b.dtype)
 * 
 *     if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *         return out
 *     else:
 */
  }

  /* "cupy/core/core.pyx":2724
 *         return out
 *     else:
 *         ret = ndarray(out_shape, ret_dtype)             # <<<<<<<<<<<<<<
 *         elementwise_copy(out, ret)
 *         return ret
 */
  /*else*/ {
    __pyx_t_25 = PyTuple_New(2); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __Pyx_INCREF(__pyx_v_out_shape);
    __Pyx_GIVEREF(__pyx_v_out_shape);
    PyTuple_SET_ITEM(__pyx_t_25, 0, __pyx_v_out_shape);
    __Pyx_INCREF(__pyx_v_ret_dtype);
    __Pyx_GIVEREF(__pyx_v_ret_dtype);
    PyTuple_SET_ITEM(__pyx_t_25, 1, __pyx_v_ret_dtype);
    __pyx_t_13 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_25, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_13);
    __pyx_t_13 = 0;

    /* "cupy/core/core.pyx":2725
 *     else:
 *         ret = ndarray(out_shape, ret_dtype)
 *         elementwise_copy(out, ret)             # <<<<<<<<<<<<<<
 *         return ret
 * 
 */
    __pyx_t_25 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 2725, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __pyx_t_8 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_25))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_25);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_25);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_25, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_25)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
      __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_25, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2725, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_13);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_25)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
      __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_25, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2725, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_13);
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2725, __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_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_13 = __Pyx_PyObject_Call(__pyx_t_25, __pyx_t_11, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2725, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

    /* "cupy/core/core.pyx":2726
 *         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":2480
 * 
 * 
 * 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_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_25);
  __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((PyObject *)__pyx_v_out_view);
  __Pyx_XDECREF((PyObject *)__pyx_v_orig_a);
  __Pyx_XDECREF((PyObject *)__pyx_v_orig_b);
  __Pyx_XDECREF(__pyx_v_ret_dtype);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_handle);
  __Pyx_XDECREF((PyObject *)__pyx_v_ret);
  __Pyx_XDECREF(__pyx_8genexpr6__pyx_v__);
  __Pyx_XDECREF(__pyx_8genexpr7__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_25matmul(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_24matmul[] = "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_25matmul(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, 2480, __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, 2480, __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, 2480, __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, 2480, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(0, 2480, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 2480, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_24matmul(__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_24matmul(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, 2480, __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":2736
 * 
 * 
 * cpdef ndarray tensordot_core(             # <<<<<<<<<<<<<<
 *         ndarray a, ndarray b, ndarray out, Py_ssize_t n, Py_ssize_t m,
 *         Py_ssize_t k, const vector.vector[Py_ssize_t]& ret_shape):
 */

static PyObject *__pyx_pw_4cupy_4core_4core_27tensordot_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>  const &__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;
  int __pyx_v_use_sgemmEx;
  float __pyx_v_one_fp32;
  float __pyx_v_zero_fp32;
  PyObject *__pyx_v_ret_dtype = NULL;
  PyObject *__pyx_v_use_tensor_core = NULL;
  PyObject *__pyx_v_dtype = 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;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  std::vector<Py_ssize_t>  __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  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":2744
 *     cdef bint use_sgemmEx
 *     cdef float one_fp32, zero_fp32
 *     ret_dtype = a.dtype.char             # <<<<<<<<<<<<<<
 *     if ret_dtype != b.dtype.char:
 *         ret_dtype = numpy.promote_types(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, 2744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret_dtype = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2745
 *     cdef float one_fp32, zero_fp32
 *     ret_dtype = a.dtype.char
 *     if ret_dtype != b.dtype.char:             # <<<<<<<<<<<<<<
 *         ret_dtype = numpy.promote_types(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, 2745, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_ret_dtype, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2745, __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, 2745, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2746
 *     ret_dtype = a.dtype.char
 *     if ret_dtype != b.dtype.char:
 *         ret_dtype = numpy.promote_types(ret_dtype, b.dtype).char             # <<<<<<<<<<<<<<
 * 
 *     if not a.size or not b.size:
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_promote_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    __pyx_t_5 = 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_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_ret_dtype, __pyx_v_b->dtype};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2746, __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[3] = {__pyx_t_1, __pyx_v_ret_dtype, __pyx_v_b->dtype};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2746, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 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, 2746, __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_INCREF(__pyx_v_ret_dtype);
      __Pyx_GIVEREF(__pyx_v_ret_dtype);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_ret_dtype);
      __Pyx_INCREF(__pyx_v_b->dtype);
      __Pyx_GIVEREF(__pyx_v_b->dtype);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_b->dtype);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2746, __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_char); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_ret_dtype, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2745
 *     cdef float one_fp32, zero_fp32
 *     ret_dtype = a.dtype.char
 *     if ret_dtype != b.dtype.char:             # <<<<<<<<<<<<<<
 *         ret_dtype = numpy.promote_types(ret_dtype, b.dtype).char
 * 
 */
  }

  /* "cupy/core/core.pyx":2748
 *         ret_dtype = numpy.promote_types(ret_dtype, b.dtype).char
 * 
 *     if not a.size or not b.size:             # <<<<<<<<<<<<<<
 *         if out is None:
 *             out = _ndarray_init(ret_shape, ret_dtype)
 */
  __pyx_t_7 = ((!(__pyx_v_a->size != 0)) != 0);
  if (!__pyx_t_7) {
  } else {
    __pyx_t_3 = __pyx_t_7;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_7 = ((!(__pyx_v_b->size != 0)) != 0);
  __pyx_t_3 = __pyx_t_7;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":2749
 * 
 *     if not a.size or not b.size:
 *         if out is None:             # <<<<<<<<<<<<<<
 *             out = _ndarray_init(ret_shape, ret_dtype)
 *         out.fill(0)
 */
    __pyx_t_3 = (((PyObject *)__pyx_v_out) == Py_None);
    __pyx_t_7 = (__pyx_t_3 != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":2750
 *     if not a.size or not b.size:
 *         if out is None:
 *             out = _ndarray_init(ret_shape, ret_dtype)             # <<<<<<<<<<<<<<
 *         out.fill(0)
 *         return out
 */
      __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core__ndarray_init(__pyx_v_ret_shape, __pyx_v_ret_dtype)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2750, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":2749
 * 
 *     if not a.size or not b.size:
 *         if out is None:             # <<<<<<<<<<<<<<
 *             out = _ndarray_init(ret_shape, ret_dtype)
 *         out.fill(0)
 */
    }

    /* "cupy/core/core.pyx":2751
 *         if out is None:
 *             out = _ndarray_init(ret_shape, ret_dtype)
 *         out.fill(0)             # <<<<<<<<<<<<<<
 *         return out
 * 
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_out->__pyx_vtab)->fill(__pyx_v_out, __pyx_int_0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":2752
 *             out = _ndarray_init(ret_shape, 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":2748
 *         ret_dtype = numpy.promote_types(ret_dtype, b.dtype).char
 * 
 *     if not a.size or not b.size:             # <<<<<<<<<<<<<<
 *         if out is None:
 *             out = _ndarray_init(ret_shape, ret_dtype)
 */
  }

  /* "cupy/core/core.pyx":2755
 * 
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version < 0:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  __pyx_t_7 = ((__pyx_v_4cupy_4core_4core__cuda_runtime_version < 0) != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":2756
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version < 0:
 *         _cuda_runtime_version = runtime.runtimeGetVersion()             # <<<<<<<<<<<<<<
 * 
 *     use_sgemmEx = (a.dtype == 'e' and b.dtype == 'e' and
 */
    __pyx_t_5 = __pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion(0); if (unlikely(__pyx_t_5 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2756, __pyx_L1_error)
    __pyx_v_4cupy_4core_4core__cuda_runtime_version = __pyx_t_5;

    /* "cupy/core/core.pyx":2755
 * 
 *     global _cuda_runtime_version
 *     if _cuda_runtime_version < 0:             # <<<<<<<<<<<<<<
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 */
  }

  /* "cupy/core/core.pyx":2758
 *         _cuda_runtime_version = runtime.runtimeGetVersion()
 * 
 *     use_sgemmEx = (a.dtype == 'e' and b.dtype == 'e' and             # <<<<<<<<<<<<<<
 *                    (ret_dtype == 'e' or ret_dtype == 'f'))
 *     use_tensor_core = (use_sgemmEx and
 */
  __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_a->dtype, __pyx_n_u_e, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2758, __pyx_L1_error)
  if (__pyx_t_3) {
  } else {
    __pyx_t_7 = __pyx_t_3;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_b->dtype, __pyx_n_u_e, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2758, __pyx_L1_error)
  if (__pyx_t_3) {
  } else {
    __pyx_t_7 = __pyx_t_3;
    goto __pyx_L9_bool_binop_done;
  }

  /* "cupy/core/core.pyx":2759
 * 
 *     use_sgemmEx = (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_3 = (__Pyx_PyUnicode_Equals(__pyx_v_ret_dtype, __pyx_n_u_e, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2759, __pyx_L1_error)
  if (!__pyx_t_3) {
  } else {
    __pyx_t_7 = __pyx_t_3;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_ret_dtype, __pyx_n_u_f, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2759, __pyx_L1_error)
  __pyx_t_7 = __pyx_t_3;
  __pyx_L9_bool_binop_done:;
  __pyx_v_use_sgemmEx = __pyx_t_7;

  /* "cupy/core/core.pyx":2760
 *     use_sgemmEx = (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_2 = __Pyx_PyBool_FromLong(__pyx_v_use_sgemmEx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2760, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L13_bool_binop_done;
  }

  /* "cupy/core/core.pyx":2761
 *                    (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_7 = (__pyx_v_4cupy_4core_4core__cuda_runtime_version >= 0x2328);
  if (__pyx_t_7) {
  } else {
    __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2761, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L13_bool_binop_done;
  }

  /* "cupy/core/core.pyx":2762
 *     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_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_device); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_get_compute_capability); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_6) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2762, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2762, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2762, __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_int_70, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2762, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_4 = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_L13_bool_binop_done:;
  __pyx_v_use_tensor_core = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2764
 *                        int(device.get_compute_capability()) >= 70)
 * 
 *     if use_sgemmEx or ret_dtype in 'fdFD':             # <<<<<<<<<<<<<<
 *         dtype = ret_dtype
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_sgemmEx != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_7 = __pyx_t_3;
    goto __pyx_L17_bool_binop_done;
  }
  __pyx_t_3 = (__Pyx_PyUnicode_ContainsTF(__pyx_v_ret_dtype, __pyx_n_u_fdFD, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2764, __pyx_L1_error)
  __pyx_t_8 = (__pyx_t_3 != 0);
  __pyx_t_7 = __pyx_t_8;
  __pyx_L17_bool_binop_done:;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":2765
 * 
 *     if use_sgemmEx or ret_dtype in 'fdFD':
 *         dtype = ret_dtype             # <<<<<<<<<<<<<<
 *     else:
 *         dtype = numpy.promote_types(ret_dtype, 'f').char
 */
    __Pyx_INCREF(__pyx_v_ret_dtype);
    __pyx_v_dtype = __pyx_v_ret_dtype;

    /* "cupy/core/core.pyx":2764
 *                        int(device.get_compute_capability()) >= 70)
 * 
 *     if use_sgemmEx or ret_dtype in 'fdFD':             # <<<<<<<<<<<<<<
 *         dtype = ret_dtype
 *     else:
 */
    goto __pyx_L16;
  }

  /* "cupy/core/core.pyx":2767
 *         dtype = ret_dtype
 *     else:
 *         dtype = numpy.promote_types(ret_dtype, 'f').char             # <<<<<<<<<<<<<<
 * 
 *     if out is None:
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_promote_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __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_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_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_ret_dtype, __pyx_n_u_f};
      __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, 2767, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_ret_dtype, __pyx_n_u_f};
      __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, 2767, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2767, __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_ret_dtype);
      __Pyx_GIVEREF(__pyx_v_ret_dtype);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_ret_dtype);
      __Pyx_INCREF(__pyx_n_u_f);
      __Pyx_GIVEREF(__pyx_n_u_f);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_n_u_f);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2767, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_char); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_dtype = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_L16:;

  /* "cupy/core/core.pyx":2769
 *         dtype = numpy.promote_types(ret_dtype, 'f').char
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = _ndarray_init(ret_shape, dtype)
 *         if dtype == ret_dtype:
 */
  __pyx_t_7 = (((PyObject *)__pyx_v_out) == Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":2770
 * 
 *     if out is None:
 *         out = _ndarray_init(ret_shape, dtype)             # <<<<<<<<<<<<<<
 *         if dtype == ret_dtype:
 *             ret = out
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__ndarray_init(__pyx_v_ret_shape, __pyx_v_dtype)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2770, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2771
 *     if out is None:
 *         out = _ndarray_init(ret_shape, dtype)
 *         if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *             ret = out
 *         else:
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_dtype, __pyx_v_ret_dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2771, __pyx_L1_error)
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 2771, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":2772
 *         out = _ndarray_init(ret_shape, dtype)
 *         if dtype == ret_dtype:
 *             ret = out             # <<<<<<<<<<<<<<
 *         else:
 *             ret = _ndarray_init(ret_shape, ret_dtype)
 */
      __Pyx_INCREF(((PyObject *)__pyx_v_out));
      __pyx_v_ret = __pyx_v_out;

      /* "cupy/core/core.pyx":2771
 *     if out is None:
 *         out = _ndarray_init(ret_shape, dtype)
 *         if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *             ret = out
 *         else:
 */
      goto __pyx_L20;
    }

    /* "cupy/core/core.pyx":2774
 *             ret = out
 *         else:
 *             ret = _ndarray_init(ret_shape, ret_dtype)             # <<<<<<<<<<<<<<
 *     else:
 *         ret = out
 */
    /*else*/ {
      __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__ndarray_init(__pyx_v_ret_shape, __pyx_v_ret_dtype)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2774, __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;
    }
    __pyx_L20:;

    /* "cupy/core/core.pyx":2769
 *         dtype = numpy.promote_types(ret_dtype, 'f').char
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = _ndarray_init(ret_shape, dtype)
 *         if dtype == ret_dtype:
 */
    goto __pyx_L19;
  }

  /* "cupy/core/core.pyx":2776
 *             ret = _ndarray_init(ret_shape, ret_dtype)
 *     else:
 *         ret = out             # <<<<<<<<<<<<<<
 *         if out.dtype != dtype:
 *             out = _ndarray_init(ret_shape, dtype)
 */
  /*else*/ {
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __pyx_v_ret = __pyx_v_out;

    /* "cupy/core/core.pyx":2777
 *     else:
 *         ret = out
 *         if out.dtype != dtype:             # <<<<<<<<<<<<<<
 *             out = _ndarray_init(ret_shape, dtype)
 * 
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_out->dtype, __pyx_v_dtype, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2777, __pyx_L1_error)
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 2777, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":2778
 *         ret = out
 *         if out.dtype != dtype:
 *             out = _ndarray_init(ret_shape, dtype)             # <<<<<<<<<<<<<<
 * 
 *     if m == 1 and n == 1:
 */
      __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__ndarray_init(__pyx_v_ret_shape, __pyx_v_dtype)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2778, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":2777
 *     else:
 *         ret = out
 *         if out.dtype != dtype:             # <<<<<<<<<<<<<<
 *             out = _ndarray_init(ret_shape, dtype)
 * 
 */
    }
  }
  __pyx_L19:;

  /* "cupy/core/core.pyx":2780
 *             out = _ndarray_init(ret_shape, dtype)
 * 
 *     if m == 1 and n == 1:             # <<<<<<<<<<<<<<
 *         _tensordot_core_mul_sum(
 *             a.ravel(), b.ravel(), _manipulation._reshape(out, ()))
 */
  __pyx_t_7 = ((__pyx_v_m == 1) != 0);
  if (__pyx_t_7) {
  } else {
    __pyx_t_8 = __pyx_t_7;
    goto __pyx_L23_bool_binop_done;
  }
  __pyx_t_7 = ((__pyx_v_n == 1) != 0);
  __pyx_t_8 = __pyx_t_7;
  __pyx_L23_bool_binop_done:;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":2782
 *     if m == 1 and n == 1:
 *         _tensordot_core_mul_sum(
 *             a.ravel(), b.ravel(), _manipulation._reshape(out, ()))             # <<<<<<<<<<<<<<
 *         if out is not ret:
 *             elementwise_copy(out, ret)
 */
    __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->ravel(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->ravel(__pyx_v_b, 0, NULL)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_empty_tuple); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2782, __pyx_L1_error)
    __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__reshape(__pyx_v_out, __pyx_t_9, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__tensordot_core_mul_sum);
    __pyx_t_10 = __pyx_v_4cupy_4core_4core__tensordot_core_mul_sum; __pyx_t_11 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_t_4, __pyx_t_6, __pyx_t_2};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2781, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __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(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_t_4, __pyx_t_6, __pyx_t_2};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2781, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __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(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2781, __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_4);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_5, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_5, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_5, __pyx_t_2);
      __pyx_t_4 = 0;
      __pyx_t_6 = 0;
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2781, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":2783
 *         _tensordot_core_mul_sum(
 *             a.ravel(), b.ravel(), _manipulation._reshape(out, ()))
 *         if out is not ret:             # <<<<<<<<<<<<<<
 *             elementwise_copy(out, ret)
 *         return ret
 */
    __pyx_t_8 = (__pyx_v_out != __pyx_v_ret);
    __pyx_t_7 = (__pyx_t_8 != 0);
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":2784
 *             a.ravel(), b.ravel(), _manipulation._reshape(out, ()))
 *         if out is not ret:
 *             elementwise_copy(out, ret)             # <<<<<<<<<<<<<<
 *         return ret
 * 
 */
      __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2784, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_12 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2784, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2784, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_2 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2784, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (__pyx_t_12) {
          __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_12); __pyx_t_12 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_out));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
        PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_5, ((PyObject *)__pyx_v_out));
        __Pyx_INCREF(((PyObject *)__pyx_v_ret));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
        PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_5, ((PyObject *)__pyx_v_ret));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2784, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/core/core.pyx":2783
 *         _tensordot_core_mul_sum(
 *             a.ravel(), b.ravel(), _manipulation._reshape(out, ()))
 *         if out is not ret:             # <<<<<<<<<<<<<<
 *             elementwise_copy(out, ret)
 *         return ret
 */
    }

    /* "cupy/core/core.pyx":2785
 *         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":2780
 *             out = _ndarray_init(ret_shape, dtype)
 * 
 *     if m == 1 and n == 1:             # <<<<<<<<<<<<<<
 *         _tensordot_core_mul_sum(
 *             a.ravel(), b.ravel(), _manipulation._reshape(out, ()))
 */
  }

  /* "cupy/core/core.pyx":2788
 * 
 *     # 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_8 = ((__pyx_v_a->_shape.size() != 2) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_7 = __pyx_t_8;
    goto __pyx_L27_bool_binop_done;
  }
  __pyx_t_8 = (((__pyx_v_a->_shape[0]) != __pyx_v_k) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_7 = __pyx_t_8;
    goto __pyx_L27_bool_binop_done;
  }
  __pyx_t_8 = (((__pyx_v_a->_shape[1]) != __pyx_v_n) != 0);
  __pyx_t_7 = __pyx_t_8;
  __pyx_L27_bool_binop_done:;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":2789
 *     # 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":2790
 *     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 = _manipulation._reshape(a, shape)
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_k);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2790, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2791
 *         shape.clear()
 *         shape.push_back(k)
 *         shape.push_back(n)             # <<<<<<<<<<<<<<
 *         a = _manipulation._reshape(a, 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, 2791, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2792
 *         shape.push_back(k)
 *         shape.push_back(n)
 *         a = _manipulation._reshape(a, shape)             # <<<<<<<<<<<<<<
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:
 *         shape.clear()
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__reshape(__pyx_v_a, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2792, __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":2788
 * 
 *     # 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":2793
 *         shape.push_back(n)
 *         a = _manipulation._reshape(a, shape)
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(k)
 */
  __pyx_t_8 = ((__pyx_v_b->_shape.size() != 2) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_7 = __pyx_t_8;
    goto __pyx_L31_bool_binop_done;
  }
  __pyx_t_8 = (((__pyx_v_b->_shape[0]) != __pyx_v_k) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_7 = __pyx_t_8;
    goto __pyx_L31_bool_binop_done;
  }
  __pyx_t_8 = (((__pyx_v_b->_shape[1]) != __pyx_v_m) != 0);
  __pyx_t_7 = __pyx_t_8;
  __pyx_L31_bool_binop_done:;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":2794
 *         a = _manipulation._reshape(a, 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":2795
 *     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 = _manipulation._reshape(b, shape)
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_k);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2795, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2796
 *         shape.clear()
 *         shape.push_back(k)
 *         shape.push_back(m)             # <<<<<<<<<<<<<<
 *         b = _manipulation._reshape(b, shape)
 *     c = out
 */
    try {
      __pyx_v_shape.push_back(__pyx_v_m);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 2796, __pyx_L1_error)
    }

    /* "cupy/core/core.pyx":2797
 *         shape.push_back(k)
 *         shape.push_back(m)
 *         b = _manipulation._reshape(b, shape)             # <<<<<<<<<<<<<<
 *     c = out
 *     if c._shape.size() != 2 or c._shape[0] != n or c._shape[1] != m:
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__reshape(__pyx_v_b, __pyx_v_shape, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2797, __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":2793
 *         shape.push_back(n)
 *         a = _manipulation._reshape(a, 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":2798
 *         shape.push_back(m)
 *         b = _manipulation._reshape(b, 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":2799
 *         b = _manipulation._reshape(b, 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_8 = ((__pyx_v_c->_shape.size() != 2) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_7 = __pyx_t_8;
    goto __pyx_L35_bool_binop_done;
  }
  __pyx_t_8 = (((__pyx_v_c->_shape[0]) != __pyx_v_n) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_7 = __pyx_t_8;
    goto __pyx_L35_bool_binop_done;
  }
  __pyx_t_8 = (((__pyx_v_c->_shape[1]) != __pyx_v_m) != 0);
  __pyx_t_7 = __pyx_t_8;
  __pyx_L35_bool_binop_done:;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":2800
 *     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, 2800, __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":2801
 *     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, 2801, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2801, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2801, __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_10);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_10);
    __pyx_t_1 = 0;
    __pyx_t_10 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_c), __pyx_n_s_shape, __pyx_t_2) < 0) __PYX_ERR(0, 2801, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2799
 *         b = _manipulation._reshape(b, 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":2803
 *         c.shape = (n, m)
 * 
 *     if not use_sgemmEx:             # <<<<<<<<<<<<<<
 *         a = a.astype(dtype, copy=False)
 *         b = b.astype(dtype, copy=False)
 */
  __pyx_t_7 = ((!(__pyx_v_use_sgemmEx != 0)) != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":2804
 * 
 *     if not use_sgemmEx:
 *         a = a.astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 *         b = b.astype(dtype, copy=False)
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2804, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2804, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_dtype);
    __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2804, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 2804, __pyx_L1_error)
    __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, __pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2804, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2804, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12));
    __pyx_t_12 = 0;

    /* "cupy/core/core.pyx":2805
 *     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_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_astype); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2805, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2805, __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_10 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2805, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 2805, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_1, __pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2805, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2805, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2803
 *         c.shape = (n, m)
 * 
 *     if not use_sgemmEx:             # <<<<<<<<<<<<<<
 *         a = a.astype(dtype, copy=False)
 *         b = b.astype(dtype, copy=False)
 */
  }

  /* "cupy/core/core.pyx":2808
 * 
 *     # 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_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_device); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2808, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_get_cublas_handle); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2808, __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 && 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_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2808, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2808, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2808, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_handle = __pyx_t_13;

  /* "cupy/core/core.pyx":2812
 *     # 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_2 = __pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(__pyx_v_a, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2812, __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 != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2812, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_12 = PyTuple_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_t_12);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2812, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2812, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_12 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2812, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 2812, __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, 2812, __pyx_L1_error)
  __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_10); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2812, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_12); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2812, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;
  __pyx_v_transa = __pyx_t_13;
  __pyx_v_lda = __pyx_t_14;

  /* "cupy/core/core.pyx":2813
 *     # 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_2 = __pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(__pyx_v_b, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2813, __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 != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2813, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_12);
    __Pyx_INCREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_t_1);
    #else
    __pyx_t_12 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2813, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2813, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_1 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2813, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 2813, __pyx_L1_error)
  }
  if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 2813, __pyx_L1_error)
  __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_10); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2813, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2813, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_12));
  __pyx_t_12 = 0;
  __pyx_v_transb = __pyx_t_14;
  __pyx_v_ldb = __pyx_t_13;

  /* "cupy/core/core.pyx":2814
 *     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_7 = (__pyx_v_use_sgemmEx != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":2815
 *     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_7 = (__Pyx_PyUnicode_Equals(__pyx_v_c->dtype, __pyx_n_u_e, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2815, __pyx_L1_error)
    if (__pyx_t_7) {
      __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":2816
 *     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_7 = __Pyx_PyObject_IsTrue(__pyx_v_use_tensor_core); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2816, __pyx_L1_error)
    if (__pyx_t_7) {

      /* "cupy/core/core.pyx":2817
 *         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":2818
 *         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":2819
 *             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_2 = __pyx_f_4cupy_4cuda_6cublas_setMathMode(__pyx_v_handle, __pyx_e_4cupy_4cuda_6cublas_CUBLAS_TENSOR_OP_MATH, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2819, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":2820
 *             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_2 = __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_DEFAULT_TENSOR_OP, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2820, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":2828
 *                 c.data.ptr, Ctype, <int>m,
 *                 runtime.CUDA_R_32F, cublas.CUBLAS_GEMM_DEFAULT_TENSOR_OP)
 *             cublas.setMathMode(handle, cublas.CUBLAS_DEFAULT_MATH)             # <<<<<<<<<<<<<<
 *         else:
 *             cublas.sgemmEx(
 */
      __pyx_t_2 = __pyx_f_4cupy_4cuda_6cublas_setMathMode(__pyx_v_handle, __pyx_e_4cupy_4cuda_6cublas_CUBLAS_DEFAULT_MATH, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2828, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/core/core.pyx":2816
 *     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_L40;
    }

    /* "cupy/core/core.pyx":2830
 *             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":2833
 *                 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.sgemmEx(
 */
      __pyx_t_2 = __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_2)) __PYX_ERR(0, 2830, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __pyx_L40:;

    /* "cupy/core/core.pyx":2814
 *     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_L39;
  }

  /* "cupy/core/core.pyx":2834
 *                 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.sgemmEx(
 *             handle, <int>transb, <int> transa, <int>m, <int>n, <int>k, 1,
 */
  __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_dtype, __pyx_n_u_f, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2834, __pyx_L1_error)
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":2835
 *                 runtime.CUDA_R_16F, <int>lda, 0, c.data.ptr, Ctype, <int>m)
 *     elif dtype == 'f':
 *         cublas.sgemmEx(             # <<<<<<<<<<<<<<
 *             handle, <int>transb, <int> transa, <int>m, <int>n, <int>k, 1,
 *             b.data.ptr, runtime.CUDA_R_32F, <int>ldb,
 */
    __pyx_t_2 = __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_32F, ((int)__pyx_v_ldb), __pyx_v_a->data->ptr, __pyx_e_4cupy_4cuda_7runtime_CUDA_R_32F, ((int)__pyx_v_lda), 0.0, __pyx_v_c->data->ptr, __pyx_e_4cupy_4cuda_7runtime_CUDA_R_32F, ((int)__pyx_v_m), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2834
 *                 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.sgemmEx(
 *             handle, <int>transb, <int> transa, <int>m, <int>n, <int>k, 1,
 */
    goto __pyx_L39;
  }

  /* "cupy/core/core.pyx":2840
 *             a.data.ptr, runtime.CUDA_R_32F, <int>lda, 0,
 *             c.data.ptr, runtime.CUDA_R_32F, <int>m)
 *     elif dtype == 'd':             # <<<<<<<<<<<<<<
 *         cublas.dgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 */
  __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_dtype, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2840, __pyx_L1_error)
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":2841
 *             c.data.ptr, runtime.CUDA_R_32F, <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_2 = __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_2)) __PYX_ERR(0, 2841, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2840
 *             a.data.ptr, runtime.CUDA_R_32F, <int>lda, 0,
 *             c.data.ptr, runtime.CUDA_R_32F, <int>m)
 *     elif dtype == 'd':             # <<<<<<<<<<<<<<
 *         cublas.dgemm(
 *             handle, <int>transb, <int>transa, <int>m, <int>n, <int>k, 1,
 */
    goto __pyx_L39;
  }

  /* "cupy/core/core.pyx":2844
 *             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_7 = (__Pyx_PyUnicode_Equals(__pyx_v_dtype, __pyx_n_u_F, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2844, __pyx_L1_error)
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":2845
 *             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_2 = __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_2)) __PYX_ERR(0, 2845, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2844
 *             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_L39;
  }

  /* "cupy/core/core.pyx":2848
 *             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_7 = (__Pyx_PyUnicode_Equals(__pyx_v_dtype, __pyx_n_u_D, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2848, __pyx_L1_error)
  if (likely(__pyx_t_7)) {

    /* "cupy/core/core.pyx":2849
 *             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_2 = __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_2)) __PYX_ERR(0, 2849, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2848
 *             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_L39;
  }

  /* "cupy/core/core.pyx":2853
 *             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_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2853, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyUnicode_Format(__pyx_kp_u_Invalid_dtype_s, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2853, __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, 2853, __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, 2853, __pyx_L1_error)
  }
  __pyx_L39:;

  /* "cupy/core/core.pyx":2855
 *         raise ValueError('Invalid dtype: %s' % str(dtype))
 * 
 *     if out is not ret:             # <<<<<<<<<<<<<<
 *         elementwise_copy(out, ret)
 *     return ret
 */
  __pyx_t_7 = (__pyx_v_out != __pyx_v_ret);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":2856
 * 
 *     if out is not ret:
 *         elementwise_copy(out, ret)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = NULL;
    __pyx_t_5 = 0;
    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);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
      __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(0, 2856, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 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_10, ((PyObject *)__pyx_v_out), ((PyObject *)__pyx_v_ret)};
      __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(0, 2856, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2856, __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(((PyObject *)__pyx_v_out));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_5, ((PyObject *)__pyx_v_out));
      __Pyx_INCREF(((PyObject *)__pyx_v_ret));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_5, ((PyObject *)__pyx_v_ret));
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2856, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2855
 *         raise ValueError('Invalid dtype: %s' % str(dtype))
 * 
 *     if out is not ret:             # <<<<<<<<<<<<<<
 *         elementwise_copy(out, ret)
 *     return ret
 */
  }

  /* "cupy/core/core.pyx":2857
 *     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":2736
 * 
 * 
 * cpdef ndarray tensordot_core(             # <<<<<<<<<<<<<<
 *         ndarray a, ndarray b, ndarray out, Py_ssize_t n, Py_ssize_t m,
 *         Py_ssize_t k, const vector.vector[Py_ssize_t]& ret_shape):
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.core.core.tensordot_core", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ret_dtype);
  __Pyx_XDECREF(__pyx_v_use_tensor_core);
  __Pyx_XDECREF(__pyx_v_dtype);
  __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_27tensordot_core(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_26tensordot_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_27tensordot_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, 2736, __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, 2736, __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, 2736, __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, 2736, __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, 2736, __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, 2736, __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, 2736, __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, 2737, __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, 2737, __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, 2738, __pyx_L3_error)
    __pyx_v_ret_shape = __pyx_convert_vector_from_py_Py_ssize_t(values[6]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2738, __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, 2736, __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, 2737, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(0, 2737, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) __PYX_ERR(0, 2737, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_26tensordot_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_26tensordot_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, 2736, __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":2861
 * 
 * @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_29_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":2862
 * @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, 2862, __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, 2862, __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, 2862, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 2862, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/core/core.pyx":2863
 * 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":2865
 *     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, 2865, __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, 2865, __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, 2865, __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":2866
 *         # 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, 2866, __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, 2866, __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, 2866, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {

      /* "cupy/core/core.pyx":2867
 *         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, 2867, __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":2866
 *         # 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":2868
 *         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, 2868, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2868, __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":2863
 * 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":2869
 *             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":2870
 *         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, 2870, __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":2869
 *             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":2871
 *     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, 2871, __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, 2871, __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, 2871, __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, 2871, __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, 2871, __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":2861
 * 
 * @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_29_mat_to_cublas_contiguous(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_28_mat_to_cublas_contiguous[] = "_mat_to_cublas_contiguous(ndarray a, Py_ssize_t trans) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_29_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, 2861, __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, 2861, __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, 2861, __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, 2861, __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, 2861, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_28_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_28_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, 2861, __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":2875
 * 
 * @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_31_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":2876
 * @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":2877
 * 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, 2877, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2877, __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":2876
 * @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":2879
 *         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, 2879, __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, 2879, __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, 2879, __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, 2879, __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":2875
 * 
 * @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_31_to_cublas_vector(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_30_to_cublas_vector[] = "_to_cublas_vector(ndarray a, Py_ssize_t rundim) -> tuple";
static PyObject *__pyx_pw_4cupy_4core_4core_31_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, 2875, __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, 2875, __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, 2875, __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, 2875, __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, 2875, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4core_4core_30_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_30_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, 2875, __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":2885
 * # -----------------------------------------------------------------------------
 * 
 * cpdef create_comparison(name, op, doc='', no_complex_dtype=True):             # <<<<<<<<<<<<<<
 * 
 *     if no_complex_dtype:
 */

static PyObject *__pyx_pw_4cupy_4core_4core_33create_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_u__6);
  PyObject *__pyx_v_no_complex_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_no_complex_dtype = __pyx_optional_args->no_complex_dtype;
      }
    }
  }

  /* "cupy/core/core.pyx":2887
 * cpdef create_comparison(name, op, doc='', no_complex_dtype=True):
 * 
 *     if no_complex_dtype:             # <<<<<<<<<<<<<<
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_no_complex_dtype); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2887, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":2888
 * 
 *     if no_complex_dtype:
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',             # <<<<<<<<<<<<<<
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 *     else:
 */
    __Pyx_INCREF(__pyx_tuple__61);
    __pyx_v_ops = __pyx_tuple__61;

    /* "cupy/core/core.pyx":2887
 * cpdef create_comparison(name, op, doc='', no_complex_dtype=True):
 * 
 *     if no_complex_dtype:             # <<<<<<<<<<<<<<
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":2891
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 *     else:
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',             # <<<<<<<<<<<<<<
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?',
 *                'FF->?', 'DD->?')
 */
  /*else*/ {
    __Pyx_INCREF(__pyx_tuple__62);
    __pyx_v_ops = __pyx_tuple__62;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":2895
 *                'FF->?', '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, 2895, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/core.pyx":2896
 * 
 *     return create_ufunc(
 *         'cupy_' + name,             # <<<<<<<<<<<<<<
 *         ops,
 *         'out0 = in0 %s in1' % op,
 */
  __pyx_t_3 = PyNumber_Add(__pyx_n_u_cupy_2, __pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2896, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/core.pyx":2898
 *         'cupy_' + name,
 *         ops,
 *         'out0 = in0 %s in1' % op,             # <<<<<<<<<<<<<<
 *         doc=doc)
 * 
 */
  __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_out0_in0_s_in1, __pyx_v_op); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2898, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":2895
 *                'FF->?', 'DD->?')
 * 
 *     return create_ufunc(             # <<<<<<<<<<<<<<
 *         'cupy_' + name,
 *         ops,
 */
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2895, __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":2899
 *         ops,
 *         'out0 = in0 %s in1' % op,
 *         doc=doc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2899, __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, 2899, __pyx_L1_error)

  /* "cupy/core/core.pyx":2895
 *                'FF->?', '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, 2895, __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":2885
 * # -----------------------------------------------------------------------------
 * 
 * cpdef create_comparison(name, op, doc='', no_complex_dtype=True):             # <<<<<<<<<<<<<<
 * 
 *     if no_complex_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_33create_comparison(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_32create_comparison[] = "create_comparison(name, op, doc=u'', no_complex_dtype=True)";
static PyObject *__pyx_pw_4cupy_4core_4core_33create_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_no_complex_dtype = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_comparison (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name_2,&__pyx_n_s_op,&__pyx_n_s_doc,&__pyx_n_s_no_complex_dtype,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = ((PyObject *)__pyx_kp_u__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_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_op)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_comparison", 0, 2, 4, 1); __PYX_ERR(0, 2885, __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_no_complex_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, 2885, __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_no_complex_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, 2885, __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_32create_comparison(__pyx_self, __pyx_v_name, __pyx_v_op, __pyx_v_doc, __pyx_v_no_complex_dtype);

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

static PyObject *__pyx_pf_4cupy_4core_4core_32create_comparison(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_op, PyObject *__pyx_v_doc, PyObject *__pyx_v_no_complex_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.no_complex_dtype = __pyx_v_no_complex_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, 2885, __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":2962
 * 
 * 
 * cpdef ndarray _convert_object_with_cuda_array_interface(a):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t sh, st
 *     cdef object desc = a.__cuda_array_interface__
 */

static PyObject *__pyx_pw_4cupy_4core_4core_35_convert_object_with_cuda_array_interface(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__convert_object_with_cuda_array_interface(PyObject *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_sh;
  Py_ssize_t __pyx_v_st;
  PyObject *__pyx_v_desc = 0;
  PyObject *__pyx_v_shape = 0;
  int __pyx_v_dev_id;
  size_t __pyx_v_nbytes;
  PyObject *__pyx_v_ptr = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_mask = NULL;
  PyObject *__pyx_v_strides = NULL;
  PyObject *__pyx_v_mem = NULL;
  PyObject *__pyx_v_memptr = 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;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *(*__pyx_t_10)(PyObject *);
  Py_ssize_t __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  size_t __pyx_t_13;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  __Pyx_RefNannySetupContext("_convert_object_with_cuda_array_interface", 0);

  /* "cupy/core/core.pyx":2964
 * cpdef ndarray _convert_object_with_cuda_array_interface(a):
 *     cdef Py_ssize_t sh, st
 *     cdef object desc = a.__cuda_array_interface__             # <<<<<<<<<<<<<<
 *     cdef tuple shape = desc['shape']
 *     cdef int dev_id = -1
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_cuda_array_interface); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2964, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_desc = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2965
 *     cdef Py_ssize_t sh, st
 *     cdef object desc = a.__cuda_array_interface__
 *     cdef tuple shape = desc['shape']             # <<<<<<<<<<<<<<
 *     cdef int dev_id = -1
 *     cdef size_t nbytes
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_desc, __pyx_n_u_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2965, __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, 2965, __pyx_L1_error)
  __pyx_v_shape = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2966
 *     cdef object desc = a.__cuda_array_interface__
 *     cdef tuple shape = desc['shape']
 *     cdef int dev_id = -1             # <<<<<<<<<<<<<<
 *     cdef size_t nbytes
 * 
 */
  __pyx_v_dev_id = -1;

  /* "cupy/core/core.pyx":2969
 *     cdef size_t nbytes
 * 
 *     ptr = desc['data'][0]             # <<<<<<<<<<<<<<
 *     dtype = numpy.dtype(desc['typestr'])
 *     mask = desc.get('mask')
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_desc, __pyx_n_u_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2969, __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, 2969, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ptr = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2970
 * 
 *     ptr = desc['data'][0]
 *     dtype = numpy.dtype(desc['typestr'])             # <<<<<<<<<<<<<<
 *     mask = desc.get('mask')
 *     if mask is not None:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2970, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2970, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_desc, __pyx_n_u_typestr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2970, __pyx_L1_error)
  __Pyx_GOTREF(__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_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2970, __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_4, __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, 2970, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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_4, __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, 2970, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __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(0, 2970, __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_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2970, __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_v_dtype = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2971
 *     ptr = desc['data'][0]
 *     dtype = numpy.dtype(desc['typestr'])
 *     mask = desc.get('mask')             # <<<<<<<<<<<<<<
 *     if mask is not None:
 *         raise ValueError('CuPy currently does not support masked arrays.')
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_desc, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_mask = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2972
 *     dtype = numpy.dtype(desc['typestr'])
 *     mask = desc.get('mask')
 *     if mask is not None:             # <<<<<<<<<<<<<<
 *         raise ValueError('CuPy currently does not support masked arrays.')
 *     strides = desc.get('strides')
 */
  __pyx_t_6 = (__pyx_v_mask != Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (unlikely(__pyx_t_7)) {

    /* "cupy/core/core.pyx":2973
 *     mask = desc.get('mask')
 *     if mask is not None:
 *         raise ValueError('CuPy currently does not support masked arrays.')             # <<<<<<<<<<<<<<
 *     strides = desc.get('strides')
 *     if strides is not None:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2973, __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, 2973, __pyx_L1_error)

    /* "cupy/core/core.pyx":2972
 *     dtype = numpy.dtype(desc['typestr'])
 *     mask = desc.get('mask')
 *     if mask is not None:             # <<<<<<<<<<<<<<
 *         raise ValueError('CuPy currently does not support masked arrays.')
 *     strides = desc.get('strides')
 */
  }

  /* "cupy/core/core.pyx":2974
 *     if mask is not None:
 *         raise ValueError('CuPy currently does not support masked arrays.')
 *     strides = desc.get('strides')             # <<<<<<<<<<<<<<
 *     if strides is not None:
 *         nbytes = 0
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_desc, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2974, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2974, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_strides = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":2975
 *         raise ValueError('CuPy currently does not support masked arrays.')
 *     strides = desc.get('strides')
 *     if strides is not None:             # <<<<<<<<<<<<<<
 *         nbytes = 0
 *         for sh, st in zip(shape, strides):
 */
  __pyx_t_7 = (__pyx_v_strides != Py_None);
  __pyx_t_6 = (__pyx_t_7 != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2976
 *     strides = desc.get('strides')
 *     if strides is not None:
 *         nbytes = 0             # <<<<<<<<<<<<<<
 *         for sh, st in zip(shape, strides):
 *             nbytes = max(nbytes, abs(sh * st))
 */
    __pyx_v_nbytes = 0;

    /* "cupy/core/core.pyx":2977
 *     if strides is not None:
 *         nbytes = 0
 *         for sh, st in zip(shape, strides):             # <<<<<<<<<<<<<<
 *             nbytes = max(nbytes, abs(sh * st))
 *     else:
 */
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2977, __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_INCREF(__pyx_v_strides);
    __Pyx_GIVEREF(__pyx_v_strides);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_strides);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2977, __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_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2977, __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, 2977, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 2977, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2977, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_8 >= 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_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 2977, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2977, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_9(__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(0, 2977, __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, 2977, __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(0, 2977, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2977, __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_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2977, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_10(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_1 = __pyx_t_10(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_4), 2) < 0) __PYX_ERR(0, 2977, __pyx_L1_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L8_unpacking_done;
        __pyx_L7_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 2977, __pyx_L1_error)
        __pyx_L8_unpacking_done:;
      }
      __pyx_t_11 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_11 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2977, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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, 2977, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_sh = __pyx_t_11;
      __pyx_v_st = __pyx_t_12;

      /* "cupy/core/core.pyx":2978
 *         nbytes = 0
 *         for sh, st in zip(shape, strides):
 *             nbytes = max(nbytes, abs(sh * st))             # <<<<<<<<<<<<<<
 *     else:
 *         nbytes = internal.prod_sequence(shape) * dtype.itemsize
 */
      __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_sh * __pyx_v_st)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2978, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyNumber_Absolute(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2978, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_13 = __pyx_v_nbytes;
      __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2978, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_5, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 2978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1;
      } else {
        __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2978, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_3 = __pyx_t_4;
        __pyx_t_4 = 0;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_13 = __Pyx_PyInt_As_size_t(__pyx_t_3); if (unlikely((__pyx_t_13 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_nbytes = __pyx_t_13;

      /* "cupy/core/core.pyx":2977
 *     if strides is not None:
 *         nbytes = 0
 *         for sh, st in zip(shape, strides):             # <<<<<<<<<<<<<<
 *             nbytes = max(nbytes, abs(sh * st))
 *     else:
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/core.pyx":2975
 *         raise ValueError('CuPy currently does not support masked arrays.')
 *     strides = desc.get('strides')
 *     if strides is not None:             # <<<<<<<<<<<<<<
 *         nbytes = 0
 *         for sh, st in zip(shape, strides):
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":2980
 *             nbytes = max(nbytes, abs(sh * st))
 *     else:
 *         nbytes = internal.prod_sequence(shape) * dtype.itemsize             # <<<<<<<<<<<<<<
 *     # the v2 protocol sets ptr=0 for 0-size arrays, so we can't look up
 *     # the pointer attributes and must use the current device
 */
  /*else*/ {
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_f_4cupy_4core_8internal_prod_sequence(__pyx_v_shape, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2980, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2980, __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, 2980, __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_13 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_13 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2980, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_nbytes = __pyx_t_13;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":2983
 *     # the v2 protocol sets ptr=0 for 0-size arrays, so we can't look up
 *     # the pointer attributes and must use the current device
 *     if nbytes == 0:             # <<<<<<<<<<<<<<
 *         dev_id = device.get_device_id()
 *     mem = memory_module.UnownedMemory(ptr, nbytes, a, dev_id)
 */
  __pyx_t_6 = ((__pyx_v_nbytes == 0) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":2984
 *     # the pointer attributes and must use the current device
 *     if nbytes == 0:
 *         dev_id = device.get_device_id()             # <<<<<<<<<<<<<<
 *     mem = memory_module.UnownedMemory(ptr, nbytes, a, dev_id)
 *     memptr = memory.MemoryPointer(mem, 0)
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_device); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2984, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_device_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2984, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __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_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2984, __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, 2984, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2984, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_dev_id = __pyx_t_14;

    /* "cupy/core/core.pyx":2983
 *     # the v2 protocol sets ptr=0 for 0-size arrays, so we can't look up
 *     # the pointer attributes and must use the current device
 *     if nbytes == 0:             # <<<<<<<<<<<<<<
 *         dev_id = device.get_device_id()
 *     mem = memory_module.UnownedMemory(ptr, nbytes, a, dev_id)
 */
  }

  /* "cupy/core/core.pyx":2985
 *     if nbytes == 0:
 *         dev_id = device.get_device_id()
 *     mem = memory_module.UnownedMemory(ptr, nbytes, a, dev_id)             # <<<<<<<<<<<<<<
 *     memptr = memory.MemoryPointer(mem, 0)
 *     return ndarray(shape, dtype, memptr, strides)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_memory_module); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2985, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UnownedMemory); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2985, __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_nbytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2985, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_dev_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2985, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_14 = 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_14 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_v_ptr, __pyx_t_2, __pyx_v_a, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_14, 4+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2985, __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_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_v_ptr, __pyx_t_2, __pyx_v_a, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_14, 4+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2985, __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_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_15 = PyTuple_New(4+__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2985, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(__pyx_v_ptr);
    __Pyx_GIVEREF(__pyx_v_ptr);
    PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_14, __pyx_v_ptr);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_14, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_a);
    __Pyx_GIVEREF(__pyx_v_a);
    PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_14, __pyx_v_a);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_15, 3+__pyx_t_14, __pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2985, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_mem = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2986
 *         dev_id = device.get_device_id()
 *     mem = memory_module.UnownedMemory(ptr, nbytes, a, dev_id)
 *     memptr = memory.MemoryPointer(mem, 0)             # <<<<<<<<<<<<<<
 *     return ndarray(shape, dtype, memptr, strides)
 * 
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2986, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_mem);
  __Pyx_GIVEREF(__pyx_v_mem);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_mem);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_0);
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4cuda_6memory_MemoryPointer), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2986, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_memptr = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2987
 *     mem = memory_module.UnownedMemory(ptr, nbytes, a, dev_id)
 *     memptr = memory.MemoryPointer(mem, 0)
 *     return ndarray(shape, dtype, memptr, strides)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2987, __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_INCREF(__pyx_v_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_dtype);
  __Pyx_INCREF(__pyx_v_memptr);
  __Pyx_GIVEREF(__pyx_v_memptr);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_memptr);
  __Pyx_INCREF(__pyx_v_strides);
  __Pyx_GIVEREF(__pyx_v_strides);
  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_strides);
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2987, __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":2962
 * 
 * 
 * cpdef ndarray _convert_object_with_cuda_array_interface(a):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t sh, st
 *     cdef object desc = a.__cuda_array_interface__
 */

  /* 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_15);
  __Pyx_AddTraceback("cupy.core.core._convert_object_with_cuda_array_interface", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_desc);
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_ptr);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_mask);
  __Pyx_XDECREF(__pyx_v_strides);
  __Pyx_XDECREF(__pyx_v_mem);
  __Pyx_XDECREF(__pyx_v_memptr);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_35_convert_object_with_cuda_array_interface(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
static char __pyx_doc_4cupy_4core_4core_34_convert_object_with_cuda_array_interface[] = "_convert_object_with_cuda_array_interface(a) -> ndarray";
static PyObject *__pyx_pw_4cupy_4core_4core_35_convert_object_with_cuda_array_interface(PyObject *__pyx_self, PyObject *__pyx_v_a) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_convert_object_with_cuda_array_interface (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_34_convert_object_with_cuda_array_interface(__pyx_self, ((PyObject *)__pyx_v_a));

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

static PyObject *__pyx_pf_4cupy_4core_4core_34_convert_object_with_cuda_array_interface(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_convert_object_with_cuda_array_interface", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__convert_object_with_cuda_array_interface(__pyx_v_a, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2962, __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._convert_object_with_cuda_array_interface", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/core/core.pyx":2990
 * 
 * 
 * cdef ndarray _ndarray_init(const vector.vector[Py_ssize_t]& shape, dtype):             # <<<<<<<<<<<<<<
 *     cdef ndarray ret = ndarray.__new__(ndarray)
 *     ret._init_fast(shape, dtype, True)
 */

static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_4core_4core__ndarray_init(std::vector<Py_ssize_t>  const &__pyx_v_shape, PyObject *__pyx_v_dtype) {
  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;
  __Pyx_RefNannySetupContext("_ndarray_init", 0);

  /* "cupy/core/core.pyx":2991
 * 
 * cdef ndarray _ndarray_init(const vector.vector[Py_ssize_t]& shape, dtype):
 *     cdef ndarray ret = ndarray.__new__(ndarray)             # <<<<<<<<<<<<<<
 *     ret._init_fast(shape, dtype, True)
 *     return ret
 */
  __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, 2991, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2992
 * cdef ndarray _ndarray_init(const vector.vector[Py_ssize_t]& shape, dtype):
 *     cdef ndarray ret = ndarray.__new__(ndarray)
 *     ret._init_fast(shape, dtype, True)             # <<<<<<<<<<<<<<
 *     return ret
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ret->__pyx_vtab)->_init_fast(__pyx_v_ret, __pyx_v_shape, __pyx_v_dtype, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":2993
 *     cdef ndarray ret = ndarray.__new__(ndarray)
 *     ret._init_fast(shape, dtype, True)
 *     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":2990
 * 
 * 
 * cdef ndarray _ndarray_init(const vector.vector[Py_ssize_t]& shape, dtype):             # <<<<<<<<<<<<<<
 *     cdef ndarray ret = ndarray.__new__(ndarray)
 *     ret._init_fast(shape, dtype, True)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.core.core._ndarray_init", __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;
}

/* "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(2, 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(2, 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(2, 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(2, 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(2, 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(2, 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(2, 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(2, 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;
}

/* "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(2, 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(2, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(2, 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 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_177__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___cuda_array_interface__(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_24__cuda_array_interface___1__get__(o);
}

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_flat(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_4core_4core_7ndarray_4flat_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[] = {
  {"item", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_3item, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_2item},
  {"tolist", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_5tolist, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_4tolist},
  {"tobytes", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_7tobytes, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_6tobytes},
  {"tofile", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_9tofile, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_8tofile},
  {"dump", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_11dump, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_10dump},
  {"dumps", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_13dumps, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_12dumps},
  {"astype", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_15astype, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_14astype},
  {"copy", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_17copy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_16copy},
  {"view", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_19view, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_18view},
  {"fill", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_21fill, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_20fill},
  {"reshape", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_23reshape, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_22reshape},
  {"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_VARARGS|METH_KEYWORDS, __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},
  {"put", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_37put, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_36put},
  {"repeat", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_39repeat, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_38repeat},
  {"choose", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_41choose, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_40choose},
  {"sort", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_43sort, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_42sort},
  {"argsort", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_45argsort, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_44argsort},
  {"partition", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_47partition, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_46partition},
  {"argpartition", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_49argpartition, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_48argpartition},
  {"nonzero", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_51nonzero, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_50nonzero},
  {"compress", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_53compress, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_52compress},
  {"diagonal", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_55diagonal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_54diagonal},
  {"max", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_57max, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_56max},
  {"argmax", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_59argmax, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_58argmax},
  {"min", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_61min, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_60min},
  {"argmin", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_63argmin, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_62argmin},
  {"ptp", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_65ptp, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_64ptp},
  {"clip", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_67clip, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_66clip},
  {"round", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_69round, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_68round},
  {"trace", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_71trace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_70trace},
  {"sum", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_73sum, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_72sum},
  {"cumsum", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_75cumsum, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_74cumsum},
  {"mean", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_77mean, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_76mean},
  {"var", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_79var, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_78var},
  {"std", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_81std, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_80std},
  {"prod", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_83prod, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_82prod},
  {"cumprod", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_85cumprod, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_84cumprod},
  {"all", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_87all, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_86all},
  {"any", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_89any, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_88any},
  {"conj", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_159conj, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_158conj},
  {"conjugate", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_161conjugate, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_160conjugate},
  {"__copy__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_163__copy__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_162__copy__},
  {"__deepcopy__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_165__deepcopy__, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_164__deepcopy__},
  {"__reduce__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_167__reduce__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_166__reduce__},
  {"__array__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_169__array__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_168__array__},
  {"scatter_add", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_179scatter_add, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_178scatter_add},
  {"scatter_max", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_181scatter_max, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_180scatter_max},
  {"scatter_min", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_183scatter_min, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_182scatter_min},
  {"__array_ufunc__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_185__array_ufunc__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_184__array_ufunc__},
  {"__array_function__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_187__array_function__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_186__array_function__},
  {"__complex__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_193__complex__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_192__complex__},
  {"__bytes__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_199__bytes__, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_198__bytes__},
  {"dot", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_205dot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_204dot},
  {"get", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_207get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_206get},
  {"set", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_209set, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_208set},
  {"reduced_view", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_211reduced_view, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_210reduced_view},
  {"_update_c_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_213_update_c_contiguity, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_212_update_c_contiguity},
  {"_update_f_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_215_update_f_contiguity, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_214_update_f_contiguity},
  {"_update_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_217_update_contiguity, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_216_update_contiguity},
  {"_set_shape_and_strides", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_219_set_shape_and_strides, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_218_set_shape_and_strides},
  {"_set_contiguous_strides", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_221_set_contiguous_strides, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_220_set_contiguous_strides},
  {"toDlpack", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_223toDlpack, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_222toDlpack},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_4core_4core_ndarray[] = {
  {(char *)"__cuda_array_interface__", __pyx_getprop_4cupy_4core_4core_7ndarray___cuda_array_interface__, 0, (char *)0, 0},
  {(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 *)"Total size of all 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 *)"flat", __pyx_getprop_4cupy_4core_4core_7ndarray_flat, 0, (char *)0, 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_103__add__, /*nb_add*/
  __pyx_pw_4cupy_4core_4core_7ndarray_105__sub__, /*nb_subtract*/
  __pyx_pw_4cupy_4core_4core_7ndarray_107__mul__, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  __pyx_pw_4cupy_4core_4core_7ndarray_111__div__, /*nb_divide*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_117__mod__, /*nb_remainder*/
  __pyx_pw_4cupy_4core_4core_7ndarray_119__divmod__, /*nb_divmod*/
  __pyx_pw_4cupy_4core_4core_7ndarray_121__pow__, /*nb_power*/
  __pyx_pw_4cupy_4core_4core_7ndarray_95__neg__, /*nb_negative*/
  __pyx_pw_4cupy_4core_4core_7ndarray_97__pos__, /*nb_positive*/
  __pyx_pw_4cupy_4core_4core_7ndarray_99__abs__, /*nb_absolute*/
  __pyx_pw_4cupy_4core_4core_7ndarray_93__nonzero__, /*nb_nonzero*/
  __pyx_pw_4cupy_4core_4core_7ndarray_101__invert__, /*nb_invert*/
  __pyx_pw_4cupy_4core_4core_7ndarray_123__lshift__, /*nb_lshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_125__rshift__, /*nb_rshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_127__and__, /*nb_and*/
  __pyx_pw_4cupy_4core_4core_7ndarray_131__xor__, /*nb_xor*/
  __pyx_pw_4cupy_4core_4core_7ndarray_129__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_189__int__, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  __pyx_pw_4cupy_4core_4core_7ndarray_189__int__, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_191__float__, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  __pyx_pw_4cupy_4core_4core_7ndarray_195__oct__, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  __pyx_pw_4cupy_4core_4core_7ndarray_197__hex__, /*nb_hex*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_133__iadd__, /*nb_inplace_add*/
  __pyx_pw_4cupy_4core_4core_7ndarray_135__isub__, /*nb_inplace_subtract*/
  __pyx_pw_4cupy_4core_4core_7ndarray_137__imul__, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  __pyx_pw_4cupy_4core_4core_7ndarray_139__idiv__, /*nb_inplace_divide*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_145__imod__, /*nb_inplace_remainder*/
  __pyx_pw_4cupy_4core_4core_7ndarray_147__ipow__, /*nb_inplace_power*/
  __pyx_pw_4cupy_4core_4core_7ndarray_149__ilshift__, /*nb_inplace_lshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_151__irshift__, /*nb_inplace_rshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_153__iand__, /*nb_inplace_and*/
  __pyx_pw_4cupy_4core_4core_7ndarray_157__ixor__, /*nb_inplace_xor*/
  __pyx_pw_4cupy_4core_4core_7ndarray_155__ior__, /*nb_inplace_or*/
  __pyx_pw_4cupy_4core_4core_7ndarray_115__floordiv__, /*nb_floor_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_113__truediv__, /*nb_true_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_143__ifloordiv__, /*nb_inplace_floor_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_141__itruediv__, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  __pyx_pw_4cupy_4core_4core_7ndarray_109__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_173__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_173__len__, /*mp_length*/
  __pyx_pw_4cupy_4core_4core_7ndarray_175__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_201__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_203__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, strides=None, order=u'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        strides (tuple of ints or None): Strides of data in memory.\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    ", /*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_91__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_4cupy_4core_4core_7ndarray_171__iter__, /*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_obj_4cupy_4core_4core___pyx_scope_struct____iter__ *__pyx_freelist_4cupy_4core_4core___pyx_scope_struct____iter__[8];
static int __pyx_freecount_4cupy_4core_4core___pyx_scope_struct____iter__ = 0;

static PyObject *__pyx_tp_new_4cupy_4core_4core___pyx_scope_struct____iter__(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____iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__)))) {
    o = (PyObject*)__pyx_freelist_4cupy_4core_4core___pyx_scope_struct____iter__[--__pyx_freecount_4cupy_4core_4core___pyx_scope_struct____iter__];
    memset(o, 0, sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__));
    (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____iter__(PyObject *o) {
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__ *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4cupy_4core_4core___pyx_scope_struct____iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__)))) {
    __pyx_freelist_4cupy_4core_4core___pyx_scope_struct____iter__[__pyx_freecount_4cupy_4core_4core___pyx_scope_struct____iter__++] = ((struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4cupy_4core_4core___pyx_scope_struct____iter__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__ *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__ *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct____iter__(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__ *p = (struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__ *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4cupy_4core_4core___pyx_scope_struct____iter__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.core.core.__pyx_scope_struct____iter__", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_4core_4core___pyx_scope_struct____iter__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_4core_4core___pyx_scope_struct____iter__, /*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____iter__, /*tp_traverse*/
  __pyx_tp_clear_4cupy_4core_4core___pyx_scope_struct____iter__, /*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____iter__, /*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);
  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;
  }
  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 PyMethodDef __pyx_methods[] = {
  {"_update_order_char", (PyCFunction)__pyx_pw_4cupy_4core_4core_1_update_order_char, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core__update_order_char},
  {"_get_strides_for_order_K", (PyCFunction)__pyx_pw_4cupy_4core_4core_3_get_strides_for_order_K, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_2_get_strides_for_order_K},
  {"_get_header_dir_path", (PyCFunction)__pyx_pw_4cupy_4core_4core_5_get_header_dir_path, METH_NOARGS, __pyx_doc_4cupy_4core_4core_4_get_header_dir_path},
  {"_get_header_source", (PyCFunction)__pyx_pw_4cupy_4core_4core_7_get_header_source, METH_NOARGS, __pyx_doc_4cupy_4core_4core_6_get_header_source},
  {"compile_with_cache", (PyCFunction)__pyx_pw_4cupy_4core_4core_9compile_with_cache, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_8compile_with_cache},
  {"array", (PyCFunction)__pyx_pw_4cupy_4core_4core_11array, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_10array},
  {"_internal_ascontiguousarray", (PyCFunction)__pyx_pw_4cupy_4core_4core_13_internal_ascontiguousarray, METH_O, __pyx_doc_4cupy_4core_4core_12_internal_ascontiguousarray},
  {"_internal_asfortranarray", (PyCFunction)__pyx_pw_4cupy_4core_4core_15_internal_asfortranarray, METH_O, __pyx_doc_4cupy_4core_4core_14_internal_asfortranarray},
  {"ascontiguousarray", (PyCFunction)__pyx_pw_4cupy_4core_4core_17ascontiguousarray, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_16ascontiguousarray},
  {"asfortranarray", (PyCFunction)__pyx_pw_4cupy_4core_4core_19asfortranarray, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_18asfortranarray},
  {"_create_bit_op", (PyCFunction)__pyx_pw_4cupy_4core_4core_21_create_bit_op, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_20_create_bit_op},
  {"dot", (PyCFunction)__pyx_pw_4cupy_4core_4core_23dot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_22dot},
  {"matmul", (PyCFunction)__pyx_pw_4cupy_4core_4core_25matmul, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_24matmul},
  {"tensordot_core", (PyCFunction)__pyx_pw_4cupy_4core_4core_27tensordot_core, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_26tensordot_core},
  {"_mat_to_cublas_contiguous", (PyCFunction)__pyx_pw_4cupy_4core_4core_29_mat_to_cublas_contiguous, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_28_mat_to_cublas_contiguous},
  {"_to_cublas_vector", (PyCFunction)__pyx_pw_4cupy_4core_4core_31_to_cublas_vector, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_30_to_cublas_vector},
  {"create_comparison", (PyCFunction)__pyx_pw_4cupy_4core_4core_33create_comparison, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_32create_comparison},
  {"_convert_object_with_cuda_array_interface", (PyCFunction)__pyx_pw_4cupy_4core_4core_35_convert_object_with_cuda_array_interface, METH_O, __pyx_doc_4cupy_4core_4core_34_convert_object_with_cuda_array_interface},
  {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_u_0, __pyx_k_0, sizeof(__pyx_k_0), 0, 1, 0, 0},
  {&__pyx_kp_u_1_14_0, __pyx_k_1_14_0, sizeof(__pyx_k_1_14_0), 0, 1, 0, 0},
  {&__pyx_n_u_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 1, 0, 1},
  {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
  {&__pyx_kp_u_Axis_dimension_mismatch, __pyx_k_Axis_dimension_mismatch, sizeof(__pyx_k_Axis_dimension_mismatch), 0, 1, 0, 0},
  {&__pyx_kp_u_BB, __pyx_k_BB, sizeof(__pyx_k_BB), 0, 1, 0, 0},
  {&__pyx_kp_u_BB_B, __pyx_k_BB_B, sizeof(__pyx_k_BB_B), 0, 1, 0, 0},
  {&__pyx_kp_u_BB_BB, __pyx_k_BB_BB, sizeof(__pyx_k_BB_BB), 0, 1, 0, 0},
  {&__pyx_kp_u_B_B, __pyx_k_B_B, sizeof(__pyx_k_B_B), 0, 1, 0, 0},
  {&__pyx_kp_u_Bq_B, __pyx_k_Bq_B, sizeof(__pyx_k_Bq_B), 0, 1, 0, 0},
  {&__pyx_n_u_C, __pyx_k_C, sizeof(__pyx_k_C), 0, 1, 0, 1},
  {&__pyx_n_s_CUDARuntimeError, __pyx_k_CUDARuntimeError, sizeof(__pyx_k_CUDARuntimeError), 0, 0, 1, 1},
  {&__pyx_kp_u_Cannot_set_to_non_contiguous_arr, __pyx_k_Cannot_set_to_non_contiguous_arr, sizeof(__pyx_k_Cannot_set_to_non_contiguous_arr), 0, 1, 0, 0},
  {&__pyx_kp_u_Casting_complex_values_to_real_d, __pyx_k_Casting_complex_values_to_real_d, sizeof(__pyx_k_Casting_complex_values_to_real_d), 0, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_n_s_ComplexWarning, __pyx_k_ComplexWarning, sizeof(__pyx_k_ComplexWarning), 0, 0, 1, 1},
  {&__pyx_kp_u_Computes_the_bitwise_AND_of_two, __pyx_k_Computes_the_bitwise_AND_of_two, sizeof(__pyx_k_Computes_the_bitwise_AND_of_two), 0, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_kp_u_Computes_the_bitwise_XOR_of_two, __pyx_k_Computes_the_bitwise_XOR_of_two, sizeof(__pyx_k_Computes_the_bitwise_XOR_of_two), 0, 1, 0, 0},
  {&__pyx_kp_u_CuPy_cannot_copy_non_contiguous, __pyx_k_CuPy_cannot_copy_non_contiguous, sizeof(__pyx_k_CuPy_cannot_copy_non_contiguous), 0, 1, 0, 0},
  {&__pyx_kp_u_CuPy_currently_does_not_support, __pyx_k_CuPy_currently_does_not_support, sizeof(__pyx_k_CuPy_currently_does_not_support), 0, 1, 0, 0},
  {&__pyx_n_u_D, __pyx_k_D, sizeof(__pyx_k_D), 0, 1, 0, 1},
  {&__pyx_kp_u_DD, __pyx_k_DD, sizeof(__pyx_k_DD), 0, 1, 0, 0},
  {&__pyx_n_s_DeprecationWarning, __pyx_k_DeprecationWarning, sizeof(__pyx_k_DeprecationWarning), 0, 0, 1, 1},
  {&__pyx_kp_u_Dq_D, __pyx_k_Dq_D, sizeof(__pyx_k_Dq_D), 0, 1, 0, 0},
  {&__pyx_n_s_ENABLE_SLICE_COPY, __pyx_k_ENABLE_SLICE_COPY, sizeof(__pyx_k_ENABLE_SLICE_COPY), 0, 0, 1, 1},
  {&__pyx_n_s_ElementwiseKernel, __pyx_k_ElementwiseKernel, sizeof(__pyx_k_ElementwiseKernel), 0, 0, 1, 1},
  {&__pyx_n_u_F, __pyx_k_F, sizeof(__pyx_k_F), 0, 1, 0, 1},
  {&__pyx_kp_u_FF, __pyx_k_FF, sizeof(__pyx_k_FF), 0, 1, 0, 0},
  {&__pyx_kp_u_Failed_to_auto_detect_CUDA_root, __pyx_k_Failed_to_auto_detect_CUDA_root, sizeof(__pyx_k_Failed_to_auto_detect_CUDA_root), 0, 1, 0, 0},
  {&__pyx_n_u_Ff, __pyx_k_Ff, sizeof(__pyx_k_Ff), 0, 1, 0, 1},
  {&__pyx_n_s_Flags, __pyx_k_Flags, sizeof(__pyx_k_Flags), 0, 0, 1, 1},
  {&__pyx_kp_u_Fq_F, __pyx_k_Fq_F, sizeof(__pyx_k_Fq_F), 0, 1, 0, 0},
  {&__pyx_kp_u_HH, __pyx_k_HH, sizeof(__pyx_k_HH), 0, 1, 0, 0},
  {&__pyx_kp_u_HH_H, __pyx_k_HH_H, sizeof(__pyx_k_HH_H), 0, 1, 0, 0},
  {&__pyx_kp_u_HH_HH, __pyx_k_HH_HH, sizeof(__pyx_k_HH_HH), 0, 1, 0, 0},
  {&__pyx_kp_u_H_H, __pyx_k_H_H, sizeof(__pyx_k_H_H), 0, 1, 0, 0},
  {&__pyx_kp_u_Hq_H, __pyx_k_Hq_H, sizeof(__pyx_k_Hq_H), 0, 1, 0, 0},
  {&__pyx_kp_u_I, __pyx_k_I, sizeof(__pyx_k_I), 0, 1, 0, 0},
  {&__pyx_kp_u_II, __pyx_k_II, sizeof(__pyx_k_II), 0, 1, 0, 0},
  {&__pyx_kp_u_II_I, __pyx_k_II_I, sizeof(__pyx_k_II_I), 0, 1, 0, 0},
  {&__pyx_kp_u_II_II, __pyx_k_II_II, sizeof(__pyx_k_II_II), 0, 1, 0, 0},
  {&__pyx_kp_u_I_I, __pyx_k_I_I, sizeof(__pyx_k_I_I), 0, 1, 0, 0},
  {&__pyx_kp_u_I_s, __pyx_k_I_s, sizeof(__pyx_k_I_s), 0, 1, 0, 0},
  {&__pyx_kp_u_Invalid_dtype_s, __pyx_k_Invalid_dtype_s, sizeof(__pyx_k_Invalid_dtype_s), 0, 1, 0, 0},
  {&__pyx_kp_u_Iq_I, __pyx_k_Iq_I, sizeof(__pyx_k_Iq_I), 0, 1, 0, 0},
  {&__pyx_n_u_K, __pyx_k_K, sizeof(__pyx_k_K), 0, 1, 0, 1},
  {&__pyx_n_u_KAka, __pyx_k_KAka, sizeof(__pyx_k_KAka), 0, 1, 0, 1},
  {&__pyx_kp_u_LL, __pyx_k_LL, sizeof(__pyx_k_LL), 0, 1, 0, 0},
  {&__pyx_kp_u_LL_L, __pyx_k_LL_L, sizeof(__pyx_k_LL_L), 0, 1, 0, 0},
  {&__pyx_kp_u_LL_LL, __pyx_k_LL_LL, sizeof(__pyx_k_LL_LL), 0, 1, 0, 0},
  {&__pyx_kp_u_L_L, __pyx_k_L_L, sizeof(__pyx_k_L_L), 0, 1, 0, 0},
  {&__pyx_kp_u_Lq_L, __pyx_k_Lq_L, sizeof(__pyx_k_Lq_L), 0, 1, 0, 0},
  {&__pyx_kp_u_Negative_dimensions_are_not_allo, __pyx_k_Negative_dimensions_are_not_allo, sizeof(__pyx_k_Negative_dimensions_are_not_allo), 0, 1, 0, 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_u_Not_supported_dtype_combination, __pyx_k_Not_supported_dtype_combination, sizeof(__pyx_k_Not_supported_dtype_combination), 0, 1, 0, 0},
  {&__pyx_n_s_NumpyVersion, __pyx_k_NumpyVersion, sizeof(__pyx_k_NumpyVersion), 0, 0, 1, 1},
  {&__pyx_kp_u_Only_numpy_ndarray_can_be_obtain, __pyx_k_Only_numpy_ndarray_can_be_obtain, sizeof(__pyx_k_Only_numpy_ndarray_can_be_obtain), 0, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_kp_u_Output_array_has_an_invalid_size, __pyx_k_Output_array_has_an_invalid_size, sizeof(__pyx_k_Output_array_has_an_invalid_size), 0, 1, 0, 0},
  {&__pyx_kp_u_Output_array_must_be_C_contiguou, __pyx_k_Output_array_must_be_C_contiguou, sizeof(__pyx_k_Output_array_must_be_C_contiguou), 0, 1, 0, 0},
  {&__pyx_n_s_PerformanceWarning, __pyx_k_PerformanceWarning, sizeof(__pyx_k_PerformanceWarning), 0, 0, 1, 1},
  {&__pyx_kp_u_QQ, __pyx_k_QQ, sizeof(__pyx_k_QQ), 0, 1, 0, 0},
  {&__pyx_kp_u_QQ_Q, __pyx_k_QQ_Q, sizeof(__pyx_k_QQ_Q), 0, 1, 0, 0},
  {&__pyx_kp_u_QQ_QQ, __pyx_k_QQ_QQ, sizeof(__pyx_k_QQ_QQ), 0, 1, 0, 0},
  {&__pyx_kp_u_Q_Q, __pyx_k_Q_Q, sizeof(__pyx_k_Q_Q), 0, 1, 0, 0},
  {&__pyx_kp_u_Qq_Q, __pyx_k_Qq_Q, sizeof(__pyx_k_Qq_Q), 0, 1, 0, 0},
  {&__pyx_n_s_ReductionKernel, __pyx_k_ReductionKernel, sizeof(__pyx_k_ReductionKernel), 0, 0, 1, 1},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_kp_u_S_x_T_y, __pyx_k_S_x_T_y, sizeof(__pyx_k_S_x_T_y), 0, 1, 0, 0},
  {&__pyx_kp_u_Scalar_operands_are_not_allowed, __pyx_k_Scalar_operands_are_not_allowed, sizeof(__pyx_k_Scalar_operands_are_not_allowed), 0, 1, 0, 0},
  {&__pyx_kp_u_Shape_mismatch_Expected_shape_ac, __pyx_k_Shape_mismatch_Expected_shape_ac, sizeof(__pyx_k_Shape_mismatch_Expected_shape_ac), 0, 1, 0, 0},
  {&__pyx_kp_u_Shape_mismatch_Old_shape_new_sha, __pyx_k_Shape_mismatch_Old_shape_new_sha, sizeof(__pyx_k_Shape_mismatch_Old_shape_new_sha), 0, 1, 0, 0},
  {&__pyx_kp_u_Shifts_the_bits_of_each_integer, __pyx_k_Shifts_the_bits_of_each_integer, sizeof(__pyx_k_Shifts_the_bits_of_each_integer), 0, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_kp_u_T_base_T_stride, __pyx_k_T_base_T_stride, sizeof(__pyx_k_T_base_T_stride), 0, 1, 0, 0},
  {&__pyx_kp_u_T_out, __pyx_k_T_out, sizeof(__pyx_k_T_out), 0, 1, 0, 0},
  {&__pyx_kp_u_T_x, __pyx_k_T_x, sizeof(__pyx_k_T_x), 0, 1, 0, 0},
  {&__pyx_kp_u_T_y, __pyx_k_T_y, sizeof(__pyx_k_T_y), 0, 1, 0, 0},
  {&__pyx_kp_u_Tests_elementwise_if_x1_x2_seeal, __pyx_k_Tests_elementwise_if_x1_x2_seeal, sizeof(__pyx_k_Tests_elementwise_if_x1_x2_seeal), 0, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_kp_u_The_out_parameter_must_have_exac, __pyx_k_The_out_parameter_must_have_exac, sizeof(__pyx_k_The_out_parameter_must_have_exac), 0, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_kp_u_U_out, __pyx_k_U_out, sizeof(__pyx_k_U_out), 0, 1, 0, 0},
  {&__pyx_n_s_UnownedMemory, __pyx_k_UnownedMemory, sizeof(__pyx_k_UnownedMemory), 0, 0, 1, 1},
  {&__pyx_kp_u_Unsupported_dtype_s, __pyx_k_Unsupported_dtype_s, sizeof(__pyx_k_Unsupported_dtype_s), 0, 1, 0, 0},
  {&__pyx_kp_u_Using_synchronous_transfer_as_pi, __pyx_k_Using_synchronous_transfer_as_pi, sizeof(__pyx_k_Using_synchronous_transfer_as_pi), 0, 1, 0, 0},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_kp_u_Zero_copy_conversion_to_a_DLPack, __pyx_k_Zero_copy_conversion_to_a_DLPack, sizeof(__pyx_k_Zero_copy_conversion_to_a_DLPack), 0, 1, 0, 0},
  {&__pyx_kp_u__21, __pyx_k__21, sizeof(__pyx_k__21), 0, 1, 0, 0},
  {&__pyx_kp_u__35, __pyx_k__35, sizeof(__pyx_k__35), 0, 1, 0, 0},
  {&__pyx_kp_u__44, __pyx_k__44, sizeof(__pyx_k__44), 0, 1, 0, 0},
  {&__pyx_kp_u__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 1, 0, 0},
  {&__pyx_kp_u__60, __pyx_k__60, sizeof(__pyx_k__60), 0, 1, 0, 0},
  {&__pyx_kp_u__66, __pyx_k__66, sizeof(__pyx_k__66), 0, 1, 0, 0},
  {&__pyx_kp_u__67, __pyx_k__67, sizeof(__pyx_k__67), 0, 1, 0, 0},
  {&__pyx_kp_u__68, __pyx_k__68, sizeof(__pyx_k__68), 0, 1, 0, 0},
  {&__pyx_kp_u__70, __pyx_k__70, sizeof(__pyx_k__70), 0, 1, 0, 0},
  {&__pyx_kp_u__71, __pyx_k__71, sizeof(__pyx_k__71), 0, 1, 0, 0},
  {&__pyx_kp_u__72, __pyx_k__72, sizeof(__pyx_k__72), 0, 1, 0, 0},
  {&__pyx_kp_u__73, __pyx_k__73, sizeof(__pyx_k__73), 0, 1, 0, 0},
  {&__pyx_kp_u__77, __pyx_k__77, sizeof(__pyx_k__77), 0, 1, 0, 0},
  {&__pyx_kp_u__78, __pyx_k__78, sizeof(__pyx_k__78), 0, 1, 0, 0},
  {&__pyx_kp_u__81, __pyx_k__81, sizeof(__pyx_k__81), 0, 1, 0, 0},
  {&__pyx_kp_u__82, __pyx_k__82, sizeof(__pyx_k__82), 0, 1, 0, 0},
  {&__pyx_kp_u__83, __pyx_k__83, sizeof(__pyx_k__83), 0, 1, 0, 0},
  {&__pyx_kp_u__84, __pyx_k__84, sizeof(__pyx_k__84), 0, 1, 0, 0},
  {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
  {&__pyx_kp_u_a_b, __pyx_k_a_b, sizeof(__pyx_k_a_b), 0, 1, 0, 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_abspath, __pyx_k_abspath, sizeof(__pyx_k_abspath), 0, 0, 1, 1},
  {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
  {&__pyx_n_s_any, __pyx_k_any, sizeof(__pyx_k_any), 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_argpartition, __pyx_k_argpartition, sizeof(__pyx_k_argpartition), 0, 0, 1, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 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_u_array_cannot_be_obtained_from_a, __pyx_k_array_cannot_be_obtained_from_a, sizeof(__pyx_k_array_cannot_be_obtained_from_a), 0, 1, 0, 0},
  {&__pyx_kp_u_array_cannot_be_set_to_array, __pyx_k_array_cannot_be_set_to_array, sizeof(__pyx_k_array_cannot_be_set_to_array), 0, 1, 0, 0},
  {&__pyx_n_s_array_interface, __pyx_k_array_interface, sizeof(__pyx_k_array_interface), 0, 0, 1, 1},
  {&__pyx_n_s_array_priority, __pyx_k_array_priority, sizeof(__pyx_k_array_priority), 0, 0, 1, 1},
  {&__pyx_n_u_array_priority, __pyx_k_array_priority, sizeof(__pyx_k_array_priority), 0, 1, 0, 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_n_s_axis2, __pyx_k_axis2, sizeof(__pyx_k_axis2), 0, 0, 1, 1},
  {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
  {&__pyx_n_u_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 1, 0, 1},
  {&__pyx_kp_u_b_b, __pyx_k_b_b, sizeof(__pyx_k_b_b), 0, 1, 0, 0},
  {&__pyx_n_s_backend, __pyx_k_backend, sizeof(__pyx_k_backend), 0, 0, 1, 1},
  {&__pyx_kp_u_bb, __pyx_k_bb, sizeof(__pyx_k_bb), 0, 1, 0, 0},
  {&__pyx_kp_u_bb_b, __pyx_k_bb_b, sizeof(__pyx_k_bb_b), 0, 1, 0, 0},
  {&__pyx_kp_u_bb_bb, __pyx_k_bb_bb, sizeof(__pyx_k_bb_bb), 0, 1, 0, 0},
  {&__pyx_kp_u_bhilqBHILQefdFD, __pyx_k_bhilqBHILQefdFD, sizeof(__pyx_k_bhilqBHILQefdFD), 0, 1, 0, 0},
  {&__pyx_n_s_bitwise_and, __pyx_k_bitwise_and, sizeof(__pyx_k_bitwise_and), 0, 0, 1, 1},
  {&__pyx_n_u_bitwise_and, __pyx_k_bitwise_and, sizeof(__pyx_k_bitwise_and), 0, 1, 0, 1},
  {&__pyx_n_s_bitwise_or, __pyx_k_bitwise_or, sizeof(__pyx_k_bitwise_or), 0, 0, 1, 1},
  {&__pyx_n_u_bitwise_or, __pyx_k_bitwise_or, sizeof(__pyx_k_bitwise_or), 0, 1, 0, 1},
  {&__pyx_n_s_bitwise_xor, __pyx_k_bitwise_xor, sizeof(__pyx_k_bitwise_xor), 0, 0, 1, 1},
  {&__pyx_n_u_bitwise_xor, __pyx_k_bitwise_xor, sizeof(__pyx_k_bitwise_xor), 0, 1, 0, 1},
  {&__pyx_kp_u_bq_b, __pyx_k_bq_b, sizeof(__pyx_k_bq_b), 0, 1, 0, 0},
  {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1},
  {&__pyx_n_s_c_contiguous, __pyx_k_c_contiguous, sizeof(__pyx_k_c_contiguous), 0, 0, 1, 1},
  {&__pyx_n_s_c_void_p, __pyx_k_c_void_p, sizeof(__pyx_k_c_void_p), 0, 0, 1, 1},
  {&__pyx_n_s_cachd_dir, __pyx_k_cachd_dir, sizeof(__pyx_k_cachd_dir), 0, 0, 1, 1},
  {&__pyx_n_u_call, __pyx_k_call, sizeof(__pyx_k_call), 0, 1, 0, 1},
  {&__pyx_kp_u_calling_nonzero_on_0d_arrays_is, __pyx_k_calling_nonzero_on_0d_arrays_is, sizeof(__pyx_k_calling_nonzero_on_0d_arrays_is), 0, 1, 0, 0},
  {&__pyx_kp_u_calling_reduced_view_with_dtype, __pyx_k_calling_reduced_view_with_dtype, sizeof(__pyx_k_calling_reduced_view_with_dtype), 0, 1, 0, 0},
  {&__pyx_kp_u_can_only_convert_an_array_of_siz, __pyx_k_can_only_convert_an_array_of_siz, sizeof(__pyx_k_can_only_convert_an_array_of_siz), 0, 1, 0, 0},
  {&__pyx_n_s_casting, __pyx_k_casting, sizeof(__pyx_k_casting), 0, 0, 1, 1},
  {&__pyx_kp_u_casting_is_not_supported_yet, __pyx_k_casting_is_not_supported_yet, sizeof(__pyx_k_casting_is_not_supported_yet), 0, 1, 0, 0},
  {&__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_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_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_compile, __pyx_k_compile, sizeof(__pyx_k_compile), 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_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_n_s_compress, __pyx_k_compress, sizeof(__pyx_k_compress), 0, 0, 1, 1},
  {&__pyx_n_s_concatenate, __pyx_k_concatenate, sizeof(__pyx_k_concatenate), 0, 0, 1, 1},
  {&__pyx_n_s_condition, __pyx_k_condition, sizeof(__pyx_k_condition), 0, 0, 1, 1},
  {&__pyx_n_s_conj, __pyx_k_conj, sizeof(__pyx_k_conj), 0, 0, 1, 1},
  {&__pyx_n_s_conjugate, __pyx_k_conjugate, sizeof(__pyx_k_conjugate), 0, 0, 1, 1},
  {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1},
  {&__pyx_kp_u_copying_a_numpy_ndarray_to_a_cup, __pyx_k_copying_a_numpy_ndarray_to_a_cup, sizeof(__pyx_k_copying_a_numpy_ndarray_to_a_cup), 0, 1, 0, 0},
  {&__pyx_n_s_create_ufunc, __pyx_k_create_ufunc, sizeof(__pyx_k_create_ufunc), 0, 0, 1, 1},
  {&__pyx_n_s_ctypes, __pyx_k_ctypes, sizeof(__pyx_k_ctypes), 0, 0, 1, 1},
  {&__pyx_kp_u_cuComplex_h, __pyx_k_cuComplex_h, sizeof(__pyx_k_cuComplex_h), 0, 1, 0, 0},
  {&__pyx_n_s_cucomplex_include_pattern, __pyx_k_cucomplex_include_pattern, sizeof(__pyx_k_cucomplex_include_pattern), 0, 0, 1, 1},
  {&__pyx_n_s_cucomplex_include_tokens, __pyx_k_cucomplex_include_tokens, sizeof(__pyx_k_cucomplex_include_tokens), 0, 0, 1, 1},
  {&__pyx_n_s_cuda, __pyx_k_cuda, sizeof(__pyx_k_cuda), 0, 0, 1, 1},
  {&__pyx_kp_u_cuda_10_0, __pyx_k_cuda_10_0, sizeof(__pyx_k_cuda_10_0), 0, 1, 0, 0},
  {&__pyx_kp_u_cuda_10_1, __pyx_k_cuda_10_1, sizeof(__pyx_k_cuda_10_1), 0, 1, 0, 0},
  {&__pyx_kp_u_cuda_10_2, __pyx_k_cuda_10_2, sizeof(__pyx_k_cuda_10_2), 0, 1, 0, 0},
  {&__pyx_n_u_cuda_2, __pyx_k_cuda_2, sizeof(__pyx_k_cuda_2), 0, 1, 0, 1},
  {&__pyx_kp_u_cuda_9_2, __pyx_k_cuda_9_2, sizeof(__pyx_k_cuda_9_2), 0, 1, 0, 0},
  {&__pyx_n_s_cuda_array_interface, __pyx_k_cuda_array_interface, sizeof(__pyx_k_cuda_array_interface), 0, 0, 1, 1},
  {&__pyx_n_u_cuda_array_interface, __pyx_k_cuda_array_interface, sizeof(__pyx_k_cuda_array_interface), 0, 1, 0, 1},
  {&__pyx_n_s_cumprod, __pyx_k_cumprod, sizeof(__pyx_k_cumprod), 0, 0, 1, 1},
  {&__pyx_n_s_cumsum, __pyx_k_cumsum, sizeof(__pyx_k_cumsum), 0, 0, 1, 1},
  {&__pyx_n_s_cupy, __pyx_k_cupy, sizeof(__pyx_k_cupy), 0, 0, 1, 1},
  {&__pyx_n_u_cupy, __pyx_k_cupy, sizeof(__pyx_k_cupy), 0, 1, 0, 1},
  {&__pyx_n_u_cupy_2, __pyx_k_cupy_2, sizeof(__pyx_k_cupy_2), 0, 1, 0, 1},
  {&__pyx_kp_u_cupy_atomics_cuh, __pyx_k_cupy_atomics_cuh, sizeof(__pyx_k_cupy_atomics_cuh), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_carray_cuh, __pyx_k_cupy_carray_cuh, sizeof(__pyx_k_cupy_carray_cuh), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_arithmetic_h, __pyx_k_cupy_complex_arithmetic_h, sizeof(__pyx_k_cupy_complex_arithmetic_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_catrig_h, __pyx_k_cupy_complex_catrig_h, sizeof(__pyx_k_cupy_complex_catrig_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_catrigf_h, __pyx_k_cupy_complex_catrigf_h, sizeof(__pyx_k_cupy_complex_catrigf_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_ccosh_h, __pyx_k_cupy_complex_ccosh_h, sizeof(__pyx_k_cupy_complex_ccosh_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_ccoshf_h, __pyx_k_cupy_complex_ccoshf_h, sizeof(__pyx_k_cupy_complex_ccoshf_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_cexp_h, __pyx_k_cupy_complex_cexp_h, sizeof(__pyx_k_cupy_complex_cexp_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_cexpf_h, __pyx_k_cupy_complex_cexpf_h, sizeof(__pyx_k_cupy_complex_cexpf_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_clog_h, __pyx_k_cupy_complex_clog_h, sizeof(__pyx_k_cupy_complex_clog_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_clogf_h, __pyx_k_cupy_complex_clogf_h, sizeof(__pyx_k_cupy_complex_clogf_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_complex_h, __pyx_k_cupy_complex_complex_h, sizeof(__pyx_k_cupy_complex_complex_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_complex_inl_h, __pyx_k_cupy_complex_complex_inl_h, sizeof(__pyx_k_cupy_complex_complex_inl_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_cpow_h, __pyx_k_cupy_complex_cpow_h, sizeof(__pyx_k_cupy_complex_cpow_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_cproj_h, __pyx_k_cupy_complex_cproj_h, sizeof(__pyx_k_cupy_complex_cproj_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_csinh_h, __pyx_k_cupy_complex_csinh_h, sizeof(__pyx_k_cupy_complex_csinh_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_csinhf_h, __pyx_k_cupy_complex_csinhf_h, sizeof(__pyx_k_cupy_complex_csinhf_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_csqrt_h, __pyx_k_cupy_complex_csqrt_h, sizeof(__pyx_k_cupy_complex_csqrt_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_csqrtf_h, __pyx_k_cupy_complex_csqrtf_h, sizeof(__pyx_k_cupy_complex_csqrtf_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_ctanh_h, __pyx_k_cupy_complex_ctanh_h, sizeof(__pyx_k_cupy_complex_ctanh_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_ctanhf_h, __pyx_k_cupy_complex_ctanhf_h, sizeof(__pyx_k_cupy_complex_ctanhf_h), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_cuh, __pyx_k_cupy_complex_cuh, sizeof(__pyx_k_cupy_complex_cuh), 0, 1, 0, 0},
  {&__pyx_kp_u_cupy_complex_math_private_h, __pyx_k_cupy_complex_math_private_h, sizeof(__pyx_k_cupy_complex_math_private_h), 0, 1, 0, 0},
  {&__pyx_n_s_cupy_core, __pyx_k_cupy_core, sizeof(__pyx_k_cupy_core), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_core__kernel, __pyx_k_cupy_core__kernel, sizeof(__pyx_k_cupy_core__kernel), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_core__reduction, __pyx_k_cupy_core__reduction, sizeof(__pyx_k_cupy_core__reduction), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_core__ufuncs, __pyx_k_cupy_core__ufuncs, sizeof(__pyx_k_cupy_core__ufuncs), 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_u_cupy_cuComplex_bridge_h, __pyx_k_cupy_cuComplex_bridge_h, sizeof(__pyx_k_cupy_cuComplex_bridge_h), 0, 1, 0, 0},
  {&__pyx_n_s_cupy_cuda, __pyx_k_cupy_cuda, sizeof(__pyx_k_cupy_cuda), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_cuda_runtime, __pyx_k_cupy_cuda_runtime, sizeof(__pyx_k_cupy_cuda_runtime), 0, 0, 1, 1},
  {&__pyx_n_u_cupy_divmod, __pyx_k_cupy_divmod, sizeof(__pyx_k_cupy_divmod), 0, 1, 0, 1},
  {&__pyx_n_u_cupy_invert, __pyx_k_cupy_invert, sizeof(__pyx_k_cupy_invert), 0, 1, 0, 1},
  {&__pyx_n_u_cupy_round, __pyx_k_cupy_round, sizeof(__pyx_k_cupy_round), 0, 1, 0, 1},
  {&__pyx_n_u_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 1, 0, 1},
  {&__pyx_n_u_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 1, 0, 1},
  {&__pyx_kp_u_dd, __pyx_k_dd, sizeof(__pyx_k_dd), 0, 1, 0, 0},
  {&__pyx_kp_u_dd_dd, __pyx_k_dd_dd, sizeof(__pyx_k_dd_dd), 0, 1, 0, 0},
  {&__pyx_n_s_ddof, __pyx_k_ddof, sizeof(__pyx_k_ddof), 0, 0, 1, 1},
  {&__pyx_n_s_decimals, __pyx_k_decimals, sizeof(__pyx_k_decimals), 0, 0, 1, 1},
  {&__pyx_n_s_declare_synchronize, __pyx_k_declare_synchronize, sizeof(__pyx_k_declare_synchronize), 0, 0, 1, 1},
  {&__pyx_n_s_descr, __pyx_k_descr, sizeof(__pyx_k_descr), 0, 0, 1, 1},
  {&__pyx_n_u_descr, __pyx_k_descr, sizeof(__pyx_k_descr), 0, 1, 0, 1},
  {&__pyx_n_s_device, __pyx_k_device, sizeof(__pyx_k_device), 0, 0, 1, 1},
  {&__pyx_n_s_diagonal, __pyx_k_diagonal, sizeof(__pyx_k_diagonal), 0, 0, 1, 1},
  {&__pyx_n_s_dirname, __pyx_k_dirname, sizeof(__pyx_k_dirname), 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_kp_u_double_x_inv_x_if_in1_0_x_inv_x, __pyx_k_double_x_inv_x_if_in1_0_x_inv_x, sizeof(__pyx_k_double_x_inv_x_if_in1_0_x_inv_x), 0, 1, 0, 0},
  {&__pyx_kp_u_dq_d, __pyx_k_dq_d, sizeof(__pyx_k_dq_d), 0, 1, 0, 0},
  {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 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_n_u_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 1, 0, 1},
  {&__pyx_kp_u_ee, __pyx_k_ee, sizeof(__pyx_k_ee), 0, 1, 0, 0},
  {&__pyx_kp_u_ee_ee, __pyx_k_ee_ee, sizeof(__pyx_k_ee_ee), 0, 1, 0, 0},
  {&__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_enable_cooperative_groups, __pyx_k_enable_cooperative_groups, sizeof(__pyx_k_enable_cooperative_groups), 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_kp_u_eq_e, __pyx_k_eq_e, sizeof(__pyx_k_eq_e), 0, 1, 0, 0},
  {&__pyx_n_s_equal, __pyx_k_equal, sizeof(__pyx_k_equal), 0, 0, 1, 1},
  {&__pyx_n_u_equal, __pyx_k_equal, sizeof(__pyx_k_equal), 0, 1, 0, 1},
  {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
  {&__pyx_n_s_expand_dims, __pyx_k_expand_dims, sizeof(__pyx_k_expand_dims), 0, 0, 1, 1},
  {&__pyx_n_u_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 1, 0, 1},
  {&__pyx_n_s_f_contiguous, __pyx_k_f_contiguous, sizeof(__pyx_k_f_contiguous), 0, 0, 1, 1},
  {&__pyx_n_u_fdFD, __pyx_k_fdFD, sizeof(__pyx_k_fdFD), 0, 1, 0, 1},
  {&__pyx_kp_u_ff, __pyx_k_ff, sizeof(__pyx_k_ff), 0, 1, 0, 0},
  {&__pyx_kp_u_ff_ff, __pyx_k_ff_ff, sizeof(__pyx_k_ff_ff), 0, 1, 0, 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_u_fill, __pyx_k_fill, sizeof(__pyx_k_fill), 0, 1, 0, 1},
  {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
  {&__pyx_n_s_flatiter, __pyx_k_flatiter, sizeof(__pyx_k_flatiter), 0, 0, 1, 1},
  {&__pyx_n_s_flatten, __pyx_k_flatten, sizeof(__pyx_k_flatten), 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_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_kp_u_fq_f, __pyx_k_fq_f, sizeof(__pyx_k_fq_f), 0, 1, 0, 0},
  {&__pyx_n_s_frombuffer, __pyx_k_frombuffer, sizeof(__pyx_k_frombuffer), 0, 0, 1, 1},
  {&__pyx_n_s_func, __pyx_k_func, sizeof(__pyx_k_func), 0, 0, 1, 1},
  {&__pyx_n_s_functools, __pyx_k_functools, sizeof(__pyx_k_functools), 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_compute_capability, __pyx_k_get_compute_capability, sizeof(__pyx_k_get_compute_capability), 0, 0, 1, 1},
  {&__pyx_n_s_get_cublas_handle, __pyx_k_get_cublas_handle, sizeof(__pyx_k_get_cublas_handle), 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_device_id, __pyx_k_get_device_id, sizeof(__pyx_k_get_device_id), 0, 0, 1, 1},
  {&__pyx_n_s_getattr, __pyx_k_getattr, sizeof(__pyx_k_getattr), 0, 0, 1, 1},
  {&__pyx_n_s_greater, __pyx_k_greater, sizeof(__pyx_k_greater), 0, 0, 1, 1},
  {&__pyx_n_u_greater, __pyx_k_greater, sizeof(__pyx_k_greater), 0, 1, 0, 1},
  {&__pyx_n_s_greater_equal, __pyx_k_greater_equal, sizeof(__pyx_k_greater_equal), 0, 0, 1, 1},
  {&__pyx_n_u_greater_equal, __pyx_k_greater_equal, sizeof(__pyx_k_greater_equal), 0, 1, 0, 1},
  {&__pyx_kp_u_h_h, __pyx_k_h_h, sizeof(__pyx_k_h_h), 0, 1, 0, 0},
  {&__pyx_n_s_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 0, 0, 1, 1},
  {&__pyx_kp_u_hh, __pyx_k_hh, sizeof(__pyx_k_hh), 0, 1, 0, 0},
  {&__pyx_kp_u_hh_h, __pyx_k_hh_h, sizeof(__pyx_k_hh_h), 0, 1, 0, 0},
  {&__pyx_kp_u_hh_hh, __pyx_k_hh_hh, sizeof(__pyx_k_hh_hh), 0, 1, 0, 0},
  {&__pyx_kp_u_hq_h, __pyx_k_hq_h, sizeof(__pyx_k_hq_h), 0, 1, 0, 0},
  {&__pyx_kp_u_i_i, __pyx_k_i_i, sizeof(__pyx_k_i_i), 0, 1, 0, 0},
  {&__pyx_kp_u_if_in1_0_TODO_okuta_Move_before, __pyx_k_if_in1_0_TODO_okuta_Move_before, sizeof(__pyx_k_if_in1_0_TODO_okuta_Move_before), 0, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_kp_u_if_in1_0_out0_round_in0_else_do, __pyx_k_if_in1_0_out0_round_in0_else_do, sizeof(__pyx_k_if_in1_0_out0_round_in0_else_do), 0, 1, 0, 0},
  {&__pyx_kp_u_ii, __pyx_k_ii, sizeof(__pyx_k_ii), 0, 1, 0, 0},
  {&__pyx_kp_u_ii_i, __pyx_k_ii_i, sizeof(__pyx_k_ii_i), 0, 1, 0, 0},
  {&__pyx_kp_u_ii_ii, __pyx_k_ii_ii, sizeof(__pyx_k_ii_ii), 0, 1, 0, 0},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_u_include, __pyx_k_include, sizeof(__pyx_k_include), 0, 1, 0, 1},
  {&__pyx_kp_u_include_cupy_cuComplex_bridge_h, __pyx_k_include_cupy_cuComplex_bridge_h, sizeof(__pyx_k_include_cupy_cuComplex_bridge_h), 0, 1, 0, 0},
  {&__pyx_kp_u_include_s, __pyx_k_include_s, sizeof(__pyx_k_include_s), 0, 1, 0, 0},
  {&__pyx_n_s_indices, __pyx_k_indices, sizeof(__pyx_k_indices), 0, 0, 1, 1},
  {&__pyx_n_s_invert, __pyx_k_invert, sizeof(__pyx_k_invert), 0, 0, 1, 1},
  {&__pyx_kp_u_iq_i, __pyx_k_iq_i, sizeof(__pyx_k_iq_i), 0, 1, 0, 0},
  {&__pyx_n_s_is_c_contiguous, __pyx_k_is_c_contiguous, sizeof(__pyx_k_is_c_contiguous), 0, 0, 1, 1},
  {&__pyx_n_s_item, __pyx_k_item, sizeof(__pyx_k_item), 0, 0, 1, 1},
  {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1},
  {&__pyx_n_s_iter___locals_genexpr, __pyx_k_iter___locals_genexpr, sizeof(__pyx_k_iter___locals_genexpr), 0, 0, 1, 1},
  {&__pyx_kp_u_iteration_over_a_0_d_array, __pyx_k_iteration_over_a_0_d_array, sizeof(__pyx_k_iteration_over_a_0_d_array), 0, 1, 0, 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_keepends, __pyx_k_keepends, sizeof(__pyx_k_keepends), 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_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
  {&__pyx_kp_u_l_l, __pyx_k_l_l, sizeof(__pyx_k_l_l), 0, 1, 0, 0},
  {&__pyx_n_s_left_shift, __pyx_k_left_shift, sizeof(__pyx_k_left_shift), 0, 0, 1, 1},
  {&__pyx_n_u_left_shift, __pyx_k_left_shift, sizeof(__pyx_k_left_shift), 0, 1, 0, 1},
  {&__pyx_kp_u_len_of_unsized_object, __pyx_k_len_of_unsized_object, sizeof(__pyx_k_len_of_unsized_object), 0, 1, 0, 0},
  {&__pyx_kp_u_len_shape_len_strides, __pyx_k_len_shape_len_strides, sizeof(__pyx_k_len_shape_len_strides), 0, 1, 0, 0},
  {&__pyx_n_s_less, __pyx_k_less, sizeof(__pyx_k_less), 0, 0, 1, 1},
  {&__pyx_n_u_less, __pyx_k_less, sizeof(__pyx_k_less), 0, 1, 0, 1},
  {&__pyx_n_s_less_equal, __pyx_k_less_equal, sizeof(__pyx_k_less_equal), 0, 0, 1, 1},
  {&__pyx_n_u_less_equal, __pyx_k_less_equal, sizeof(__pyx_k_less_equal), 0, 1, 0, 1},
  {&__pyx_n_s_lib, __pyx_k_lib, sizeof(__pyx_k_lib), 0, 0, 1, 1},
  {&__pyx_kp_u_ll, __pyx_k_ll, sizeof(__pyx_k_ll), 0, 1, 0, 0},
  {&__pyx_kp_u_ll_l, __pyx_k_ll_l, sizeof(__pyx_k_ll_l), 0, 1, 0, 0},
  {&__pyx_kp_u_ll_ll, __pyx_k_ll_ll, sizeof(__pyx_k_ll_ll), 0, 1, 0, 0},
  {&__pyx_kp_u_lq_l, __pyx_k_lq_l, sizeof(__pyx_k_lq_l), 0, 1, 0, 0},
  {&__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_u_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 1, 0, 1},
  {&__pyx_n_u_mat_ptrs, __pyx_k_mat_ptrs, sizeof(__pyx_k_mat_ptrs), 0, 1, 0, 1},
  {&__pyx_n_s_match, __pyx_k_match, sizeof(__pyx_k_match), 0, 0, 1, 1},
  {&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1},
  {&__pyx_n_s_mean, __pyx_k_mean, sizeof(__pyx_k_mean), 0, 0, 1, 1},
  {&__pyx_n_s_memory, __pyx_k_memory, sizeof(__pyx_k_memory), 0, 0, 1, 1},
  {&__pyx_n_s_memory_module, __pyx_k_memory_module, sizeof(__pyx_k_memory_module), 0, 0, 1, 1},
  {&__pyx_n_s_memptr, __pyx_k_memptr, sizeof(__pyx_k_memptr), 0, 0, 1, 1},
  {&__pyx_kp_u_memptr_is_required_if_strides_is, __pyx_k_memptr_is_required_if_strides_is, sizeof(__pyx_k_memptr_is_required_if_strides_is), 0, 1, 0, 0},
  {&__pyx_n_s_method, __pyx_k_method, sizeof(__pyx_k_method), 0, 0, 1, 1},
  {&__pyx_n_s_min, __pyx_k_min, sizeof(__pyx_k_min), 0, 0, 1, 1},
  {&__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_n, __pyx_k_n, sizeof(__pyx_k_n), 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_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_1183, __pyx_k_ndarray___getitem___line_1183, sizeof(__pyx_k_ndarray___getitem___line_1183), 0, 1, 0, 0},
  {&__pyx_kp_u_ndarray___setitem___line_1207, __pyx_k_ndarray___setitem___line_1207, sizeof(__pyx_k_ndarray___setitem___line_1207), 0, 1, 0, 0},
  {&__pyx_kp_u_ndarray_toDlpack_line_1648, __pyx_k_ndarray_toDlpack_line_1648, sizeof(__pyx_k_ndarray_toDlpack_line_1648), 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_no_bool, __pyx_k_no_bool, sizeof(__pyx_k_no_bool), 0, 0, 1, 1},
  {&__pyx_n_s_no_complex_dtype, __pyx_k_no_complex_dtype, sizeof(__pyx_k_no_complex_dtype), 0, 0, 1, 1},
  {&__pyx_kp_u_non_scalar_numpy_ndarray_cannot, __pyx_k_non_scalar_numpy_ndarray_cannot, sizeof(__pyx_k_non_scalar_numpy_ndarray_cannot), 0, 1, 0, 0},
  {&__pyx_n_s_nonzero, __pyx_k_nonzero, sizeof(__pyx_k_nonzero), 0, 0, 1, 1},
  {&__pyx_n_s_not_equal, __pyx_k_not_equal, sizeof(__pyx_k_not_equal), 0, 0, 1, 1},
  {&__pyx_n_u_not_equal, __pyx_k_not_equal, sizeof(__pyx_k_not_equal), 0, 1, 0, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_n_u_nvrtc, __pyx_k_nvrtc, sizeof(__pyx_k_nvrtc), 0, 1, 0, 1},
  {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 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_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_u_operands_could_not_be_broadcast, __pyx_k_operands_could_not_be_broadcast, sizeof(__pyx_k_operands_could_not_be_broadcast), 0, 1, 0, 0},
  {&__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_n_s_order_char, __pyx_k_order_char, sizeof(__pyx_k_order_char), 0, 0, 1, 1},
  {&__pyx_kp_u_order_not_understood_order_s, __pyx_k_order_not_understood_order_s, sizeof(__pyx_k_order_not_understood_order_s), 0, 1, 0, 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_n_u_out, __pyx_k_out, sizeof(__pyx_k_out), 0, 1, 0, 1},
  {&__pyx_kp_u_out0_in0, __pyx_k_out0_in0, sizeof(__pyx_k_out0_in0), 0, 1, 0, 0},
  {&__pyx_kp_u_out0_in0_2, __pyx_k_out0_in0_2, sizeof(__pyx_k_out0_in0_2), 0, 1, 0, 0},
  {&__pyx_kp_u_out0_in0_3, __pyx_k_out0_in0_3, sizeof(__pyx_k_out0_in0_3), 0, 1, 0, 0},
  {&__pyx_kp_u_out0_in0_s_in1, __pyx_k_out0_in0_s_in1, sizeof(__pyx_k_out0_in0_s_in1), 0, 1, 0, 0},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_kp_u_out_a, __pyx_k_out_a, sizeof(__pyx_k_out_a), 0, 1, 0, 0},
  {&__pyx_kp_u_out_base__ind_get__ind_ndim_1_st, __pyx_k_out_base__ind_get__ind_ndim_1_st, sizeof(__pyx_k_out_base__ind_get__ind_ndim_1_st), 0, 1, 0, 0},
  {&__pyx_kp_u_out_cannot_be_specified_when_co, __pyx_k_out_cannot_be_specified_when_co, sizeof(__pyx_k_out_cannot_be_specified_when_co), 0, 1, 0, 0},
  {&__pyx_n_s_partition, __pyx_k_partition, sizeof(__pyx_k_partition), 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_prepend_cupy_headers, __pyx_k_prepend_cupy_headers, sizeof(__pyx_k_prepend_cupy_headers), 0, 0, 1, 1},
  {&__pyx_n_s_prod, __pyx_k_prod, sizeof(__pyx_k_prod), 0, 0, 1, 1},
  {&__pyx_n_s_promote_types, __pyx_k_promote_types, sizeof(__pyx_k_promote_types), 0, 0, 1, 1},
  {&__pyx_n_s_ptp, __pyx_k_ptp, sizeof(__pyx_k_ptp), 0, 0, 1, 1},
  {&__pyx_n_s_put, __pyx_k_put, sizeof(__pyx_k_put), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_kp_u_q_e, __pyx_k_q_e, sizeof(__pyx_k_q_e), 0, 1, 0, 0},
  {&__pyx_kp_u_q_q, __pyx_k_q_q, sizeof(__pyx_k_q_q), 0, 1, 0, 0},
  {&__pyx_kp_u_qq, __pyx_k_qq, sizeof(__pyx_k_qq), 0, 1, 0, 0},
  {&__pyx_kp_u_qq_q, __pyx_k_qq_q, sizeof(__pyx_k_qq_q), 0, 1, 0, 0},
  {&__pyx_kp_u_qq_qq, __pyx_k_qq_qq, sizeof(__pyx_k_qq_qq), 0, 1, 0, 0},
  {&__pyx_n_s_radd, __pyx_k_radd, sizeof(__pyx_k_radd), 0, 0, 1, 1},
  {&__pyx_n_u_raise, __pyx_k_raise, sizeof(__pyx_k_raise), 0, 1, 0, 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_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_re, __pyx_k_re, sizeof(__pyx_k_re), 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_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_dims, __pyx_k_reduce_dims, sizeof(__pyx_k_reduce_dims), 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_repeat, __pyx_k_repeat, sizeof(__pyx_k_repeat), 0, 0, 1, 1},
  {&__pyx_n_s_repeats, __pyx_k_repeats, sizeof(__pyx_k_repeats), 0, 0, 1, 1},
  {&__pyx_n_s_reshape, __pyx_k_reshape, sizeof(__pyx_k_reshape), 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_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_right_shift, __pyx_k_right_shift, sizeof(__pyx_k_right_shift), 0, 0, 1, 1},
  {&__pyx_n_u_right_shift, __pyx_k_right_shift, sizeof(__pyx_k_right_shift), 0, 1, 0, 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_ror, __pyx_k_ror, sizeof(__pyx_k_ror), 0, 0, 1, 1},
  {&__pyx_n_s_round, __pyx_k_round, sizeof(__pyx_k_round), 0, 0, 1, 1},
  {&__pyx_n_s_round_ufunc, __pyx_k_round_ufunc, sizeof(__pyx_k_round_ufunc), 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_u_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 1, 0, 0},
  {&__pyx_kp_u_s_2, __pyx_k_s_2, sizeof(__pyx_k_s_2), 0, 1, 0, 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_contiguous_strides, __pyx_k_set_contiguous_strides, sizeof(__pyx_k_set_contiguous_strides), 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_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
  {&__pyx_n_u_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 1, 0, 1},
  {&__pyx_kp_u_shapes_and_not_aligned, __pyx_k_shapes_and_not_aligned, sizeof(__pyx_k_shapes_and_not_aligned), 0, 1, 0, 0},
  {&__pyx_n_s_signature, __pyx_k_signature, sizeof(__pyx_k_signature), 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_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
  {&__pyx_n_s_splitlines, __pyx_k_splitlines, sizeof(__pyx_k_splitlines), 0, 0, 1, 1},
  {&__pyx_n_s_squeeze, __pyx_k_squeeze, sizeof(__pyx_k_squeeze), 0, 0, 1, 1},
  {&__pyx_kp_u_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, 1, 0, 0},
  {&__pyx_n_s_status, __pyx_k_status, sizeof(__pyx_k_status), 0, 0, 1, 1},
  {&__pyx_n_s_std, __pyx_k_std, sizeof(__pyx_k_std), 0, 0, 1, 1},
  {&__pyx_n_s_str, __pyx_k_str, sizeof(__pyx_k_str), 0, 0, 1, 1},
  {&__pyx_n_s_stream, __pyx_k_stream, sizeof(__pyx_k_stream), 0, 0, 1, 1},
  {&__pyx_n_s_strides, __pyx_k_strides, sizeof(__pyx_k_strides), 0, 0, 1, 1},
  {&__pyx_n_u_strides, __pyx_k_strides, sizeof(__pyx_k_strides), 0, 1, 0, 1},
  {&__pyx_n_s_subok, __pyx_k_subok, sizeof(__pyx_k_subok), 0, 0, 1, 1},
  {&__pyx_kp_u_subok_is_not_supported_yet, __pyx_k_subok_is_not_supported_yet, sizeof(__pyx_k_subok_is_not_supported_yet), 0, 1, 0, 0},
  {&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1},
  {&__pyx_n_s_swapaxes, __pyx_k_swapaxes, sizeof(__pyx_k_swapaxes), 0, 0, 1, 1},
  {&__pyx_n_s_syncdetect, __pyx_k_syncdetect, sizeof(__pyx_k_syncdetect), 0, 0, 1, 1},
  {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
  {&__pyx_n_s_take, __pyx_k_take, sizeof(__pyx_k_take), 0, 0, 1, 1},
  {&__pyx_kp_u_template_typename_T___device, __pyx_k_template_typename_T___device, sizeof(__pyx_k_template_typename_T___device), 0, 1, 0, 0},
  {&__pyx_n_u_tensordot_core_mul_sum, __pyx_k_tensordot_core_mul_sum, sizeof(__pyx_k_tensordot_core_mul_sum), 0, 1, 0, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_n_s_toDlpack, __pyx_k_toDlpack, sizeof(__pyx_k_toDlpack), 0, 0, 1, 1},
  {&__pyx_n_s_tobytes, __pyx_k_tobytes, sizeof(__pyx_k_tobytes), 0, 0, 1, 1},
  {&__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_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_translate_cucomplex, __pyx_k_translate_cucomplex, sizeof(__pyx_k_translate_cucomplex), 0, 0, 1, 1},
  {&__pyx_n_s_types, __pyx_k_types, sizeof(__pyx_k_types), 0, 0, 1, 1},
  {&__pyx_n_u_typestr, __pyx_k_typestr, sizeof(__pyx_k_typestr), 0, 1, 0, 1},
  {&__pyx_n_s_ufunc, __pyx_k_ufunc, sizeof(__pyx_k_ufunc), 0, 0, 1, 1},
  {&__pyx_n_s_uintp, __pyx_k_uintp, sizeof(__pyx_k_uintp), 0, 0, 1, 1},
  {&__pyx_kp_u_unsupported_order, __pyx_k_unsupported_order, sizeof(__pyx_k_unsupported_order), 0, 1, 0, 0},
  {&__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_update_f_contiguity_2, __pyx_k_update_f_contiguity_2, sizeof(__pyx_k_update_f_contiguity_2), 0, 0, 1, 1},
  {&__pyx_n_s_upper, __pyx_k_upper, sizeof(__pyx_k_upper), 0, 0, 1, 1},
  {&__pyx_n_s_util, __pyx_k_util, sizeof(__pyx_k_util), 0, 0, 1, 1},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1},
  {&__pyx_n_s_var, __pyx_k_var, sizeof(__pyx_k_var), 0, 0, 1, 1},
  {&__pyx_n_u_version, __pyx_k_version, sizeof(__pyx_k_version), 0, 1, 0, 1},
  {&__pyx_n_s_version_2, __pyx_k_version_2, sizeof(__pyx_k_version_2), 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_u_wrap, __pyx_k_wrap, sizeof(__pyx_k_wrap), 0, 1, 0, 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_u_y_x, __pyx_k_y_x, sizeof(__pyx_k_y_x), 0, 1, 0, 0},
  {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 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_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 109, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 115, __pyx_L1_error)
  __pyx_builtin_chr = __Pyx_GetBuiltinName(__pyx_n_s_chr); if (!__pyx_builtin_chr) __PYX_ERR(0, 398, __pyx_L1_error)
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(0, 452, __pyx_L1_error)
  __pyx_builtin_DeprecationWarning = __Pyx_GetBuiltinName(__pyx_n_s_DeprecationWarning); if (!__pyx_builtin_DeprecationWarning) __PYX_ERR(0, 728, __pyx_L1_error)
  __pyx_builtin_NotImplemented = __Pyx_GetBuiltinName(__pyx_n_s_NotImplemented); if (!__pyx_builtin_NotImplemented) __PYX_ERR(0, 960, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 1176, __pyx_L1_error)
  __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 1335, __pyx_L1_error)
  __pyx_builtin_oct = __Pyx_GetBuiltinName(__pyx_n_s_oct); if (!__pyx_builtin_oct) __PYX_ERR(0, 1383, __pyx_L1_error)
  __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) __PYX_ERR(0, 1386, __pyx_L1_error)
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 1458, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 1711, __pyx_L1_error)
  __pyx_builtin_open = __Pyx_GetBuiltinName(__pyx_n_s_open); if (!__pyx_builtin_open) __PYX_ERR(0, 1782, __pyx_L1_error)
  __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 2977, __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":115
 *         for x in s:
 *             if x < 0:
 *                 raise ValueError('Negative dimensions are not allowed')             # <<<<<<<<<<<<<<
 *             self._shape.push_back(x)
 *         del s
 */
  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_Negative_dimensions_are_not_allo); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "cupy/core/core.pyx":125
 *         if strides is not None:
 *             if memptr is None:
 *                 raise ValueError('memptr is required if strides is given.')             # <<<<<<<<<<<<<<
 *             self._set_shape_and_strides(self._shape, strides, True, True)
 *         elif order_char == b'C':
 */
  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_memptr_is_required_if_strides_is); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "cupy/core/core.pyx":163
 *             desc['data'] = (self.data.ptr, False)
 *         else:
 *             desc['data'] = (0, False)             # <<<<<<<<<<<<<<
 * 
 *         return desc
 */
  __pyx_tuple__4 = PyTuple_Pack(2, __pyx_int_0, Py_False); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "cupy/core/core.pyx":297
 *         """
 *         if self.size != 1:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'can only convert an array of size 1 to a Python scalar')
 *         return self.get().item()
 */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_can_only_convert_an_array_of_siz); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "cupy/core/core.pyx":372
 *         # 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_u_casting_is_not_supported_yet); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "cupy/core/core.pyx":374
 *             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_u_subok_is_not_supported_yet); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "cupy/core/core.pyx":452
 *         newarray = _ndarray_init(x._shape, x.dtype)
 *         if not x._c_contiguous and not x._f_contiguous:
 *             raise NotImplementedError(             # <<<<<<<<<<<<<<
 *                 'CuPy cannot copy non-contiguous array between devices.')
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 */
  __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_CuPy_cannot_copy_non_contiguous); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 452, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "cupy/core/core.pyx":490
 *         ndim = self._shape.size()
 *         if 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_u_Changing_the_dtype_of_a_0d_array); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 490, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "cupy/core/core.pyx":494
 *                 '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_u_To_change_to_a_dtype_of_a_differ); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 494, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "cupy/core/core.pyx":516
 *         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_u_non_scalar_numpy_ndarray_cannot); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 516, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "cupy/core/core.pyx":726
 *         """
 *         if self.ndim == 0:
 *             warnings.warn(             # <<<<<<<<<<<<<<
 *                 'calling nonzero on 0d arrays is deprecated',
 *                 DeprecationWarning)
 */
  __pyx_tuple__13 = PyTuple_Pack(2, __pyx_kp_u_calling_nonzero_on_0d_arrays_is, __pyx_builtin_DeprecationWarning); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);

  /* "cupy/core/core.pyx":1153
 * 
 *     def __deepcopy__(self, memo):
 *         with self.device:             # <<<<<<<<<<<<<<
 *             return self.copy()
 * 
 */
  __pyx_tuple__14 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 1153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);
  __pyx_tuple__15 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 1153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "cupy/core/core.pyx":1175
 *     def __iter__(self):
 *         if self._shape.size() == 0:
 *             raise TypeError('iteration over a 0-d array')             # <<<<<<<<<<<<<<
 *         return (self[i] for i in range(self._shape[0]))
 * 
 */
  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_u_iteration_over_a_0_d_array); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 1175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "cupy/core/core.pyx":1180
 *     def __len__(self):
 *         if self._shape.size() == 0:
 *             raise TypeError('len() of unsized object')             # <<<<<<<<<<<<<<
 *         return self._shape[0]
 * 
 */
  __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_u_len_of_unsized_object); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 1180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "cupy/core/core.pyx":1257
 *         if util.ENABLE_SLICE_COPY and (
 *                 type(slices) is slice
 *                 and slices == slice(None, None, None)             # <<<<<<<<<<<<<<
 *                 and isinstance(value, numpy.ndarray)
 *         ):
 */
  __pyx_slice__18 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__18)) __PYX_ERR(0, 1257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__18);
  __Pyx_GIVEREF(__pyx_slice__18);

  /* "cupy/core/core.pyx":1273
 *                     self.data.copy_from_host_async(ptr, self.nbytes)
 *             else:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'copying a numpy.ndarray to a cupy.ndarray by empty slice '
 *                     'assignment must ensure arrays have same shape and dtype')
 */
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_u_copying_a_numpy_ndarray_to_a_cup); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 1273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);

  /* "cupy/core/core.pyx":1324
 *             out = kwargs['out']
 *             if len(out) != 1:
 *                 raise ValueError('The \'out\' parameter must have exactly one '             # <<<<<<<<<<<<<<
 *                                  'array value')
 *             kwargs['out'] = out[0]
 */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_u_The_out_parameter_must_have_exac); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 1324, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "cupy/core/core.pyx":1359
 *         try:
 *             module = functools.reduce(
 *                 getattr, func.__module__.split('.')[1:], cupy)             # <<<<<<<<<<<<<<
 *             cupy_func = getattr(module, func.__name__)
 *         except AttributeError:
 */
  __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_u__21); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 1359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);
  __pyx_slice__23 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__23)) __PYX_ERR(0, 1359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__23);
  __Pyx_GIVEREF(__pyx_slice__23);

  /* "cupy/core/core.pyx":1440
 *         if out is not None:
 *             if not isinstance(out, numpy.ndarray):
 *                 raise TypeError('Only numpy.ndarray can be obtained from'             # <<<<<<<<<<<<<<
 *                                 'cupy.ndarray')
 *             if self.dtype != out.dtype:
 */
  __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_u_Only_numpy_ndarray_can_be_obtain); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 1440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "cupy/core/core.pyx":1458
 *                         a_gpu = _internal_asfortranarray(self)
 *                     else:
 *                         raise RuntimeError(             # <<<<<<<<<<<<<<
 *                             '`out` cannot be specified when copying to '
 *                             'non-contiguous ndarray')
 */
  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_u_out_cannot_be_specified_when_co); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 1458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "cupy/core/core.pyx":1452
 *             if not (out.flags.c_contiguous and self._c_contiguous or
 *                     out.flags.f_contiguous and self._f_contiguous):
 *                 with self.device:             # <<<<<<<<<<<<<<
 *                     if out.flags.c_contiguous:
 *                         a_gpu = _internal_ascontiguousarray(self)
 */
  __pyx_tuple__26 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 1452, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "cupy/core/core.pyx":1476
 *             if not (order == 'C' and self._c_contiguous or
 *                     order == 'F' and self._f_contiguous):
 *                 with self.device:             # <<<<<<<<<<<<<<
 *                     if order == 'C':
 *                         a_gpu = _internal_ascontiguousarray(self)
 */
  __pyx_tuple__27 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 1476, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);

  /* "cupy/core/core.pyx":1489
 *         syncdetect._declare_synchronize()
 *         ptr = ctypes.c_void_p(a_cpu.__array_interface__['data'][0])
 *         with self.device:             # <<<<<<<<<<<<<<
 *             if stream is not None:
 *                 a_gpu.data.copy_to_host_async(ptr, a_gpu.nbytes, stream)
 */
  __pyx_tuple__28 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 1489, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);

  /* "cupy/core/core.pyx":1511
 *         """
 *         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__29 = PyTuple_Pack(1, __pyx_kp_u_Only_numpy_ndarray_can_be_set_to); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 1511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);

  /* "cupy/core/core.pyx":1524
 *             arr = numpy.asfortranarray(arr)
 *         else:
 *             raise RuntimeError('Cannot set to non-contiguous array')             # <<<<<<<<<<<<<<
 * 
 *         ptr = ctypes.c_void_p(arr.__array_interface__['data'][0])
 */
  __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_u_Cannot_set_to_non_contiguous_arr); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 1524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);

  /* "cupy/core/core.pyx":1527
 * 
 *         ptr = ctypes.c_void_p(arr.__array_interface__['data'][0])
 *         with self.device:             # <<<<<<<<<<<<<<
 *             if stream is not None:
 *                 self.data.copy_from_host_async(ptr, self.nbytes, stream)
 */
  __pyx_tuple__31 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 1527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);

  /* "cupy/core/core.pyx":1553
 *         cdef ndarray view
 *         if dtype is not None:
 *             warnings.warn(             # <<<<<<<<<<<<<<
 *                 'calling reduced_view with dtype is deprecated',
 *                 DeprecationWarning)
 */
  __pyx_tuple__32 = PyTuple_Pack(2, __pyx_kp_u_calling_reduced_view_with_dtype, __pyx_builtin_DeprecationWarning); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 1553, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);

  /* "cupy/core/core.pyx":1610
 *                                  bint update_f_contiguity):
 *         if shape.size() != strides.size():
 *             raise ValueError('len(shape) != len(strides)')             # <<<<<<<<<<<<<<
 *         self._shape = shape
 *         self._strides = strides
 */
  __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_u_len_shape_len_strides); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 1610, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);

  /* "cupy/core/core.pyx":1782
 *         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__34 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 1782, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);

  /* "cupy/core/core.pyx":1840
 * 
 *         if bundled_include is None and cuda_path is None:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 'Failed to auto-detect CUDA root directory. '
 *                 'Please specify `CUDA_PATH` environment variable if you '
 */
  __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_u_Failed_to_auto_detect_CUDA_root); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 1840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);

  /* "cupy/core/core.pyx":1980
 *                 # When `copy` is False, `a` is same as `obj`.
 *                 a = a.view()
 *             a.shape = (1,) * (ndmin - ndim) + a.shape             # <<<<<<<<<<<<<<
 *     elif hasattr(obj, '__cuda_array_interface__'):
 *         return array(_convert_object_with_cuda_array_interface(obj),
 */
  __pyx_tuple__37 = PyTuple_New(1); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 1980, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__37, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__37);

  /* "cupy/core/core.pyx":1998
 *             ndim = len(shape)
 *             if ndmin > ndim:
 *                 shape = (1,) * (ndmin - ndim) + shape             # <<<<<<<<<<<<<<
 * 
 *             if dtype is None:
 */
  __pyx_tuple__38 = PyTuple_New(1); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 1998, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__38, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__38);

  /* "cupy/core/core.pyx":2046
 *     if isinstance(obj, (list, tuple)):
 *         return _get_concat_shape_impl(obj)
 *     return (None, None, None)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__39 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 2046, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);

  /* "cupy/core/core.pyx":2117
 *     if mem is not None:
 *         src_cpu = numpy.frombuffer(mem, a_dtype, a_cpu.size)
 *         src_cpu[:] = a_cpu.ravel(order)             # <<<<<<<<<<<<<<
 *         a.data.copy_from_host_async(ctypes.c_void_p(mem.ptr), nbytes)
 *         pinned_memory._add_to_watch_list(stream.record(), mem)
 */
  __pyx_slice__40 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__40)) __PYX_ERR(0, 2117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__40);
  __Pyx_GIVEREF(__pyx_slice__40);

  /* "cupy/core/core.pyx":2183
 *         numpy.concatenate(arrays, axis, out)
 *     else:
 *         out[:] = numpy.concatenate(arrays, axis)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_slice__41 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__41)) __PYX_ERR(0, 2183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__41);
  __Pyx_GIVEREF(__pyx_slice__41);

  /* "cupy/core/core.pyx":2256
 *         return a
 * 
 *     shape = (1,) if zero_dim else a.shape             # <<<<<<<<<<<<<<
 *     newarray = ndarray(shape, dtype)
 *     elementwise_copy(a, newarray)
 */
  __pyx_tuple__42 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 2256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "cupy/core/core.pyx":2283
 *         return _internal_asfortranarray(a)
 * 
 *     newarray = ndarray((1,) if zero_dim else a.shape, dtype, order='F')             # <<<<<<<<<<<<<<
 *     elementwise_copy(a, newarray)
 *     return newarray
 */
  __pyx_tuple__43 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 2283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);

  /* "cupy/core/core.pyx":2293
 * 
 * cpdef _create_bit_op(name, op, no_bool, doc=''):
 *     types = () if no_bool else ('??->?',)             # <<<<<<<<<<<<<<
 *     return create_ufunc(
 *         'cupy_' + name,
 */
  __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_u__44); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 2293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);

  /* "cupy/core/core.pyx":2296
 *     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__46 = PyTuple_Pack(10, __pyx_kp_u_bb_b, __pyx_kp_u_BB_B, __pyx_kp_u_hh_h, __pyx_kp_u_HH_H, __pyx_kp_u_ii_i, __pyx_kp_u_II_I, __pyx_kp_u_ll_l, __pyx_kp_u_LL_L, __pyx_kp_u_qq_q, __pyx_kp_u_QQ_Q); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 2296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);

  /* "cupy/core/core.pyx":2388
 * 
 *     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__47 = PyTuple_Pack(1, __pyx_kp_u_Not_supported_dtype_combination); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 2388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);

  /* "cupy/core/core.pyx":2412
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:
 *         raise ValueError('Axis dimension mismatch')             # <<<<<<<<<<<<<<
 * 
 *     if a_axis:
 */
  __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_u_Axis_dimension_mismatch); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 2412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);

  /* "cupy/core/core.pyx":2435
 *     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__49 = PyTuple_Pack(1, __pyx_kp_u_Output_array_has_an_invalid_size); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 2435, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);

  /* "cupy/core/core.pyx":2437
 *             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__50 = PyTuple_Pack(1, __pyx_kp_u_Output_array_must_be_C_contiguou); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 2437, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);

  /* "cupy/core/core.pyx":2468
 *     for i in range(1, ndim - 2):
 *         idx = _mat_ptrs_kernel(
 *             idx[:, None], a._strides[i],             # <<<<<<<<<<<<<<
 *             ndarray((idx.size, a._shape[i]), dtype=numpy.uintp))
 *         idx = idx.ravel()
 */
  __pyx_slice__51 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__51)) __PYX_ERR(0, 2468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__51);
  __Pyx_GIVEREF(__pyx_slice__51);
  __pyx_tuple__52 = PyTuple_Pack(2, __pyx_slice__51, Py_None); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 2468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);

  /* "cupy/core/core.pyx":2503
 * 
 *     if out is not None:
 *         raise NotImplementedError('The out array as input is currently not '             # <<<<<<<<<<<<<<
 *                                   'supported')
 * 
 */
  __pyx_tuple__53 = PyTuple_Pack(1, __pyx_kp_u_The_out_array_as_input_is_curren); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 2503, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__53);
  __Pyx_GIVEREF(__pyx_tuple__53);

  /* "cupy/core/core.pyx":2515
 *     orig_b_ndim = b._shape.size()
 *     if orig_a_ndim == 0 or orig_b_ndim == 0:
 *         raise ValueError('Scalar operands are not allowed, use \'*\' instead')             # <<<<<<<<<<<<<<
 * 
 *     ndim = max(orig_a_ndim, orig_b_ndim)
 */
  __pyx_tuple__54 = PyTuple_Pack(1, __pyx_kp_u_Scalar_operands_are_not_allowed); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 2515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__54);
  __Pyx_GIVEREF(__pyx_tuple__54);

  /* "cupy/core/core.pyx":2542
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 *         a._set_shape_and_strides(
 *             (1,) * (ndim - a_ndim) + a.shape,             # <<<<<<<<<<<<<<
 *             (0,) * (ndim - a_ndim) + a.strides,
 *             True, True)
 */
  __pyx_tuple__55 = PyTuple_New(1); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 2542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__55, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__55);

  /* "cupy/core/core.pyx":2543
 *         a._set_shape_and_strides(
 *             (1,) * (ndim - a_ndim) + a.shape,
 *             (0,) * (ndim - a_ndim) + a.strides,             # <<<<<<<<<<<<<<
 *             True, True)
 *     if b_ndim < ndim:
 */
  __pyx_tuple__56 = PyTuple_New(1); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(0, 2543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__56);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_tuple__56, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_tuple__56);

  /* "cupy/core/core.pyx":2548
 *         # TODO(niboshi): Confirm update_x_contiguity flags
 *         b._set_shape_and_strides(
 *             (1,) * (ndim - b_ndim) + b.shape,             # <<<<<<<<<<<<<<
 *             (0,) * (ndim - b_ndim) + b.strides,
 *             True, True)
 */
  __pyx_tuple__57 = PyTuple_New(1); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 2548, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__57, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__57);

  /* "cupy/core/core.pyx":2549
 *         b._set_shape_and_strides(
 *             (1,) * (ndim - b_ndim) + b.shape,
 *             (0,) * (ndim - b_ndim) + b.strides,             # <<<<<<<<<<<<<<
 *             True, True)
 * 
 */
  __pyx_tuple__58 = PyTuple_New(1); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(0, 2549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_tuple__58, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_tuple__58);

  /* "cupy/core/core.pyx":2566
 *         b_sh = b._shape[i]
 *         if a_sh != b_sh and a_sh != 1 and b_sh != 1:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'operands could not be broadcast together with '
 *                 'remapped shapes')
 */
  __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_u_operands_could_not_be_broadcast); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 2566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);

  /* "cupy/core/core.pyx":2888
 * 
 *     if no_complex_dtype:
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',             # <<<<<<<<<<<<<<
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 *     else:
 */
  __pyx_tuple__61 = PyTuple_Pack(14, __pyx_kp_u__44, __pyx_kp_u_bb, __pyx_kp_u_BB, __pyx_kp_u_hh, __pyx_kp_u_HH, __pyx_kp_u_ii, __pyx_kp_u_II, __pyx_kp_u_ll, __pyx_kp_u_LL, __pyx_kp_u_qq, __pyx_kp_u_QQ, __pyx_kp_u_ee, __pyx_kp_u_ff, __pyx_kp_u_dd); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 2888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);

  /* "cupy/core/core.pyx":2891
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?')
 *     else:
 *         ops = ('??->?', 'bb->?', 'BB->?', 'hh->?', 'HH->?', 'ii->?', 'II->?',             # <<<<<<<<<<<<<<
 *                'll->?', 'LL->?', 'qq->?', 'QQ->?', 'ee->?', 'ff->?', 'dd->?',
 *                'FF->?', 'DD->?')
 */
  __pyx_tuple__62 = PyTuple_Pack(16, __pyx_kp_u__44, __pyx_kp_u_bb, __pyx_kp_u_BB, __pyx_kp_u_hh, __pyx_kp_u_HH, __pyx_kp_u_ii, __pyx_kp_u_II, __pyx_kp_u_ll, __pyx_kp_u_LL, __pyx_kp_u_qq, __pyx_kp_u_QQ, __pyx_kp_u_ee, __pyx_kp_u_ff, __pyx_kp_u_dd, __pyx_kp_u_FF, __pyx_kp_u_DD); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(0, 2891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__62);
  __Pyx_GIVEREF(__pyx_tuple__62);

  /* "cupy/core/core.pyx":2971
 *     ptr = desc['data'][0]
 *     dtype = numpy.dtype(desc['typestr'])
 *     mask = desc.get('mask')             # <<<<<<<<<<<<<<
 *     if mask is not None:
 *         raise ValueError('CuPy currently does not support masked arrays.')
 */
  __pyx_tuple__63 = PyTuple_Pack(1, __pyx_n_u_mask); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 2971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);

  /* "cupy/core/core.pyx":2973
 *     mask = desc.get('mask')
 *     if mask is not None:
 *         raise ValueError('CuPy currently does not support masked arrays.')             # <<<<<<<<<<<<<<
 *     strides = desc.get('strides')
 *     if strides is not None:
 */
  __pyx_tuple__64 = PyTuple_Pack(1, __pyx_kp_u_CuPy_currently_does_not_support); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(0, 2973, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__64);
  __Pyx_GIVEREF(__pyx_tuple__64);

  /* "cupy/core/core.pyx":2974
 *     if mask is not None:
 *         raise ValueError('CuPy currently does not support masked arrays.')
 *     strides = desc.get('strides')             # <<<<<<<<<<<<<<
 *     if strides is not None:
 *         nbytes = 0
 */
  __pyx_tuple__65 = PyTuple_Pack(1, __pyx_n_u_strides); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(0, 2974, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);

  /* "cupy/core/core.pyx":1864
 * cdef str _id = 'out0 = in0'
 * 
 * cdef fill_kernel = ElementwiseKernel('T x', 'T y', 'y = x', 'fill')             # <<<<<<<<<<<<<<
 * 
 * cdef str _divmod_float = '''
 */
  __pyx_tuple__69 = PyTuple_Pack(4, __pyx_kp_u_T_x, __pyx_kp_u_T_y, __pyx_kp_u_y_x, __pyx_n_u_fill); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(0, 1864, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__69);
  __Pyx_GIVEREF(__pyx_tuple__69);

  /* "cupy/core/core.pyx":2337
 * 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__74 = PyTuple_Pack(2, __pyx_kp_u__73, __pyx_kp_u_out0_in0_2); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(0, 2337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__74);
  __Pyx_GIVEREF(__pyx_tuple__74);
  __pyx_tuple__75 = PyTuple_Pack(11, __pyx_tuple__74, __pyx_kp_u_b_b, __pyx_kp_u_B_B, __pyx_kp_u_h_h, __pyx_kp_u_H_H, __pyx_kp_u_i_i, __pyx_kp_u_I_I, __pyx_kp_u_l_l, __pyx_kp_u_L_L, __pyx_kp_u_q_q, __pyx_kp_u_Q_Q); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(0, 2337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__75);
  __Pyx_GIVEREF(__pyx_tuple__75);

  /* "cupy/core/core.pyx":2335
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_tuple__76 = PyTuple_Pack(3, __pyx_n_u_cupy_invert, __pyx_tuple__75, __pyx_kp_u_out0_in0_3); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(0, 2335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);

  /* "cupy/core/core.pyx":2442
 * 
 * 
 * cdef _mat_ptrs_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'T base, T stride', 'T out',
 *     'out = base + _ind.get()[_ind.ndim - 1] * stride', 'mat_ptrs',
 */
  __pyx_tuple__79 = PyTuple_Pack(4, __pyx_kp_u_T_base_T_stride, __pyx_kp_u_T_out, __pyx_kp_u_out_base__ind_get__ind_ndim_1_st, __pyx_n_u_mat_ptrs); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 2442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);

  /* "cupy/core/core.pyx":2730
 * 
 * cdef int _cuda_runtime_version = -1
 * cdef _tensordot_core_mul_sum = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T y', 'U out',
 *     'static_cast<U>(x) * static_cast<U>(y)',
 */
  __pyx_tuple__80 = PyTuple_Pack(7, __pyx_kp_u_S_x_T_y, __pyx_kp_u_U_out, __pyx_kp_u_static_cast_U_x_static_cast_U_y, __pyx_kp_u_a_b, __pyx_kp_u_out_a, __pyx_kp_u_0, __pyx_n_u_tensordot_core_mul_sum); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(0, 2730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__80);
  __Pyx_GIVEREF(__pyx_tuple__80);
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __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_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static 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__HANDLED_TYPES = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __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__id = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core_fill_kernel = 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__round_preamble = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__round_float = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__round_complex = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__mat_ptrs_kernel = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4core_4core__tensordot_core_mul_sum = Py_None; Py_INCREF(Py_None);
  __pyx_8genexpr3__pyx_v_4cupy_4core_4core_i = 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("_internal_ascontiguousarray", (void (*)(void))__pyx_f_4cupy_4core_4core__internal_ascontiguousarray, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportFunction("_internal_asfortranarray", (void (*)(void))__pyx_f_4cupy_4core_4core__internal_asfortranarray, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  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)
  if (__Pyx_ExportFunction("asfortranarray", (void (*)(void))__pyx_f_4cupy_4core_4core_asfortranarray, "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_asfortranarray *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportFunction("compile_with_cache", (void (*)(void))__pyx_f_4cupy_4core_4core_compile_with_cache, "struct __pyx_obj_4cupy_4cuda_8function_Module *(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportFunction("array", (void (*)(void))__pyx_f_4cupy_4core_4core_array, "struct __pyx_obj_4cupy_4core_4core_ndarray *(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_array *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportFunction("_convert_object_with_cuda_array_interface", (void (*)(void))__pyx_f_4cupy_4core_4core__convert_object_with_cuda_array_interface, "struct __pyx_obj_4cupy_4core_4core_ndarray *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportFunction("_ndarray_init", (void (*)(void))__pyx_f_4cupy_4core_4core__ndarray_init, "struct __pyx_obj_4cupy_4core_4core_ndarray *(std::vector<Py_ssize_t>  const &, PyObject *)") < 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._init_fast = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  const &, PyObject *, int))__pyx_f_4cupy_4core_4core_7ndarray__init_fast;
  __pyx_vtable_4cupy_4core_4core_ndarray.item = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_item;
  __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.tobytes = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tobytes *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_tobytes;
  __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.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, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_ravel *__pyx_optional_args))__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.put = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_put *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_put;
  __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.sort = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sort *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_sort;
  __pyx_vtable_4cupy_4core_4core_ndarray.argsort = (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_argsort *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_argsort;
  __pyx_vtable_4cupy_4core_4core_ndarray.partition = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_partition *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_partition;
  __pyx_vtable_4cupy_4core_4core_ndarray.argpartition = (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_argpartition *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_argpartition;
  __pyx_vtable_4cupy_4core_4core_ndarray.nonzero = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_nonzero;
  __pyx_vtable_4cupy_4core_4core_ndarray.compress = (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_compress *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_compress;
  __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.ptp = (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_ptp *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_ptp;
  __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.round = (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_round *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_round;
  __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.cumsum = (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_cumsum *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_cumsum;
  __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.cumprod = (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_cumprod *__pyx_optional_args))__pyx_f_4cupy_4core_4core_7ndarray_cumprod;
  __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.conjugate = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_conjugate;
  __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>  const &, std::vector<Py_ssize_t>  const &, int, int, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray__set_shape_and_strides;
  __pyx_vtable_4cupy_4core_4core_ndarray._view = (struct __pyx_obj_4cupy_4core_4core_ndarray *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  const &, std::vector<Py_ssize_t>  const &, int, int))__pyx_f_4cupy_4core_4core_7ndarray__view;
  __pyx_vtable_4cupy_4core_4core_ndarray._set_contiguous_strides = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, int, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray__set_contiguous_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;
  __pyx_vtable_4cupy_4core_4core_ndarray.toDlpack = (PyObject *(*)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch))__pyx_f_4cupy_4core_4core_7ndarray_toDlpack;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core_ndarray) < 0) __PYX_ERR(0, 64, __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, 64, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_4cupy_4core_4core_7ndarray_174__getitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_4cupy_4core_4core_7ndarray_174__getitem__.doc = __pyx_doc_4cupy_4core_4core_7ndarray_174__getitem__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4cupy_4core_4core_7ndarray_174__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, 64, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_4cupy_4core_4core_7ndarray_176__setitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_4cupy_4core_4core_7ndarray_176__setitem__.doc = __pyx_doc_4cupy_4core_4core_7ndarray_176__setitem__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4cupy_4core_4core_7ndarray_176__setitem__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_4cupy_4core_4core_ndarray.tp_dict, __pyx_vtabptr_4cupy_4core_4core_ndarray) < 0) __PYX_ERR(0, 64, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "ndarray", (PyObject *)&__pyx_type_4cupy_4core_4core_ndarray) < 0) __PYX_ERR(0, 64, __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;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct____iter__) < 0) __PYX_ERR(0, 1173, __pyx_L1_error)
  __pyx_type_4cupy_4core_4core___pyx_scope_struct____iter__.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_4core_4core___pyx_scope_struct____iter__.tp_dictoffset && __pyx_type_4cupy_4core_4core___pyx_scope_struct____iter__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_4core_4core___pyx_scope_struct____iter__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4cupy_4core_4core___pyx_scope_struct____iter__ = &__pyx_type_4cupy_4core_4core___pyx_scope_struct____iter__;
  if (PyType_Ready(&__pyx_type_4cupy_4core_4core___pyx_scope_struct_1_genexpr) < 0) __PYX_ERR(0, 1176, __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;
  __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_Handle = __Pyx_ImportType("cupy.cuda.device", "Handle", sizeof(struct __pyx_obj_4cupy_4cuda_6device_Handle), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6device_Handle)) __PYX_ERR(3, 7, __pyx_L1_error)
  __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(3, 12, __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(3, 12, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_BaseMemory = __Pyx_ImportType("cupy.cuda.memory", "BaseMemory", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_BaseMemory), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_BaseMemory)) __PYX_ERR(4, 11, __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(4, 20, __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(4, 20, __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(4, 52, __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(4, 52, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocatorMemory = __Pyx_ImportType("cupy.cuda.memory", "CFunctionAllocatorMemory", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_CFunctionAllocatorMemory), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocatorMemory)) __PYX_ERR(4, 69, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocator = __Pyx_ImportType("cupy.cuda.memory", "CFunctionAllocator", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_CFunctionAllocator), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocator)) __PYX_ERR(4, 76, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6memory_CFunctionAllocator = (struct __pyx_vtabstruct_4cupy_4cuda_6memory_CFunctionAllocator*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocator->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6memory_CFunctionAllocator)) __PYX_ERR(4, 76, __pyx_L1_error)
  __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(5, 4, __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(5, 8, __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(5, 8, __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(5, 18, __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(5, 18, __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(5, 30, __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(5, 30, __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(6, 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(7, 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(8, 15, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_7_carray_CArray = __Pyx_ImportType("cupy.core._carray", "CArray", sizeof(struct __pyx_obj_4cupy_4core_7_carray_CArray), 1); if (unlikely(!__pyx_ptype_4cupy_4core_7_carray_CArray)) __PYX_ERR(9, 17, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4core_7_carray_CArray = (struct __pyx_vtabstruct_4cupy_4core_7_carray_CArray*)__Pyx_GetVtable(__pyx_ptype_4cupy_4core_7_carray_CArray->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4core_7_carray_CArray)) __PYX_ERR(9, 17, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_7_carray_CIndexer = __Pyx_ImportType("cupy.core._carray", "CIndexer", sizeof(struct __pyx_obj_4cupy_4core_7_carray_CIndexer), 1); if (unlikely(!__pyx_ptype_4cupy_4core_7_carray_CIndexer)) __PYX_ERR(9, 33, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_7_carray_Indexer = __Pyx_ImportType("cupy.core._carray", "Indexer", sizeof(struct __pyx_obj_4cupy_4core_7_carray_Indexer), 1); if (unlikely(!__pyx_ptype_4cupy_4core_7_carray_Indexer)) __PYX_ERR(9, 38, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4core_7_carray_Indexer = (struct __pyx_vtabstruct_4cupy_4core_7_carray_Indexer*)__Pyx_GetVtable(__pyx_ptype_4cupy_4core_7_carray_Indexer->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4core_7_carray_Indexer)) __PYX_ERR(9, 38, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_7_scalar_CScalar = __Pyx_ImportType("cupy.core._scalar", "CScalar", sizeof(struct __pyx_obj_4cupy_4core_7_scalar_CScalar), 1); if (unlikely(!__pyx_ptype_4cupy_4core_7_scalar_CScalar)) __PYX_ERR(10, 10, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4core_7_scalar_CScalar = (struct __pyx_vtabstruct_4cupy_4core_7_scalar_CScalar*)__Pyx_GetVtable(__pyx_ptype_4cupy_4core_7_scalar_CScalar->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4core_7_scalar_CScalar)) __PYX_ERR(10, 10, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_7_kernel_ParameterInfo = __Pyx_ImportType("cupy.core._kernel", "ParameterInfo", sizeof(struct __pyx_obj_4cupy_4core_7_kernel_ParameterInfo), 1); if (unlikely(!__pyx_ptype_4cupy_4core_7_kernel_ParameterInfo)) __PYX_ERR(11, 8, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_7_kernel__ArgInfo = __Pyx_ImportType("cupy.core._kernel", "_ArgInfo", sizeof(struct __pyx_obj_4cupy_4core_7_kernel__ArgInfo), 1); if (unlikely(!__pyx_ptype_4cupy_4core_7_kernel__ArgInfo)) __PYX_ERR(11, 23, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4core_7_kernel__ArgInfo = (struct __pyx_vtabstruct_4cupy_4core_7_kernel__ArgInfo*)__Pyx_GetVtable(__pyx_ptype_4cupy_4core_7_kernel__ArgInfo->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4core_7_kernel__ArgInfo)) __PYX_ERR(11, 23, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_7_kernel__TypeMap = __Pyx_ImportType("cupy.core._kernel", "_TypeMap", sizeof(struct __pyx_obj_4cupy_4core_7_kernel__TypeMap), 1); if (unlikely(!__pyx_ptype_4cupy_4core_7_kernel__TypeMap)) __PYX_ERR(11, 59, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4core_7_kernel__TypeMap = (struct __pyx_vtabstruct_4cupy_4core_7_kernel__TypeMap*)__Pyx_GetVtable(__pyx_ptype_4cupy_4core_7_kernel__TypeMap->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4core_7_kernel__TypeMap)) __PYX_ERR(11, 59, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_7_kernel__Op = __Pyx_ImportType("cupy.core._kernel", "_Op", sizeof(struct __pyx_obj_4cupy_4core_7_kernel__Op), 1); if (unlikely(!__pyx_ptype_4cupy_4core_7_kernel__Op)) __PYX_ERR(11, 69, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4core_7_kernel__Op = (struct __pyx_vtabstruct_4cupy_4core_7_kernel__Op*)__Pyx_GetVtable(__pyx_ptype_4cupy_4core_7_kernel__Op->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4core_7_kernel__Op)) __PYX_ERR(11, 69, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_7_kernel__Ops = __Pyx_ImportType("cupy.core._kernel", "_Ops", sizeof(struct __pyx_obj_4cupy_4core_7_kernel__Ops), 1); if (unlikely(!__pyx_ptype_4cupy_4core_7_kernel__Ops)) __PYX_ERR(11, 101, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4core_7_kernel__Ops = (struct __pyx_vtabstruct_4cupy_4core_7_kernel__Ops*)__Pyx_GetVtable(__pyx_ptype_4cupy_4core_7_kernel__Ops->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4core_7_kernel__Ops)) __PYX_ERR(11, 101, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_22_routines_manipulation_broadcast = __Pyx_ImportType("cupy.core._routines_manipulation", "broadcast", sizeof(struct __pyx_obj_4cupy_4core_22_routines_manipulation_broadcast), 1); if (unlikely(!__pyx_ptype_4cupy_4core_22_routines_manipulation_broadcast)) __PYX_ERR(12, 6, __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(13, 4, __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(13, 4, __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(13, 24, __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(13, 24, __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(14, 8, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("cupy.core._routines_math"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_sum_auto_dtype", (void **)&__pyx_vp_4cupy_4core_14_routines_math__sum_auto_dtype, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_add", (void **)&__pyx_vp_4cupy_4core_14_routines_math__add, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_conj", (void **)&__pyx_vp_4cupy_4core_14_routines_math__conj, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_angle", (void **)&__pyx_vp_4cupy_4core_14_routines_math__angle, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_real", (void **)&__pyx_vp_4cupy_4core_14_routines_math__real, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_imag", (void **)&__pyx_vp_4cupy_4core_14_routines_math__imag, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_negative", (void **)&__pyx_vp_4cupy_4core_14_routines_math__negative, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_multiply", (void **)&__pyx_vp_4cupy_4core_14_routines_math__multiply, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_divide", (void **)&__pyx_vp_4cupy_4core_14_routines_math__divide, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_power", (void **)&__pyx_vp_4cupy_4core_14_routines_math__power, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_subtract", (void **)&__pyx_vp_4cupy_4core_14_routines_math__subtract, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_true_divide", (void **)&__pyx_vp_4cupy_4core_14_routines_math__true_divide, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_floor_divide", (void **)&__pyx_vp_4cupy_4core_14_routines_math__floor_divide, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_remainder", (void **)&__pyx_vp_4cupy_4core_14_routines_math__remainder, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_absolute", (void **)&__pyx_vp_4cupy_4core_14_routines_math__absolute, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_sqrt", (void **)&__pyx_vp_4cupy_4core_14_routines_math__sqrt, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = __Pyx_ImportModule("cupy.cuda.runtime"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_2, "_is_hip_environment", (void **)&__pyx_vp_4cupy_4cuda_7runtime__is_hip_environment, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_2, "deviceAttributeComputeCapabilityMajor", (void **)&__pyx_vp_4cupy_4cuda_7runtime_deviceAttributeComputeCapabilityMajor, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_2, "deviceAttributeComputeCapabilityMinor", (void **)&__pyx_vp_4cupy_4cuda_7runtime_deviceAttributeComputeCapabilityMinor, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_RefNannyFinishContext();
  return -1;
}

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;
  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;
  PyObject *__pyx_t_15 = NULL;
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("cupy.cuda.memory"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "alloc", (void (**)(void))&__pyx_f_4cupy_4cuda_6memory_alloc, "struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *(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.core._dtype"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_2, "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)
  if (__Pyx_ImportFunction(__pyx_t_2, "get_dtype_with_itemsize", (void (**)(void))&__pyx_f_4cupy_4core_6_dtype_get_dtype_with_itemsize, "PyObject *(PyObject *, 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._kernel"); if (!__pyx_t_3) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "create_ufunc", (void (**)(void))&__pyx_f_4cupy_4core_7_kernel_create_ufunc, "PyObject *(PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_7_kernel_create_ufunc *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_ImportModule("cupy.core._routines_indexing"); if (!__pyx_t_4) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "_ndarray_getitem", (void (**)(void))&__pyx_f_4cupy_4core_18_routines_indexing__ndarray_getitem, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "_ndarray_setitem", (void (**)(void))&__pyx_f_4cupy_4core_18_routines_indexing__ndarray_setitem, "PyObject *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "_ndarray_nonzero", (void (**)(void))&__pyx_f_4cupy_4core_18_routines_indexing__ndarray_nonzero, "PyObject *(struct __pyx_obj_4cupy_4core_4core_ndarray *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "_ndarray_scatter_add", (void (**)(void))&__pyx_f_4cupy_4core_18_routines_indexing__ndarray_scatter_add, "PyObject *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "_ndarray_scatter_max", (void (**)(void))&__pyx_f_4cupy_4core_18_routines_indexing__ndarray_scatter_max, "PyObject *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "_ndarray_scatter_min", (void (**)(void))&__pyx_f_4cupy_4core_18_routines_indexing__ndarray_scatter_min, "PyObject *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "_ndarray_take", (void (**)(void))&__pyx_f_4cupy_4core_18_routines_indexing__ndarray_take, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "_ndarray_put", (void (**)(void))&__pyx_f_4cupy_4core_18_routines_indexing__ndarray_put, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "_ndarray_choose", (void (**)(void))&__pyx_f_4cupy_4core_18_routines_indexing__ndarray_choose, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "_ndarray_compress", (void (**)(void))&__pyx_f_4cupy_4core_18_routines_indexing__ndarray_compress, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_4, "_ndarray_diagonal", (void (**)(void))&__pyx_f_4cupy_4core_18_routines_indexing__ndarray_diagonal, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __Pyx_ImportModule("cupy.core._routines_logic"); if (!__pyx_t_5) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_5, "_ndarray_all", (void (**)(void))&__pyx_f_4cupy_4core_15_routines_logic__ndarray_all, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_5, "_ndarray_any", (void (**)(void))&__pyx_f_4cupy_4core_15_routines_logic__ndarray_any, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_ImportModule("cupy.core._routines_manipulation"); if (!__pyx_t_6) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "_ndarray_shape_setter", (void (**)(void))&__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_shape_setter, "PyObject *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "_ndarray_reshape", (void (**)(void))&__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_reshape, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "_ndarray_transpose", (void (**)(void))&__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_transpose, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "_ndarray_swapaxes", (void (**)(void))&__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_swapaxes, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, Py_ssize_t)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "_ndarray_flatten", (void (**)(void))&__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_flatten, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "_ndarray_ravel", (void (**)(void))&__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_ravel, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "_ndarray_squeeze", (void (**)(void))&__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_squeeze, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "_ndarray_repeat", (void (**)(void))&__pyx_f_4cupy_4core_22_routines_manipulation__ndarray_repeat, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "rollaxis", (void (**)(void))&__pyx_f_4cupy_4core_22_routines_manipulation_rollaxis, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_22_routines_manipulation_rollaxis *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "_reshape", (void (**)(void))&__pyx_f_4cupy_4core_22_routines_manipulation__reshape, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  const &, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "_T", (void (**)(void))&__pyx_f_4cupy_4core_22_routines_manipulation__T, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_6, "concatenate_method", (void (**)(void))&__pyx_f_4cupy_4core_22_routines_manipulation_concatenate_method, "struct __pyx_obj_4cupy_4core_4core_ndarray *(PyObject *, int, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_22_routines_manipulation_concatenate_method *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_7 = __Pyx_ImportModule("cupy.core._routines_math"); if (!__pyx_t_7) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_7, "_ndarray_conj", (void (**)(void))&__pyx_f_4cupy_4core_14_routines_math__ndarray_conj, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_7, "_ndarray_real_getter", (void (**)(void))&__pyx_f_4cupy_4core_14_routines_math__ndarray_real_getter, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_7, "_ndarray_real_setter", (void (**)(void))&__pyx_f_4cupy_4core_14_routines_math__ndarray_real_setter, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_7, "_ndarray_imag_getter", (void (**)(void))&__pyx_f_4cupy_4core_14_routines_math__ndarray_imag_getter, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_7, "_ndarray_imag_setter", (void (**)(void))&__pyx_f_4cupy_4core_14_routines_math__ndarray_imag_setter, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_7, "_ndarray_prod", (void (**)(void))&__pyx_f_4cupy_4core_14_routines_math__ndarray_prod, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_7, "_ndarray_sum", (void (**)(void))&__pyx_f_4cupy_4core_14_routines_math__ndarray_sum, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_7, "_ndarray_cumsum", (void (**)(void))&__pyx_f_4cupy_4core_14_routines_math__ndarray_cumsum, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_7, "_ndarray_cumprod", (void (**)(void))&__pyx_f_4cupy_4core_14_routines_math__ndarray_cumprod, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_7, "_ndarray_clip", (void (**)(void))&__pyx_f_4cupy_4core_14_routines_math__ndarray_clip, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_8 = __Pyx_ImportModule("cupy.core._routines_sorting"); if (!__pyx_t_8) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_8, "_ndarray_sort", (void (**)(void))&__pyx_f_4cupy_4core_17_routines_sorting__ndarray_sort, "PyObject *(struct __pyx_obj_4cupy_4core_4core_ndarray *, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_8, "_ndarray_argsort", (void (**)(void))&__pyx_f_4cupy_4core_17_routines_sorting__ndarray_argsort, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_8, "_ndarray_partition", (void (**)(void))&__pyx_f_4cupy_4core_17_routines_sorting__ndarray_partition, "PyObject *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_8, "_ndarray_argpartition", (void (**)(void))&__pyx_f_4cupy_4core_17_routines_sorting__ndarray_argpartition, "struct __pyx_obj_4cupy_4core_4core_ndarray *(PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_9 = __Pyx_ImportModule("cupy.core._routines_statistics"); if (!__pyx_t_9) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_9, "_ndarray_max", (void (**)(void))&__pyx_f_4cupy_4core_20_routines_statistics__ndarray_max, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_9, "_ndarray_min", (void (**)(void))&__pyx_f_4cupy_4core_20_routines_statistics__ndarray_min, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_9, "_ndarray_ptp", (void (**)(void))&__pyx_f_4cupy_4core_20_routines_statistics__ndarray_ptp, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_9, "_ndarray_argmax", (void (**)(void))&__pyx_f_4cupy_4core_20_routines_statistics__ndarray_argmax, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_9, "_ndarray_argmin", (void (**)(void))&__pyx_f_4cupy_4core_20_routines_statistics__ndarray_argmin, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_9, "_ndarray_mean", (void (**)(void))&__pyx_f_4cupy_4core_20_routines_statistics__ndarray_mean, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_9, "_ndarray_var", (void (**)(void))&__pyx_f_4cupy_4core_20_routines_statistics__ndarray_var, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_9, "_ndarray_std", (void (**)(void))&__pyx_f_4cupy_4core_20_routines_statistics__ndarray_std, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_10 = __Pyx_ImportModule("cupy.core.dlpack"); if (!__pyx_t_10) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_10, "toDlpack", (void (**)(void))&__pyx_f_4cupy_4core_6dlpack_toDlpack, "PyObject *(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_11 = __Pyx_ImportModule("cupy.core.internal"); if (!__pyx_t_11) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_11, "prod", (void (**)(void))&__pyx_f_4cupy_4core_8internal_prod, "Py_ssize_t (std::vector<Py_ssize_t>  const &, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_11, "prod_sequence", (void (**)(void))&__pyx_f_4cupy_4core_8internal_prod_sequence, "Py_ssize_t (PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_11, "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_11, "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_11, "get_contiguous_strides_inplace", (void (**)(void))&__pyx_f_4cupy_4core_8internal_get_contiguous_strides_inplace, "Py_ssize_t (std::vector<Py_ssize_t>  const &, std::vector<Py_ssize_t>  &, Py_ssize_t, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_11, "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_11, "_normalize_order", (void (**)(void))&__pyx_f_4cupy_4core_8internal__normalize_order, "int (PyObject *, struct __pyx_opt_args_4cupy_4core_8internal__normalize_order *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_12 = __Pyx_ImportModule("cupy.cuda.cublas"); if (!__pyx_t_12) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_12, "setMathMode", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_setMathMode, "PyObject *(intptr_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_12, "dgemm", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_dgemm, "PyObject *(intptr_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_12, "cgemm", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_cgemm, "PyObject *(intptr_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_12, "zgemm", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_zgemm, "PyObject *(intptr_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_12, "sgemmBatched", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_sgemmBatched, "PyObject *(intptr_t, int, int, int, int, int, float, size_t, int, size_t, int, float, size_t, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_12, "dgemmBatched", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_dgemmBatched, "PyObject *(intptr_t, int, int, int, int, int, double, size_t, int, size_t, int, double, size_t, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_12, "cgemmBatched", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_cgemmBatched, "PyObject *(intptr_t, int, int, int, int, int, __pyx_t_float_complex, size_t, int, size_t, int, __pyx_t_float_complex, size_t, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_12, "zgemmBatched", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_zgemmBatched, "PyObject *(intptr_t, int, int, int, int, int, __pyx_t_double_complex, size_t, int, size_t, int, __pyx_t_double_complex, size_t, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_12, "sgemmStridedBatched", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_sgemmStridedBatched, "PyObject *(intptr_t, int, int, int, int, int, float, size_t, int, PY_LONG_LONG, size_t, int, PY_LONG_LONG, float, size_t, int, PY_LONG_LONG, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_12, "dgemmStridedBatched", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_dgemmStridedBatched, "PyObject *(intptr_t, int, int, int, int, int, double, size_t, int, PY_LONG_LONG, size_t, int, PY_LONG_LONG, double, size_t, int, PY_LONG_LONG, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_12, "cgemmStridedBatched", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_cgemmStridedBatched, "PyObject *(intptr_t, int, int, int, int, int, __pyx_t_float_complex, size_t, int, PY_LONG_LONG, size_t, int, PY_LONG_LONG, __pyx_t_float_complex, size_t, int, PY_LONG_LONG, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_12, "zgemmStridedBatched", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_zgemmStridedBatched, "PyObject *(intptr_t, int, int, int, int, int, __pyx_t_double_complex, size_t, int, PY_LONG_LONG, size_t, int, PY_LONG_LONG, __pyx_t_double_complex, size_t, int, PY_LONG_LONG, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_12, "sgeam", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_sgeam, "PyObject *(intptr_t, int, int, int, int, float, size_t, int, float, size_t, int, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_12, "dgeam", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_dgeam, "PyObject *(intptr_t, int, int, int, int, double, size_t, int, double, size_t, int, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_12, "sgemmEx", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_sgemmEx, "PyObject *(intptr_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_12, "gemmEx", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_gemmEx, "PyObject *(intptr_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_12); __pyx_t_12 = 0;
  __pyx_t_13 = __Pyx_ImportModule("cupy.cuda.pinned_memory"); if (!__pyx_t_13) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_13, "_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_13, "alloc_pinned_memory", (void (**)(void))&__pyx_f_4cupy_4cuda_13pinned_memory_alloc_pinned_memory, "struct __pyx_obj_4cupy_4cuda_13pinned_memory_PinnedMemoryPointer *(size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_14 = __Pyx_ImportModule("cupy.cuda.runtime"); if (!__pyx_t_14) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_14, "runtimeGetVersion", (void (**)(void))&__pyx_f_4cupy_4cuda_7runtime_runtimeGetVersion, "int (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_14, "setDevice", (void (**)(void))&__pyx_f_4cupy_4cuda_7runtime_setDevice, "PyObject *(int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_15 = __Pyx_ImportModule("cupy.cuda.stream"); if (!__pyx_t_15) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_15, "get_current_stream_ptr", (void (**)(void))&__pyx_f_4cupy_4cuda_6stream_get_current_stream_ptr, "intptr_t (void)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_15, "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_15); __pyx_t_15 = 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_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_XDECREF(__pyx_t_15);
  __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__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
    #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;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  struct __pyx_opt_args_4cupy_4core_7_kernel_create_ufunc __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  struct __pyx_opt_args_4cupy_4core_4core__create_bit_op __pyx_t_10;
  struct __pyx_opt_args_4cupy_4core_4core_create_comparison __pyx_t_11;
  __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;
  if (unlikely(__Pyx_modinit_variable_import_code() != 0)) goto __pyx_L1_error;
  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":3
 * # distutils: language = c++
 * 
 * import functools             # <<<<<<<<<<<<<<
 * import os
 * import pickle
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_functools, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_functools, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":4
 * 
 * import functools
 * import os             # <<<<<<<<<<<<<<
 * import pickle
 * import re
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, 0); 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_os, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":5
 * import functools
 * import os
 * import pickle             # <<<<<<<<<<<<<<
 * import re
 * import sys
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_pickle, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pickle, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":6
 * import os
 * import pickle
 * import re             # <<<<<<<<<<<<<<
 * import sys
 * import warnings
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_re, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_re, __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 pickle
 * import re
 * import sys             # <<<<<<<<<<<<<<
 * import warnings
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, 0); 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_sys, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":8
 * import re
 * import sys
 * import warnings             # <<<<<<<<<<<<<<
 * 
 * import ctypes
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_warnings, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":10
 * import warnings
 * 
 * import ctypes             # <<<<<<<<<<<<<<
 * import numpy
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_ctypes, 0, 0); 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_ctypes, __pyx_t_1) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":11
 * 
 * import ctypes
 * import numpy             # <<<<<<<<<<<<<<
 * 
 * import cupy
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":13
 * import numpy
 * 
 * import cupy             # <<<<<<<<<<<<<<
 * from cupy.core._kernel import create_ufunc
 * from cupy.core._kernel import ElementwiseKernel
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_cupy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_cupy, __pyx_t_1) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":14
 * 
 * import cupy
 * from cupy.core._kernel import create_ufunc             # <<<<<<<<<<<<<<
 * from cupy.core._kernel import ElementwiseKernel
 * from cupy.core._kernel import ufunc  # NOQA
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_create_ufunc);
  __Pyx_GIVEREF(__pyx_n_s_create_ufunc);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_create_ufunc);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy_core__kernel, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __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_create_ufunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_ufunc, __pyx_t_1) < 0) __PYX_ERR(0, 14, __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":15
 * import cupy
 * from cupy.core._kernel import create_ufunc
 * from cupy.core._kernel import ElementwiseKernel             # <<<<<<<<<<<<<<
 * from cupy.core._kernel import ufunc  # NOQA
 * from cupy.core._reduction import ReductionKernel
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_ElementwiseKernel);
  __Pyx_GIVEREF(__pyx_n_s_ElementwiseKernel);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ElementwiseKernel);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_cupy_core__kernel, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __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_ElementwiseKernel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ElementwiseKernel, __pyx_t_2) < 0) __PYX_ERR(0, 15, __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":16
 * from cupy.core._kernel import create_ufunc
 * from cupy.core._kernel import ElementwiseKernel
 * from cupy.core._kernel import ufunc  # NOQA             # <<<<<<<<<<<<<<
 * from cupy.core._reduction import ReductionKernel
 * from cupy.core._ufuncs import elementwise_copy
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_ufunc);
  __Pyx_GIVEREF(__pyx_n_s_ufunc);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_ufunc);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy_core__kernel, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __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_ufunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ufunc, __pyx_t_1) < 0) __PYX_ERR(0, 16, __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":17
 * from cupy.core._kernel import ElementwiseKernel
 * from cupy.core._kernel import ufunc  # NOQA
 * from cupy.core._reduction import ReductionKernel             # <<<<<<<<<<<<<<
 * from cupy.core._ufuncs import elementwise_copy
 * from cupy.core._ufuncs import elementwise_copy_where
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_ReductionKernel);
  __Pyx_GIVEREF(__pyx_n_s_ReductionKernel);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ReductionKernel);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_cupy_core__reduction, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __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_ReductionKernel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ReductionKernel, __pyx_t_2) < 0) __PYX_ERR(0, 17, __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":18
 * from cupy.core._kernel import ufunc  # NOQA
 * from cupy.core._reduction import ReductionKernel
 * from cupy.core._ufuncs import elementwise_copy             # <<<<<<<<<<<<<<
 * from cupy.core._ufuncs import elementwise_copy_where
 * from cupy.core import flags
 */
  __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_elementwise_copy);
  __Pyx_GIVEREF(__pyx_n_s_elementwise_copy);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_elementwise_copy);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy_core__ufuncs, __pyx_t_1, 0); 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_elementwise_copy); 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_elementwise_copy, __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":19
 * from cupy.core._reduction import ReductionKernel
 * from cupy.core._ufuncs import elementwise_copy
 * from cupy.core._ufuncs import elementwise_copy_where             # <<<<<<<<<<<<<<
 * from cupy.core import flags
 * from cupy.core import syncdetect
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_elementwise_copy_where);
  __Pyx_GIVEREF(__pyx_n_s_elementwise_copy_where);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_elementwise_copy_where);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_cupy_core__ufuncs, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __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_elementwise_copy_where); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_elementwise_copy_where, __pyx_t_2) < 0) __PYX_ERR(0, 19, __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":20
 * from cupy.core._ufuncs import elementwise_copy
 * from cupy.core._ufuncs import elementwise_copy_where
 * from cupy.core import flags             # <<<<<<<<<<<<<<
 * from cupy.core import syncdetect
 * from cupy import cuda
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __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, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __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, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_flags, __pyx_t_1) < 0) __PYX_ERR(0, 20, __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":21
 * from cupy.core._ufuncs import elementwise_copy_where
 * from cupy.core import flags
 * from cupy.core import syncdetect             # <<<<<<<<<<<<<<
 * from cupy import cuda
 * from cupy.cuda import device
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_syncdetect);
  __Pyx_GIVEREF(__pyx_n_s_syncdetect);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_syncdetect);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_cupy_core, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __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_syncdetect); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_syncdetect, __pyx_t_2) < 0) __PYX_ERR(0, 21, __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":22
 * from cupy.core import flags
 * from cupy.core import syncdetect
 * from cupy import cuda             # <<<<<<<<<<<<<<
 * from cupy.cuda import device
 * from cupy.cuda import memory as memory_module
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_cuda);
  __Pyx_GIVEREF(__pyx_n_s_cuda);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_cuda);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __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_cuda); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_cuda, __pyx_t_1) < 0) __PYX_ERR(0, 22, __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":23
 * from cupy.core import syncdetect
 * from cupy import cuda
 * from cupy.cuda import device             # <<<<<<<<<<<<<<
 * from cupy.cuda import memory as memory_module
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __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, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __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, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_device, __pyx_t_2) < 0) __PYX_ERR(0, 23, __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":24
 * from cupy import cuda
 * from cupy.cuda import device
 * from cupy.cuda import memory as memory_module             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_memory);
  __Pyx_GIVEREF(__pyx_n_s_memory);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_memory);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy_cuda, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __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_memory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_memory_module, __pyx_t_1) < 0) __PYX_ERR(0, 24, __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":27
 * 
 * 
 * from cupy.cuda.runtime import CUDARuntimeError             # <<<<<<<<<<<<<<
 * from cupy import util
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_CUDARuntimeError);
  __Pyx_GIVEREF(__pyx_n_s_CUDARuntimeError);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_CUDARuntimeError);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_cupy_cuda_runtime, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __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_CUDARuntimeError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_CUDARuntimeError, __pyx_t_2) < 0) __PYX_ERR(0, 27, __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":28
 * 
 * from cupy.cuda.runtime import CUDARuntimeError
 * from cupy import util             # <<<<<<<<<<<<<<
 * 
 * cimport cpython  # NOQA
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __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, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __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, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_1) < 0) __PYX_ERR(0, 28, __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":97
 *     """
 * 
 *     def __init__(self, shape, dtype=float, memptr=None, strides=None,             # <<<<<<<<<<<<<<
 *                  order='C'):
 *         cdef Py_ssize_t x, itemsize
 */
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __pyx_k_ = ((PyObject *)(&PyFloat_Type));
  __Pyx_GIVEREF((&PyFloat_Type));

  /* "cupy/core/core.pyx":263
 *         return cupy.flatiter(self)
 * 
 *     __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, 263, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_ndarray);

  /* "cupy/core/core.pyx":1721
 * 
 * 
 * _HANDLED_TYPES = (ndarray, numpy.ndarray)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__HANDLED_TYPES);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__HANDLED_TYPES, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":1729
 * # TODO(niboshi): Move it out of core.pyx
 * 
 * cdef list _cupy_header_list = [             # <<<<<<<<<<<<<<
 *     'cupy/complex.cuh',
 *     'cupy/carray.cuh',
 */
  __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_cuh);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_cuh);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_cupy_complex_cuh);
  __Pyx_INCREF(__pyx_kp_u_cupy_carray_cuh);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_carray_cuh);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_kp_u_cupy_carray_cuh);
  __Pyx_INCREF(__pyx_kp_u_cupy_atomics_cuh);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_atomics_cuh);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u_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/core.pyx":1734
 *     'cupy/atomics.cuh',
 * ]
 * cdef str _cupy_header = ''.join(             # <<<<<<<<<<<<<<
 *     ['#include <%s>\n' % i for i in _cupy_header_list])
 * 
 */
  { /* enter inner scope */

    /* "cupy/core/core.pyx":1735
 * ]
 * 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(0, 1735, __pyx_L4_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(0, 1735, __pyx_L4_error)
    }
    __pyx_t_1 = __pyx_v_4cupy_4core_4core__cupy_header_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, 1735, __pyx_L4_error)
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1735, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_XGOTREF(__pyx_8genexpr3__pyx_v_4cupy_4core_4core_i);
      __Pyx_DECREF_SET(__pyx_8genexpr3__pyx_v_4cupy_4core_4core_i, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_include_s, __pyx_8genexpr3__pyx_v_4cupy_4core_4core_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1735, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 1735, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_8genexpr3__pyx_v_4cupy_4core_4core_i);
    __Pyx_DECREF_SET(__pyx_8genexpr3__pyx_v_4cupy_4core_4core_i, Py_None);
    goto __pyx_L7_exit_scope;
    __pyx_L4_error:;
    __Pyx_GOTREF(__pyx_8genexpr3__pyx_v_4cupy_4core_4core_i);
    __Pyx_DECREF_SET(__pyx_8genexpr3__pyx_v_4cupy_4core_4core_i, Py_None);
    goto __pyx_L1_error;
    __pyx_L7_exit_scope:;
  } /* exit inner scope */

  /* "cupy/core/core.pyx":1734
 *     'cupy/atomics.cuh',
 * ]
 * cdef str _cupy_header = ''.join(             # <<<<<<<<<<<<<<
 *     ['#include <%s>\n' % i for i in _cupy_header_list])
 * 
 */
  __pyx_t_1 = PyUnicode_Join(__pyx_kp_u__6, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1734, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__cupy_header);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__cupy_header, ((PyObject*)__pyx_t_1));
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1739
 * # 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_1 = PyList_New(20); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1739, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_complex_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_complex_h);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_cupy_complex_complex_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_math_private_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_math_private_h);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u_cupy_complex_math_private_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_complex_inl_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_complex_inl_h);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_cupy_complex_complex_inl_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_arithmetic_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_arithmetic_h);
  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_kp_u_cupy_complex_arithmetic_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_cproj_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_cproj_h);
  PyList_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_cupy_complex_cproj_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_cexp_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_cexp_h);
  PyList_SET_ITEM(__pyx_t_1, 5, __pyx_kp_u_cupy_complex_cexp_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_cexpf_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_cexpf_h);
  PyList_SET_ITEM(__pyx_t_1, 6, __pyx_kp_u_cupy_complex_cexpf_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_clog_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_clog_h);
  PyList_SET_ITEM(__pyx_t_1, 7, __pyx_kp_u_cupy_complex_clog_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_clogf_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_clogf_h);
  PyList_SET_ITEM(__pyx_t_1, 8, __pyx_kp_u_cupy_complex_clogf_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_cpow_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_cpow_h);
  PyList_SET_ITEM(__pyx_t_1, 9, __pyx_kp_u_cupy_complex_cpow_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_ccosh_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_ccosh_h);
  PyList_SET_ITEM(__pyx_t_1, 10, __pyx_kp_u_cupy_complex_ccosh_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_ccoshf_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_ccoshf_h);
  PyList_SET_ITEM(__pyx_t_1, 11, __pyx_kp_u_cupy_complex_ccoshf_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_csinh_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_csinh_h);
  PyList_SET_ITEM(__pyx_t_1, 12, __pyx_kp_u_cupy_complex_csinh_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_csinhf_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_csinhf_h);
  PyList_SET_ITEM(__pyx_t_1, 13, __pyx_kp_u_cupy_complex_csinhf_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_ctanh_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_ctanh_h);
  PyList_SET_ITEM(__pyx_t_1, 14, __pyx_kp_u_cupy_complex_ctanh_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_ctanhf_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_ctanhf_h);
  PyList_SET_ITEM(__pyx_t_1, 15, __pyx_kp_u_cupy_complex_ctanhf_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_csqrt_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_csqrt_h);
  PyList_SET_ITEM(__pyx_t_1, 16, __pyx_kp_u_cupy_complex_csqrt_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_csqrtf_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_csqrtf_h);
  PyList_SET_ITEM(__pyx_t_1, 17, __pyx_kp_u_cupy_complex_csqrtf_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_catrig_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_catrig_h);
  PyList_SET_ITEM(__pyx_t_1, 18, __pyx_kp_u_cupy_complex_catrig_h);
  __Pyx_INCREF(__pyx_kp_u_cupy_complex_catrigf_h);
  __Pyx_GIVEREF(__pyx_kp_u_cupy_complex_catrigf_h);
  PyList_SET_ITEM(__pyx_t_1, 19, __pyx_kp_u_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_1));
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1762
 * ]
 * 
 * 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/core.pyx":1763
 * 
 * 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/core.pyx":1789
 * 
 * # added at the module level for precompiling the regex
 * _cucomplex_include_tokens = ['', '#', 'include', '<', r'cuComplex\.h', '>']             # <<<<<<<<<<<<<<
 * _cucomplex_include_pattern = re.compile(r'\s*'.join(_cucomplex_include_tokens))
 * 
 */
  __pyx_t_1 = PyList_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1789, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_kp_u__6);
  __Pyx_GIVEREF(__pyx_kp_u__6);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u__6);
  __Pyx_INCREF(__pyx_kp_u__66);
  __Pyx_GIVEREF(__pyx_kp_u__66);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u__66);
  __Pyx_INCREF(__pyx_n_u_include);
  __Pyx_GIVEREF(__pyx_n_u_include);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_u_include);
  __Pyx_INCREF(__pyx_kp_u__67);
  __Pyx_GIVEREF(__pyx_kp_u__67);
  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_kp_u__67);
  __Pyx_INCREF(__pyx_kp_u_cuComplex_h);
  __Pyx_GIVEREF(__pyx_kp_u_cuComplex_h);
  PyList_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_cuComplex_h);
  __Pyx_INCREF(__pyx_kp_u__68);
  __Pyx_GIVEREF(__pyx_kp_u__68);
  PyList_SET_ITEM(__pyx_t_1, 5, __pyx_kp_u__68);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_cucomplex_include_tokens, __pyx_t_1) < 0) __PYX_ERR(0, 1789, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1790
 * # added at the module level for precompiling the regex
 * _cucomplex_include_tokens = ['', '#', 'include', '<', r'cuComplex\.h', '>']
 * _cucomplex_include_pattern = re.compile(r'\s*'.join(_cucomplex_include_tokens))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cucomplex_include_tokens); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyUnicode_Join(__pyx_kp_u_s_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_cucomplex_include_pattern, __pyx_t_1) < 0) __PYX_ERR(0, 1790, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1862
 * # =============================================================================
 * 
 * cdef str _id = 'out0 = in0'             # <<<<<<<<<<<<<<
 * 
 * cdef fill_kernel = ElementwiseKernel('T x', 'T y', 'y = x', 'fill')
 */
  __Pyx_INCREF(__pyx_kp_u_out0_in0);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__id);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__id, __pyx_kp_u_out0_in0);
  __Pyx_GIVEREF(__pyx_kp_u_out0_in0);

  /* "cupy/core/core.pyx":1864
 * cdef str _id = 'out0 = in0'
 * 
 * cdef fill_kernel = ElementwiseKernel('T x', 'T y', 'y = x', 'fill')             # <<<<<<<<<<<<<<
 * 
 * cdef str _divmod_float = '''
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ElementwiseKernel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1864, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1864, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core_fill_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core_fill_kernel, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":1866
 * cdef fill_kernel = ElementwiseKernel('T x', 'T y', 'y = x', 'fill')
 * 
 * cdef str _divmod_float = '''             # <<<<<<<<<<<<<<
 *     out0_type a = _floor_divide(in0, in1);
 *     out0 = a;
 */
  __Pyx_INCREF(__pyx_kp_u_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_u_out0_type_a__floor_divide_in0_i);
  __Pyx_GIVEREF(__pyx_kp_u_out0_type_a__floor_divide_in0_i);

  /* "cupy/core/core.pyx":1876
 *     ('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_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1876, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_kp_u_ee_ee);
  __Pyx_GIVEREF(__pyx_kp_u_ee_ee);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_u_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_4, 1, __pyx_v_4cupy_4core_4core__divmod_float);

  /* "cupy/core/core.pyx":1877
 *      'LL->LL', 'qq->qq', 'QQ->QQ',
 *      ('ee->ee', _divmod_float),
 *      ('ff->ff', _divmod_float),             # <<<<<<<<<<<<<<
 *      ('dd->dd', _divmod_float)),
 *     '''
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1877, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_kp_u_ff_ff);
  __Pyx_GIVEREF(__pyx_kp_u_ff_ff);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_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_1, 1, __pyx_v_4cupy_4core_4core__divmod_float);

  /* "cupy/core/core.pyx":1878
 *      ('ee->ee', _divmod_float),
 *      ('ff->ff', _divmod_float),
 *      ('dd->dd', _divmod_float)),             # <<<<<<<<<<<<<<
 *     '''
 *     if (in1 == 0) {
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1878, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_kp_u_dd_dd);
  __Pyx_GIVEREF(__pyx_kp_u_dd_dd);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_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_2, 1, __pyx_v_4cupy_4core_4core__divmod_float);

  /* "cupy/core/core.pyx":1874
 * 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_5 = PyTuple_New(13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1874, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_kp_u_bb_bb);
  __Pyx_GIVEREF(__pyx_kp_u_bb_bb);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u_bb_bb);
  __Pyx_INCREF(__pyx_kp_u_BB_BB);
  __Pyx_GIVEREF(__pyx_kp_u_BB_BB);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_kp_u_BB_BB);
  __Pyx_INCREF(__pyx_kp_u_hh_hh);
  __Pyx_GIVEREF(__pyx_kp_u_hh_hh);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_kp_u_hh_hh);
  __Pyx_INCREF(__pyx_kp_u_HH_HH);
  __Pyx_GIVEREF(__pyx_kp_u_HH_HH);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_kp_u_HH_HH);
  __Pyx_INCREF(__pyx_kp_u_ii_ii);
  __Pyx_GIVEREF(__pyx_kp_u_ii_ii);
  PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_kp_u_ii_ii);
  __Pyx_INCREF(__pyx_kp_u_II_II);
  __Pyx_GIVEREF(__pyx_kp_u_II_II);
  PyTuple_SET_ITEM(__pyx_t_5, 5, __pyx_kp_u_II_II);
  __Pyx_INCREF(__pyx_kp_u_ll_ll);
  __Pyx_GIVEREF(__pyx_kp_u_ll_ll);
  PyTuple_SET_ITEM(__pyx_t_5, 6, __pyx_kp_u_ll_ll);
  __Pyx_INCREF(__pyx_kp_u_LL_LL);
  __Pyx_GIVEREF(__pyx_kp_u_LL_LL);
  PyTuple_SET_ITEM(__pyx_t_5, 7, __pyx_kp_u_LL_LL);
  __Pyx_INCREF(__pyx_kp_u_qq_qq);
  __Pyx_GIVEREF(__pyx_kp_u_qq_qq);
  PyTuple_SET_ITEM(__pyx_t_5, 8, __pyx_kp_u_qq_qq);
  __Pyx_INCREF(__pyx_kp_u_QQ_QQ);
  __Pyx_GIVEREF(__pyx_kp_u_QQ_QQ);
  PyTuple_SET_ITEM(__pyx_t_5, 9, __pyx_kp_u_QQ_QQ);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 10, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 11, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 12, __pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":1872
 * 
 * 
 * divmod = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divmod',
 *     ('bb->bb', 'BB->BB', 'hh->hh', 'HH->HH', 'ii->ii', 'II->II', 'll->ll',
 */
  __pyx_t_6.__pyx_n = 1;
  __pyx_t_6.routine = __pyx_kp_u_if_in1_0_out0_0_out1_0_else_out;
  __pyx_t_2 = __pyx_f_4cupy_4core_7_kernel_create_ufunc(__pyx_n_u_cupy_divmod, __pyx_t_5, 0, &__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1872, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_divmod, __pyx_t_2) < 0) __PYX_ERR(0, 1872, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/core.pyx":1890
 * 
 * 
 * cdef _round_preamble = '''             # <<<<<<<<<<<<<<
 * template<typename T> __device__ T pow10(long long n){
 *   T x = 1, a = 10;
 */
  __Pyx_INCREF(__pyx_kp_u_template_typename_T___device);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__round_preamble);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__round_preamble, __pyx_kp_u_template_typename_T___device);
  __Pyx_GIVEREF(__pyx_kp_u_template_typename_T___device);

  /* "cupy/core/core.pyx":1903
 * 
 * 
 * cdef _round_float = '''             # <<<<<<<<<<<<<<
 * if (in1 == 0) {
 *     out0 = round(in0);
 */
  __Pyx_INCREF(__pyx_kp_u_if_in1_0_out0_round_in0_else_do);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__round_float);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__round_float, __pyx_kp_u_if_in1_0_out0_round_in0_else_do);
  __Pyx_GIVEREF(__pyx_kp_u_if_in1_0_out0_round_in0_else_do);

  /* "cupy/core/core.pyx":1912
 * }'''
 * 
 * cdef _round_complex = '''             # <<<<<<<<<<<<<<
 * double x, inv_x;
 * if (in1 == 0) {
 */
  __Pyx_INCREF(__pyx_kp_u_double_x_inv_x_if_in1_0_x_inv_x);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__round_complex);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__round_complex, __pyx_kp_u_double_x_inv_x_if_in1_0_x_inv_x);
  __Pyx_GIVEREF(__pyx_kp_u_double_x_inv_x_if_in1_0_x_inv_x);

  /* "cupy/core/core.pyx":1934
 *      'bq->b', 'Bq->B', 'hq->h', 'Hq->H', 'iq->i', 'Iq->I', 'lq->l', 'Lq->L',
 *      'qq->q', 'Qq->Q',
 *      ('eq->e', _round_float),             # <<<<<<<<<<<<<<
 *      ('fq->f', _round_float),
 *      ('dq->d', _round_float),
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1934, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_kp_u_eq_e);
  __Pyx_GIVEREF(__pyx_kp_u_eq_e);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_eq_e);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__round_float);
  __Pyx_GIVEREF(__pyx_v_4cupy_4core_4core__round_float);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_4cupy_4core_4core__round_float);

  /* "cupy/core/core.pyx":1935
 *      'qq->q', 'Qq->Q',
 *      ('eq->e', _round_float),
 *      ('fq->f', _round_float),             # <<<<<<<<<<<<<<
 *      ('dq->d', _round_float),
 *      ('Fq->F', _round_complex),
 */
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1935, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_kp_u_fq_f);
  __Pyx_GIVEREF(__pyx_kp_u_fq_f);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u_fq_f);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__round_float);
  __Pyx_GIVEREF(__pyx_v_4cupy_4core_4core__round_float);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_4cupy_4core_4core__round_float);

  /* "cupy/core/core.pyx":1936
 *      ('eq->e', _round_float),
 *      ('fq->f', _round_float),
 *      ('dq->d', _round_float),             # <<<<<<<<<<<<<<
 *      ('Fq->F', _round_complex),
 *      ('Dq->D', _round_complex)),
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1936, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_kp_u_dq_d);
  __Pyx_GIVEREF(__pyx_kp_u_dq_d);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_dq_d);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__round_float);
  __Pyx_GIVEREF(__pyx_v_4cupy_4core_4core__round_float);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_4cupy_4core_4core__round_float);

  /* "cupy/core/core.pyx":1937
 *      ('fq->f', _round_float),
 *      ('dq->d', _round_float),
 *      ('Fq->F', _round_complex),             # <<<<<<<<<<<<<<
 *      ('Dq->D', _round_complex)),
 *     '''
 */
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1937, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_kp_u_Fq_F);
  __Pyx_GIVEREF(__pyx_kp_u_Fq_F);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_u_Fq_F);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__round_complex);
  __Pyx_GIVEREF(__pyx_v_4cupy_4core_4core__round_complex);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_4cupy_4core_4core__round_complex);

  /* "cupy/core/core.pyx":1938
 *      ('dq->d', _round_float),
 *      ('Fq->F', _round_complex),
 *      ('Dq->D', _round_complex)),             # <<<<<<<<<<<<<<
 *     '''
 *     if (in1 < 0) {
 */
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1938, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_kp_u_Dq_D);
  __Pyx_GIVEREF(__pyx_kp_u_Dq_D);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_kp_u_Dq_D);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__round_complex);
  __Pyx_GIVEREF(__pyx_v_4cupy_4core_4core__round_complex);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_4cupy_4core_4core__round_complex);

  /* "cupy/core/core.pyx":1931
 * _round_ufunc = create_ufunc(
 *     'cupy_round',
 *     ('?q->e',             # <<<<<<<<<<<<<<
 *      'bq->b', 'Bq->B', 'hq->h', 'Hq->H', 'iq->i', 'Iq->I', 'lq->l', 'Lq->L',
 *      'qq->q', 'Qq->Q',
 */
  __pyx_t_8 = PyTuple_New(16); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1931, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_kp_u_q_e);
  __Pyx_GIVEREF(__pyx_kp_u_q_e);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_kp_u_q_e);
  __Pyx_INCREF(__pyx_kp_u_bq_b);
  __Pyx_GIVEREF(__pyx_kp_u_bq_b);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_kp_u_bq_b);
  __Pyx_INCREF(__pyx_kp_u_Bq_B);
  __Pyx_GIVEREF(__pyx_kp_u_Bq_B);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_kp_u_Bq_B);
  __Pyx_INCREF(__pyx_kp_u_hq_h);
  __Pyx_GIVEREF(__pyx_kp_u_hq_h);
  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_kp_u_hq_h);
  __Pyx_INCREF(__pyx_kp_u_Hq_H);
  __Pyx_GIVEREF(__pyx_kp_u_Hq_H);
  PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_kp_u_Hq_H);
  __Pyx_INCREF(__pyx_kp_u_iq_i);
  __Pyx_GIVEREF(__pyx_kp_u_iq_i);
  PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_kp_u_iq_i);
  __Pyx_INCREF(__pyx_kp_u_Iq_I);
  __Pyx_GIVEREF(__pyx_kp_u_Iq_I);
  PyTuple_SET_ITEM(__pyx_t_8, 6, __pyx_kp_u_Iq_I);
  __Pyx_INCREF(__pyx_kp_u_lq_l);
  __Pyx_GIVEREF(__pyx_kp_u_lq_l);
  PyTuple_SET_ITEM(__pyx_t_8, 7, __pyx_kp_u_lq_l);
  __Pyx_INCREF(__pyx_kp_u_Lq_L);
  __Pyx_GIVEREF(__pyx_kp_u_Lq_L);
  PyTuple_SET_ITEM(__pyx_t_8, 8, __pyx_kp_u_Lq_L);
  __Pyx_INCREF(__pyx_kp_u_qq_q);
  __Pyx_GIVEREF(__pyx_kp_u_qq_q);
  PyTuple_SET_ITEM(__pyx_t_8, 9, __pyx_kp_u_qq_q);
  __Pyx_INCREF(__pyx_kp_u_Qq_Q);
  __Pyx_GIVEREF(__pyx_kp_u_Qq_Q);
  PyTuple_SET_ITEM(__pyx_t_8, 10, __pyx_kp_u_Qq_Q);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_8, 11, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_8, 12, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 13, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_8, 14, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_8, 15, __pyx_t_7);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = 0;
  __pyx_t_4 = 0;
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":1947
 *     } else {
 *         out0 = in0;
 *     }''', preamble=_round_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_7 = __pyx_v_4cupy_4core_4core__round_preamble;
  __Pyx_INCREF(__pyx_t_7);

  /* "cupy/core/core.pyx":1929
 * 
 * 
 * _round_ufunc = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_round',
 *     ('?q->e',
 */
  __pyx_t_6.__pyx_n = 2;
  __pyx_t_6.routine = __pyx_kp_u_if_in1_0_TODO_okuta_Move_before;
  __pyx_t_6.preamble = __pyx_t_7;
  __pyx_t_4 = __pyx_f_4cupy_4core_7_kernel_create_ufunc(__pyx_n_u_cupy_round, __pyx_t_8, 0, &__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __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_round_ufunc, __pyx_t_4) < 0) __PYX_ERR(0, 1929, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2172
 * 
 * cdef bint _numpy_concatenate_has_out_argument = (
 *     numpy.lib.NumpyVersion(numpy.__version__) >= '1.14.0')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_lib); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_NumpyVersion); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_version_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyObject_RichCompare(__pyx_t_7, __pyx_kp_u_1_14_0, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2172, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2172, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_4cupy_4core_4core__numpy_concatenate_has_out_argument = __pyx_t_9;

  /* "cupy/core/core.pyx":2302
 * 
 * 
 * bitwise_and = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_and', '&', False,
 *     '''Computes the bitwise AND of two arrays elementwise.
 */
  __pyx_t_10.__pyx_n = 1;
  __pyx_t_10.doc = __pyx_kp_u_Computes_the_bitwise_AND_of_two;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_u_bitwise_and, __pyx_kp_u__70, Py_False, 0, &__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_and, __pyx_t_8) < 0) __PYX_ERR(0, 2302, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2313
 * 
 * 
 * bitwise_or = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_or', '|', False,
 *     '''Computes the bitwise OR of two arrays elementwise.
 */
  __pyx_t_10.__pyx_n = 1;
  __pyx_t_10.doc = __pyx_kp_u_Computes_the_bitwise_OR_of_two_a;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_u_bitwise_or, __pyx_kp_u__71, Py_False, 0, &__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_or, __pyx_t_8) < 0) __PYX_ERR(0, 2313, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2324
 * 
 * 
 * bitwise_xor = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_xor', '^', False,
 *     '''Computes the bitwise XOR of two arrays elementwise.
 */
  __pyx_t_10.__pyx_n = 1;
  __pyx_t_10.doc = __pyx_kp_u_Computes_the_bitwise_XOR_of_two;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_u_bitwise_xor, __pyx_kp_u__72, Py_False, 0, &__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2324, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_xor, __pyx_t_8) < 0) __PYX_ERR(0, 2324, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2335
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/core.pyx":2340
 *      '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_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_doc, __pyx_kp_u_Computes_the_bitwise_NOT_of_an_a) < 0) __PYX_ERR(0, 2340, __pyx_L1_error)

  /* "cupy/core/core.pyx":2335
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__76, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __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_invert, __pyx_t_4) < 0) __PYX_ERR(0, 2335, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2352
 * 
 * 
 * left_shift = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'left_shift', '<<', True,
 *     '''Shifts the bits of each integer element to the left.
 */
  __pyx_t_10.__pyx_n = 1;
  __pyx_t_10.doc = __pyx_kp_u_Shifts_the_bits_of_each_integer;
  __pyx_t_4 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_u_left_shift, __pyx_kp_u__77, Py_True, 0, &__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_left_shift, __pyx_t_4) < 0) __PYX_ERR(0, 2352, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2363
 * 
 * 
 * right_shift = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'right_shift', '>>', True,
 *     '''Shifts the bits of each integer element to the right.
 */
  __pyx_t_10.__pyx_n = 1;
  __pyx_t_10.doc = __pyx_kp_u_Shifts_the_bits_of_each_integer_2;
  __pyx_t_4 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_u_right_shift, __pyx_kp_u__78, Py_True, 0, &__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_right_shift, __pyx_t_4) < 0) __PYX_ERR(0, 2363, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2442
 * 
 * 
 * cdef _mat_ptrs_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'T base, T stride', 'T out',
 *     'out = base + _ind.get()[_ind.ndim - 1] * stride', 'mat_ptrs',
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_ElementwiseKernel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":2445
 *     'T base, T stride', 'T out',
 *     'out = base + _ind.get()[_ind.ndim - 1] * stride', 'mat_ptrs',
 *     reduce_dims=False)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_reduce_dims, Py_False) < 0) __PYX_ERR(0, 2445, __pyx_L1_error)

  /* "cupy/core/core.pyx":2442
 * 
 * 
 * cdef _mat_ptrs_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'T base, T stride', 'T out',
 *     'out = base + _ind.get()[_ind.ndim - 1] * stride', 'mat_ptrs',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__79, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__mat_ptrs_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__mat_ptrs_kernel, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2729
 * 
 * 
 * cdef int _cuda_runtime_version = -1             # <<<<<<<<<<<<<<
 * cdef _tensordot_core_mul_sum = ReductionKernel(
 *     'S x, T y', 'U out',
 */
  __pyx_v_4cupy_4core_4core__cuda_runtime_version = -1;

  /* "cupy/core/core.pyx":2730
 * 
 * cdef int _cuda_runtime_version = -1
 * 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, 2730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __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_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2902
 * 
 * 
 * greater = create_comparison(             # <<<<<<<<<<<<<<
 *     'greater', '>',
 *     '''Tests elementwise if ``x1 > x2``.
 */
  __pyx_t_11.__pyx_n = 2;
  __pyx_t_11.doc = __pyx_kp_u_Tests_elementwise_if_x1_x2_seeal;
  __pyx_t_11.no_complex_dtype = Py_False;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_u_greater, __pyx_kp_u__68, 0, &__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2902, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_greater, __pyx_t_7) < 0) __PYX_ERR(0, 2902, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2912
 * 
 * 
 * greater_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'greater_equal', '>=',
 *     '''Tests elementwise if ``x1 >= x2``.
 */
  __pyx_t_11.__pyx_n = 2;
  __pyx_t_11.doc = __pyx_kp_u_Tests_elementwise_if_x1_x2_seeal_2;
  __pyx_t_11.no_complex_dtype = Py_False;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_u_greater_equal, __pyx_kp_u__81, 0, &__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_greater_equal, __pyx_t_7) < 0) __PYX_ERR(0, 2912, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2922
 * 
 * 
 * less = create_comparison(             # <<<<<<<<<<<<<<
 *     'less', '<',
 *     '''Tests elementwise if ``x1 < x2``.
 */
  __pyx_t_11.__pyx_n = 2;
  __pyx_t_11.doc = __pyx_kp_u_Tests_elementwise_if_x1_x2_seeal_3;
  __pyx_t_11.no_complex_dtype = Py_False;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_u_less, __pyx_kp_u__67, 0, &__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2922, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_less, __pyx_t_7) < 0) __PYX_ERR(0, 2922, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2932
 * 
 * 
 * less_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'less_equal', '<=',
 *     '''Tests elementwise if ``x1 <= x2``.
 */
  __pyx_t_11.__pyx_n = 2;
  __pyx_t_11.doc = __pyx_kp_u_Tests_elementwise_if_x1_x2_seeal_4;
  __pyx_t_11.no_complex_dtype = Py_False;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_u_less_equal, __pyx_kp_u__82, 0, &__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2932, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_less_equal, __pyx_t_7) < 0) __PYX_ERR(0, 2932, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2942
 * 
 * 
 * equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'equal', '==',
 *     '''Tests elementwise if ``x1 == x2``.
 */
  __pyx_t_11.__pyx_n = 2;
  __pyx_t_11.doc = __pyx_kp_u_Tests_elementwise_if_x1_x2_seeal_5;
  __pyx_t_11.no_complex_dtype = Py_False;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_u_equal, __pyx_kp_u__83, 0, &__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2942, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_equal, __pyx_t_7) < 0) __PYX_ERR(0, 2942, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":2952
 * 
 * 
 * not_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'not_equal', '!=',
 *     '''Tests elementwise if ``x1 != x2``.
 */
  __pyx_t_11.__pyx_n = 2;
  __pyx_t_11.doc = __pyx_kp_u_Tests_elementwise_if_x1_x2_seeal_6;
  __pyx_t_11.no_complex_dtype = Py_False;
  __pyx_t_7 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_u_not_equal, __pyx_kp_u__84, 0, &__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2952, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_not_equal, __pyx_t_7) < 0) __PYX_ERR(0, 2952, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":1
 * # distutils: language = c++             # <<<<<<<<<<<<<<
 * 
 * import functools
 */
  __pyx_t_7 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_7, __pyx_kp_u_ndarray___getitem___line_1183, __pyx_kp_u_x___getitem___y_x_y_Supports_bot) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_7, __pyx_kp_u_ndarray___setitem___line_1207, __pyx_kp_u_x___setitem___slices_y_x_slices) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_7, __pyx_kp_u_ndarray_toDlpack_line_1648, __pyx_kp_u_Zero_copy_conversion_to_a_DLPack) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_7) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "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())]
 * 
 */

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __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_7);
  __Pyx_XDECREF(__pyx_t_8);
  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);
}

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

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

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

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

/* RaiseTooManyValuesToUnpack */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

/* RaiseNeedMoreValuesToUnpack */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

/* RaiseNoneIterError */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

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

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

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

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

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

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

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

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

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

/* 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 void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

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

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

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

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

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

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

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

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

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

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

/* SliceObject */
        static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value,
        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_ass_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_ass_slice(obj, cstart, cstop, value);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_ass_subscript))
#endif
    {
        int 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_ass_subscript(obj, py_slice, value);
#else
        result = value ? PyObject_SetItem(obj, py_slice, value) : PyObject_DelItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object does not support slice %.10s",
        Py_TYPE(obj)->tp_name, value ? "assignment" : "deletion");
bad:
    return -1;
}

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

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

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

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

/* 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
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
      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);
}

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

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

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

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

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

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

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

/* VoidPtrImport */
            #ifndef __PYX_HAVE_RT_ImportVoidPtr
#define __PYX_HAVE_RT_ImportVoidPtr
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, name);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C variable %.200s",
                PyModule_GetName(module), name);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    *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 variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), name, sig, desc);
        goto bad;
    }
    *p = PyCObject_AsVoidPtr(cobj);}
#endif
    if (!(*p))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#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_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
